todo: update metadata
This commit is contained in:
parent
54defcc4f1
commit
ff7dbbc5e6
4 changed files with 477 additions and 331 deletions
|
|
@ -1,11 +1,11 @@
|
||||||
# 
|
# 
|
||||||
|
|
||||||
[](https://crates.io/crates/smartcrop2)
|
[](https://crates.io/crates/rustypipe)
|
||||||
[](http://opensource.org/licenses/MIT)
|
[](http://opensource.org/licenses/MIT)
|
||||||
[](https://code.thetadev.de/ThetaDev/rustypipe/actions/?workflow=ci.yaml)
|
[](https://code.thetadev.de/ThetaDev/rustypipe/actions/?workflow=ci.yaml)
|
||||||
|
|
||||||
Rust client for the public YouTube / YouTube Music API (Innertube), inspired by
|
RustyPipe is a fully featured Rust client for the public YouTube / YouTube Music API
|
||||||
[NewPipe](https://github.com/TeamNewPipe/NewPipeExtractor).
|
(Innertube), inspired by [NewPipe](https://github.com/TeamNewPipe/NewPipeExtractor).
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1 +1,94 @@
|
||||||
# RustyPipe CLI
|
#  CLI
|
||||||
|
|
||||||
|
[](https://crates.io/crates/rustypipe-cli)
|
||||||
|
[](http://opensource.org/licenses/MIT)
|
||||||
|
[](https://code.thetadev.de/ThetaDev/rustypipe/actions/?workflow=ci.yaml)
|
||||||
|
|
||||||
|
The RustyPipe CLI is a powerful YouTube client for the command line. It allows you to
|
||||||
|
access most of the features of the RustyPipe crate: getting data from YouTube and
|
||||||
|
downloading videos.
|
||||||
|
|
||||||
|
The following subcommands are included:
|
||||||
|
|
||||||
|
## `get`: Fetch information
|
||||||
|
|
||||||
|
You can call the get command with any YouTube entity ID or URL and RustyPipe will fetch
|
||||||
|
the associated metadata. It can fetch channels, playlists, albums and videos.
|
||||||
|
|
||||||
|
**Usage:** `rustypipe get UC2TXq_t06Hjdr2g_KdKpHQg`
|
||||||
|
|
||||||
|
- `-l`, `--limit` Limit the number of list items to fetch
|
||||||
|
- ``-t, --tab` Channel tab (options: **videos**, shorts, live, playlists, info)
|
||||||
|
- `-m, --music` Use the YouTube Music API
|
||||||
|
- `--rss`Fetch the RSS feed of a channel
|
||||||
|
- `--comments` Get comments (options: top, latest)
|
||||||
|
- `--lyrics` Get the lyrics for YTM tracks
|
||||||
|
- `--player` Get the player data instead of the video details when fetching videos
|
||||||
|
- `-c, --client-type` YT clients used to fetch player data (options: desktop, tv,
|
||||||
|
tv-embed, android, ios; if multiple clients are specified, they are attempted in
|
||||||
|
order)
|
||||||
|
|
||||||
|
## `search`: Search YouTube
|
||||||
|
|
||||||
|
With the search command you can search the entire YouTube platform or individual
|
||||||
|
channels. YouTube Music search is also supported.
|
||||||
|
|
||||||
|
Note that search filters are only supported when searching YouTube. They have no effect
|
||||||
|
when searching YTM or individual channels.
|
||||||
|
|
||||||
|
**Usage:** `rustypipe search "query"`
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
- `-l`, `--limit` Limit the number of list items to fetch
|
||||||
|
|
||||||
|
- `--item-type` Filter results by item type
|
||||||
|
- `--length` Filter results by video length
|
||||||
|
- `--date` Filter results by upload date (options: hour, day, week, month, year)
|
||||||
|
- `--order` Sort search results (options: rating, date, views)
|
||||||
|
- `--channel` Channel ID for searching channel videos
|
||||||
|
- `-m, --music` Search YouTube Music in the given category (options: all, tracks,
|
||||||
|
videos, artists, albums, playlists-ytm, playlists-community)
|
||||||
|
|
||||||
|
## `dl`: Download videos
|
||||||
|
|
||||||
|
The downloader can download individual videos, playlists, albums and channels. Multiple
|
||||||
|
videos can be downloaded in parallel for improved performance.
|
||||||
|
|
||||||
|
**Usage:** `rustypipe dl eRsGyueVLvQ`
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
- `-o`, `--output` Download to the given directory
|
||||||
|
- `--output-file` Download to the given file
|
||||||
|
- `--template` Download to a path determined by a template
|
||||||
|
|
||||||
|
- `-r`, `--resolution` Video resolution (e.g. 720, 1080). Set to 0 for audio-only
|
||||||
|
- `-a`, `--audio` Download only the audio track and write track metadata + album cover
|
||||||
|
- `-p`, `--parallel` Number of videos downloaded in parallel (default: 8)
|
||||||
|
- `-m, --music` Use YouTube Music for downloading playlists
|
||||||
|
- `-l`, `--limit` Limit the number of videos to download (default: 1000)
|
||||||
|
- `-c`, `--client-type` YT clients used to fetch player data (options: desktop, tv,
|
||||||
|
tv-embed, android, ios; if multiple clients are specified, they are attempted in
|
||||||
|
order)
|
||||||
|
- `--pot` token to circumvent bot detection
|
||||||
|
|
||||||
|
## `vdata`: Get visitor data
|
||||||
|
|
||||||
|
You can use the vdata command to get a new visitor data cookie. This feature may come in
|
||||||
|
handy for testing and reproducing A/B tests.
|
||||||
|
|
||||||
|
## Global options
|
||||||
|
|
||||||
|
- **Proxy:** RustyPipe respects the environment variables `HTTP_PROXY`, `HTTPS_PROXY`
|
||||||
|
and `ALL_PROXY`
|
||||||
|
- **Logging:** You can change the log level with the `RUST_LOG` environment variable, it
|
||||||
|
is set to `info` by default
|
||||||
|
- **Visitor data:** A custom visitor data cookie can be used with the `--vdata` flag
|
||||||
|
- `--report`
|
||||||
|
|
||||||
|
### Output format
|
||||||
|
|
||||||
|
By default, the CLI outputs YouTube data in a human-readable text format. If you want to
|
||||||
|
store the data or process it with a script, you should choose a machine readable output
|
||||||
|
format. You can choose both JSON and YAML with the `-f, --format` flag.
|
||||||
|
|
|
||||||
207
cli/src/main.rs
207
cli/src/main.rs
|
|
@ -49,10 +49,13 @@ struct Cli {
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[group(multiple = false)]
|
#[group(multiple = false)]
|
||||||
struct DownloadTarget {
|
struct DownloadTarget {
|
||||||
|
/// Download to the given directory
|
||||||
#[clap(short, long)]
|
#[clap(short, long)]
|
||||||
output: Option<PathBuf>,
|
output: Option<PathBuf>,
|
||||||
|
/// Download to the given file
|
||||||
#[clap(long)]
|
#[clap(long)]
|
||||||
output_file: Option<PathBuf>,
|
output_file: Option<PathBuf>,
|
||||||
|
/// Download to a path determined by a template
|
||||||
#[clap(long)]
|
#[clap(long)]
|
||||||
template: Option<String>,
|
template: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
@ -93,7 +96,7 @@ enum Commands {
|
||||||
/// Video resolution (e.g. 720, 1080). Set to 0 for audio-only.
|
/// Video resolution (e.g. 720, 1080). Set to 0 for audio-only.
|
||||||
#[clap(short, long)]
|
#[clap(short, long)]
|
||||||
resolution: Option<u32>,
|
resolution: Option<u32>,
|
||||||
/// Download only the audio track
|
/// Download only the audio track and write track information
|
||||||
#[clap(short, long)]
|
#[clap(short, long)]
|
||||||
audio: bool,
|
audio: bool,
|
||||||
/// Number of videos downloaded in parallel
|
/// Number of videos downloaded in parallel
|
||||||
|
|
@ -117,24 +120,21 @@ enum Commands {
|
||||||
/// ID or URL
|
/// ID or URL
|
||||||
id: String,
|
id: String,
|
||||||
/// Output format
|
/// Output format
|
||||||
#[clap(long, value_parser, default_value = "json")]
|
#[clap(short, long, value_parser)]
|
||||||
format: Format,
|
format: Option<Format>,
|
||||||
/// Pretty-print output
|
/// Pretty-print output
|
||||||
#[clap(long)]
|
#[clap(long)]
|
||||||
pretty: bool,
|
pretty: bool,
|
||||||
/// Output as text
|
|
||||||
#[clap(short, long)]
|
|
||||||
txt: bool,
|
|
||||||
/// Limit the number of items to fetch
|
/// Limit the number of items to fetch
|
||||||
#[clap(short, long, default_value_t = 20)]
|
#[clap(short, long, default_value_t = 20)]
|
||||||
limit: usize,
|
limit: usize,
|
||||||
/// Channel tab
|
/// Channel tab
|
||||||
#[clap(long, default_value = "videos")]
|
#[clap(short, long, default_value = "videos")]
|
||||||
tab: ChannelTab,
|
tab: ChannelTab,
|
||||||
/// Use YouTube Music
|
/// Use YouTube Music
|
||||||
#[clap(short, long)]
|
#[clap(short, long)]
|
||||||
music: bool,
|
music: bool,
|
||||||
/// Use the RSS feed of a channel
|
/// Fetch the RSS feed of a channel
|
||||||
#[clap(long)]
|
#[clap(long)]
|
||||||
rss: bool,
|
rss: bool,
|
||||||
/// Get comments
|
/// Get comments
|
||||||
|
|
@ -148,21 +148,18 @@ enum Commands {
|
||||||
player: bool,
|
player: bool,
|
||||||
/// YT Client used to fetch player data
|
/// YT Client used to fetch player data
|
||||||
#[clap(short, long)]
|
#[clap(short, long)]
|
||||||
client_type: Option<ClientTypeArg>,
|
client_type: Option<Vec<ClientTypeArg>>,
|
||||||
},
|
},
|
||||||
/// Search YouTube
|
/// Search YouTube
|
||||||
Search {
|
Search {
|
||||||
/// Search query
|
/// Search query
|
||||||
query: String,
|
query: String,
|
||||||
/// Output format
|
/// Output format
|
||||||
#[clap(long, value_parser, default_value = "json")]
|
#[clap(short, long, value_parser)]
|
||||||
format: Format,
|
format: Option<Format>,
|
||||||
/// Pretty-print output
|
/// Pretty-print output
|
||||||
#[clap(long)]
|
#[clap(long)]
|
||||||
pretty: bool,
|
pretty: bool,
|
||||||
/// Output as text
|
|
||||||
#[clap(short, long)]
|
|
||||||
txt: bool,
|
|
||||||
/// Limit the number of items to fetch
|
/// Limit the number of items to fetch
|
||||||
#[clap(short, long, default_value_t = 20)]
|
#[clap(short, long, default_value_t = 20)]
|
||||||
limit: usize,
|
limit: usize,
|
||||||
|
|
@ -181,7 +178,7 @@ enum Commands {
|
||||||
/// Channel ID for searching channel videos
|
/// Channel ID for searching channel videos
|
||||||
#[clap(long)]
|
#[clap(long)]
|
||||||
channel: Option<String>,
|
channel: Option<String>,
|
||||||
/// YouTube Music search filter
|
/// Search YouTube Music in the given category
|
||||||
#[clap(short, long)]
|
#[clap(short, long)]
|
||||||
music: Option<MusicSearchCategory>,
|
music: Option<MusicSearchCategory>,
|
||||||
},
|
},
|
||||||
|
|
@ -189,8 +186,9 @@ enum Commands {
|
||||||
Vdata,
|
Vdata,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, ValueEnum)]
|
#[derive(Default, Copy, Clone, ValueEnum)]
|
||||||
enum Format {
|
enum Format {
|
||||||
|
#[default]
|
||||||
Json,
|
Json,
|
||||||
Yaml,
|
Yaml,
|
||||||
}
|
}
|
||||||
|
|
@ -388,17 +386,17 @@ fn print_duration(duration: Option<u32>) {
|
||||||
|
|
||||||
fn print_music_search<T: Serialize + YtEntity>(
|
fn print_music_search<T: Serialize + YtEntity>(
|
||||||
data: &MusicSearchResult<T>,
|
data: &MusicSearchResult<T>,
|
||||||
format: Format,
|
format: Option<Format>,
|
||||||
pretty: bool,
|
pretty: bool,
|
||||||
txt: bool,
|
|
||||||
) {
|
) {
|
||||||
if txt {
|
match format {
|
||||||
|
Some(format) => print_data(data, format, pretty),
|
||||||
|
None => {
|
||||||
if let Some(corr) = &data.corrected_query {
|
if let Some(corr) = &data.corrected_query {
|
||||||
anstream::println!("Did you mean `{}`?", corr.magenta());
|
anstream::println!("Did you mean `{}`?", corr.magenta());
|
||||||
}
|
}
|
||||||
print_entities(&data.items.items);
|
print_entities(&data.items.items);
|
||||||
} else {
|
}
|
||||||
print_data(data, format, pretty)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -406,7 +404,7 @@ fn print_description(desc: Option<String>) {
|
||||||
if let Some(desc) = desc {
|
if let Some(desc) = desc {
|
||||||
if !desc.is_empty() {
|
if !desc.is_empty() {
|
||||||
print_h2("Description");
|
print_h2("Description");
|
||||||
println!("{}", desc);
|
println!("{}", desc.trim());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -651,7 +649,6 @@ async fn run() -> anyhow::Result<()> {
|
||||||
Commands::Get {
|
Commands::Get {
|
||||||
id,
|
id,
|
||||||
format,
|
format,
|
||||||
txt,
|
|
||||||
pretty,
|
pretty,
|
||||||
limit,
|
limit,
|
||||||
tab,
|
tab,
|
||||||
|
|
@ -671,17 +668,18 @@ async fn run() -> anyhow::Result<()> {
|
||||||
match details.lyrics_id {
|
match details.lyrics_id {
|
||||||
Some(lyrics_id) => {
|
Some(lyrics_id) => {
|
||||||
let lyrics = rp.query().music_lyrics(lyrics_id).await?;
|
let lyrics = rp.query().music_lyrics(lyrics_id).await?;
|
||||||
if txt {
|
match format {
|
||||||
println!("{}\n\n{}", lyrics.body, lyrics.footer.blue());
|
Some(format) => print_data(&lyrics, format, pretty),
|
||||||
} else {
|
None => println!("{}\n\n{}", lyrics.body, lyrics.footer.blue()),
|
||||||
print_data(&lyrics, format, pretty);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => eprintln!("no lyrics found"),
|
None => eprintln!("no lyrics found"),
|
||||||
}
|
}
|
||||||
} else if music {
|
} else if music {
|
||||||
let details = rp.query().music_details(&id).await?;
|
let details = rp.query().music_details(&id).await?;
|
||||||
if txt {
|
match format {
|
||||||
|
Some(format) => print_data(&details, format, pretty),
|
||||||
|
None => {
|
||||||
if details.track.is_video {
|
if details.track.is_video {
|
||||||
anstream::println!("{}", "[MV]".on_green().black());
|
anstream::println!("{}", "[MV]".on_green().black());
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -711,16 +709,19 @@ async fn run() -> anyhow::Result<()> {
|
||||||
if let Some(view_count) = details.track.view_count {
|
if let Some(view_count) = details.track.view_count {
|
||||||
anstream::println!("{} {}", "Views:".blue(), view_count);
|
anstream::println!("{} {}", "Views:".blue(), view_count);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
print_data(&details, format, pretty);
|
|
||||||
}
|
}
|
||||||
} else if player {
|
} else if player {
|
||||||
let player = if let Some(client_type) = client_type {
|
let player = if let Some(client_types) = client_type {
|
||||||
rp.query().player_from_client(&id, client_type.into()).await
|
let cts = client_types
|
||||||
|
.into_iter()
|
||||||
|
.map(ClientType::from)
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
rp.query().player_from_clients(&id, &cts).await
|
||||||
} else {
|
} else {
|
||||||
rp.query().player(&id).await
|
rp.query().player(&id).await
|
||||||
}?;
|
}?;
|
||||||
print_data(&player, format, pretty);
|
print_data(&player, format.unwrap_or_default(), pretty);
|
||||||
} else {
|
} else {
|
||||||
let mut details = rp.query().video_details(&id).await?;
|
let mut details = rp.query().video_details(&id).await?;
|
||||||
|
|
||||||
|
|
@ -737,7 +738,9 @@ async fn run() -> anyhow::Result<()> {
|
||||||
None => {}
|
None => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
if txt {
|
match format {
|
||||||
|
Some(format) => print_data(&details, format, pretty),
|
||||||
|
None => {
|
||||||
anstream::println!(
|
anstream::println!(
|
||||||
"{}\n{} [{}]",
|
"{}\n{} [{}]",
|
||||||
"[Video]".on_green().black(),
|
"[Video]".on_green().black(),
|
||||||
|
|
@ -782,7 +785,11 @@ async fn run() -> anyhow::Result<()> {
|
||||||
print_h2("Comments");
|
print_h2("Comments");
|
||||||
for c in comment_list {
|
for c in comment_list {
|
||||||
if let Some(author) = &c.author {
|
if let Some(author) = &c.author {
|
||||||
anstream::print!("{} [{}]", author.name.cyan(), author.id);
|
anstream::print!(
|
||||||
|
"{} [{}]",
|
||||||
|
author.name.cyan(),
|
||||||
|
author.id
|
||||||
|
);
|
||||||
print_verification(author.verification);
|
print_verification(author.verification);
|
||||||
} else {
|
} else {
|
||||||
anstream::print!("{}", "Unknown author".magenta());
|
anstream::print!("{}", "Unknown author".magenta());
|
||||||
|
|
@ -803,15 +810,16 @@ async fn run() -> anyhow::Result<()> {
|
||||||
println!("\n");
|
println!("\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
print_data(&details, format, pretty);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
UrlTarget::Channel { id } => {
|
UrlTarget::Channel { id } => {
|
||||||
if music {
|
if music {
|
||||||
let artist = rp.query().music_artist(&id, true).await?;
|
let artist = rp.query().music_artist(&id, true).await?;
|
||||||
if txt {
|
match format {
|
||||||
|
Some(format) => print_data(&artist, format, pretty),
|
||||||
|
None => {
|
||||||
anstream::println!(
|
anstream::println!(
|
||||||
"{}\n{} [{}]",
|
"{}\n{} [{}]",
|
||||||
"[Artist]".on_green().black(),
|
"[Artist]".on_green().black(),
|
||||||
|
|
@ -857,13 +865,14 @@ async fn run() -> anyhow::Result<()> {
|
||||||
print_h2("Similar artists");
|
print_h2("Similar artists");
|
||||||
print_entities(&artist.similar_artists);
|
print_entities(&artist.similar_artists);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
print_data(&artist, format, pretty);
|
|
||||||
}
|
}
|
||||||
} else if rss {
|
} else if rss {
|
||||||
let rss = rp.query().channel_rss(&id).await?;
|
let rss = rp.query().channel_rss(&id).await?;
|
||||||
|
|
||||||
if txt {
|
match format {
|
||||||
|
Some(format) => print_data(&rss, format, pretty),
|
||||||
|
None => {
|
||||||
anstream::println!(
|
anstream::println!(
|
||||||
"{}\n{} [{}]\n{} {}",
|
"{}\n{} [{}]\n{} {}",
|
||||||
"[Channel RSS]".on_green().black(),
|
"[Channel RSS]".on_green().black(),
|
||||||
|
|
@ -882,8 +891,7 @@ async fn run() -> anyhow::Result<()> {
|
||||||
}
|
}
|
||||||
println!();
|
println!();
|
||||||
print_entities(&rss.videos);
|
print_entities(&rss.videos);
|
||||||
} else {
|
}
|
||||||
print_data(&rss, format, pretty);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
match tab {
|
match tab {
|
||||||
|
|
@ -899,7 +907,9 @@ async fn run() -> anyhow::Result<()> {
|
||||||
|
|
||||||
channel.content.extend_limit(rp.query(), limit).await?;
|
channel.content.extend_limit(rp.query(), limit).await?;
|
||||||
|
|
||||||
if txt {
|
match format {
|
||||||
|
Some(format) => print_data(&channel, format, pretty),
|
||||||
|
None => {
|
||||||
anstream::print!(
|
anstream::print!(
|
||||||
"{}\n{} [{}]",
|
"{}\n{} [{}]",
|
||||||
format!("[Channel {tab:?}]").on_green().black(),
|
format!("[Channel {tab:?}]").on_green().black(),
|
||||||
|
|
@ -909,19 +919,24 @@ async fn run() -> anyhow::Result<()> {
|
||||||
print_verification(channel.verification);
|
print_verification(channel.verification);
|
||||||
println!();
|
println!();
|
||||||
if let Some(subs) = channel.subscriber_count {
|
if let Some(subs) = channel.subscriber_count {
|
||||||
anstream::println!("{} {}", "Subscribers:".blue(), subs);
|
anstream::println!(
|
||||||
|
"{} {}",
|
||||||
|
"Subscribers:".blue(),
|
||||||
|
subs
|
||||||
|
);
|
||||||
}
|
}
|
||||||
print_description(Some(channel.description));
|
print_description(Some(channel.description));
|
||||||
println!();
|
println!();
|
||||||
print_entities(&channel.content.items);
|
print_entities(&channel.content.items);
|
||||||
} else {
|
}
|
||||||
print_data(&channel, format, pretty);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ChannelTab::Playlists => {
|
ChannelTab::Playlists => {
|
||||||
let channel = rp.query().channel_playlists(&id).await?;
|
let channel = rp.query().channel_playlists(&id).await?;
|
||||||
|
|
||||||
if txt {
|
match format {
|
||||||
|
Some(format) => print_data(&channel, format, pretty),
|
||||||
|
None => {
|
||||||
anstream::println!(
|
anstream::println!(
|
||||||
"{}\n{} [{}]",
|
"{}\n{} [{}]",
|
||||||
format!("[Channel {tab:?}]").on_green().black(),
|
format!("[Channel {tab:?}]").on_green().black(),
|
||||||
|
|
@ -930,18 +945,23 @@ async fn run() -> anyhow::Result<()> {
|
||||||
);
|
);
|
||||||
print_description(Some(channel.description));
|
print_description(Some(channel.description));
|
||||||
if let Some(subs) = channel.subscriber_count {
|
if let Some(subs) = channel.subscriber_count {
|
||||||
anstream::println!("{} {}", "Subscribers:".blue(), subs);
|
anstream::println!(
|
||||||
|
"{} {}",
|
||||||
|
"Subscribers:".blue(),
|
||||||
|
subs
|
||||||
|
);
|
||||||
}
|
}
|
||||||
println!();
|
println!();
|
||||||
print_entities(&channel.content.items);
|
print_entities(&channel.content.items);
|
||||||
} else {
|
}
|
||||||
print_data(&channel, format, pretty);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ChannelTab::Info => {
|
ChannelTab::Info => {
|
||||||
let info = rp.query().channel_info(&id).await?;
|
let info = rp.query().channel_info(&id).await?;
|
||||||
|
|
||||||
if txt {
|
match format {
|
||||||
|
Some(format) => print_data(&info, format, pretty),
|
||||||
|
None => {
|
||||||
anstream::println!(
|
anstream::println!(
|
||||||
"{}\n<b>ID:</b>{}",
|
"{}\n<b>ID:</b>{}",
|
||||||
"[Channel info]".on_green().black(),
|
"[Channel info]".on_green().black(),
|
||||||
|
|
@ -949,7 +969,11 @@ async fn run() -> anyhow::Result<()> {
|
||||||
);
|
);
|
||||||
print_description(Some(info.description));
|
print_description(Some(info.description));
|
||||||
if let Some(subs) = info.subscriber_count {
|
if let Some(subs) = info.subscriber_count {
|
||||||
anstream::println!("{} {}", "Subscribers:".blue(), subs);
|
anstream::println!(
|
||||||
|
"{} {}",
|
||||||
|
"Subscribers:".blue(),
|
||||||
|
subs
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if let Some(vids) = info.video_count {
|
if let Some(vids) = info.video_count {
|
||||||
anstream::println!("{} {}", "Videos:".blue(), vids);
|
anstream::println!("{} {}", "Videos:".blue(), vids);
|
||||||
|
|
@ -958,7 +982,11 @@ async fn run() -> anyhow::Result<()> {
|
||||||
anstream::println!("{} {}", "Views:".blue(), views);
|
anstream::println!("{} {}", "Views:".blue(), views);
|
||||||
}
|
}
|
||||||
if let Some(created) = info.create_date {
|
if let Some(created) = info.create_date {
|
||||||
anstream::println!("{} {}", "Created on:".blue(), created);
|
anstream::println!(
|
||||||
|
"{} {}",
|
||||||
|
"Created on:".blue(),
|
||||||
|
created
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if !info.links.is_empty() {
|
if !info.links.is_empty() {
|
||||||
print_h2("Links");
|
print_h2("Links");
|
||||||
|
|
@ -966,8 +994,7 @@ async fn run() -> anyhow::Result<()> {
|
||||||
anstream::println!("{} {}", name.blue(), url);
|
anstream::println!("{} {}", name.blue(), url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
print_data(&info, format, pretty);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -977,7 +1004,9 @@ async fn run() -> anyhow::Result<()> {
|
||||||
if music {
|
if music {
|
||||||
let mut playlist = rp.query().music_playlist(&id).await?;
|
let mut playlist = rp.query().music_playlist(&id).await?;
|
||||||
playlist.tracks.extend_limit(rp.query(), limit).await?;
|
playlist.tracks.extend_limit(rp.query(), limit).await?;
|
||||||
if txt {
|
match format {
|
||||||
|
Some(format) => print_data(&playlist, format, pretty),
|
||||||
|
None => {
|
||||||
anstream::println!(
|
anstream::println!(
|
||||||
"{}\n{} [{}]\n{} {}",
|
"{}\n{} [{}]\n{} {}",
|
||||||
"[MusicPlaylist]".on_green().black(),
|
"[MusicPlaylist]".on_green().black(),
|
||||||
|
|
@ -996,13 +1025,14 @@ async fn run() -> anyhow::Result<()> {
|
||||||
print_description(playlist.description.map(|d| d.to_plaintext()));
|
print_description(playlist.description.map(|d| d.to_plaintext()));
|
||||||
println!();
|
println!();
|
||||||
print_tracks(&playlist.tracks.items);
|
print_tracks(&playlist.tracks.items);
|
||||||
} else {
|
}
|
||||||
print_data(&playlist, format, pretty);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let mut playlist = rp.query().playlist(&id).await?;
|
let mut playlist = rp.query().playlist(&id).await?;
|
||||||
playlist.videos.extend_limit(rp.query(), limit).await?;
|
playlist.videos.extend_limit(rp.query(), limit).await?;
|
||||||
if txt {
|
match format {
|
||||||
|
Some(format) => print_data(&playlist, format, pretty),
|
||||||
|
None => {
|
||||||
anstream::println!(
|
anstream::println!(
|
||||||
"{}\n{} [{}]\n{} {}",
|
"{}\n{} [{}]\n{} {}",
|
||||||
"[Playlist]".on_green().black(),
|
"[Playlist]".on_green().black(),
|
||||||
|
|
@ -1024,14 +1054,15 @@ async fn run() -> anyhow::Result<()> {
|
||||||
print_description(playlist.description.map(|d| d.to_plaintext()));
|
print_description(playlist.description.map(|d| d.to_plaintext()));
|
||||||
println!();
|
println!();
|
||||||
print_entities(&playlist.videos.items);
|
print_entities(&playlist.videos.items);
|
||||||
} else {
|
}
|
||||||
print_data(&playlist, format, pretty);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
UrlTarget::Album { id } => {
|
UrlTarget::Album { id } => {
|
||||||
let album = rp.query().music_album(&id).await?;
|
let album = rp.query().music_album(&id).await?;
|
||||||
if txt {
|
match format {
|
||||||
|
Some(format) => print_data(&album, format, pretty),
|
||||||
|
None => {
|
||||||
anstream::print!(
|
anstream::print!(
|
||||||
"{}\n{} [{}] ({:?}",
|
"{}\n{} [{}] ({:?}",
|
||||||
"[Album]".on_green().black(),
|
"[Album]".on_green().black(),
|
||||||
|
|
@ -1052,8 +1083,7 @@ async fn run() -> anyhow::Result<()> {
|
||||||
print_description(album.description.map(|d| d.to_plaintext()));
|
print_description(album.description.map(|d| d.to_plaintext()));
|
||||||
println!();
|
println!();
|
||||||
print_tracks(&album.tracks);
|
print_tracks(&album.tracks);
|
||||||
} else {
|
}
|
||||||
print_data(&album, format, pretty);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1062,7 +1092,6 @@ async fn run() -> anyhow::Result<()> {
|
||||||
query,
|
query,
|
||||||
format,
|
format,
|
||||||
pretty,
|
pretty,
|
||||||
txt,
|
|
||||||
limit,
|
limit,
|
||||||
item_type,
|
item_type,
|
||||||
length,
|
length,
|
||||||
|
|
@ -1072,10 +1101,29 @@ async fn run() -> anyhow::Result<()> {
|
||||||
music,
|
music,
|
||||||
} => match music {
|
} => match music {
|
||||||
None => match channel {
|
None => match channel {
|
||||||
Some(channel) => {
|
Some(channel_id) => {
|
||||||
rustypipe::validate::channel_id(&channel)?;
|
rustypipe::validate::channel_id(&channel_id)?;
|
||||||
let res = rp.query().channel_search(&channel, &query).await?;
|
let channel = rp.query().channel_search(&channel_id, &query).await?;
|
||||||
print_data(&res, format, pretty);
|
|
||||||
|
match format {
|
||||||
|
Some(format) => print_data(&channel, format, pretty),
|
||||||
|
None => {
|
||||||
|
anstream::print!(
|
||||||
|
"{}\n{} [{}]",
|
||||||
|
"[Channel search]".on_green().black(),
|
||||||
|
channel.name.green().bold(),
|
||||||
|
channel.id
|
||||||
|
);
|
||||||
|
print_verification(channel.verification);
|
||||||
|
println!();
|
||||||
|
if let Some(subs) = channel.subscriber_count {
|
||||||
|
anstream::println!("{} {}", "Subscribers:".blue(), subs);
|
||||||
|
}
|
||||||
|
print_description(Some(channel.description));
|
||||||
|
println!();
|
||||||
|
print_entities(&channel.content.items);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
let filter = search_filter::SearchFilter::new()
|
let filter = search_filter::SearchFilter::new()
|
||||||
|
|
@ -1089,39 +1137,40 @@ async fn run() -> anyhow::Result<()> {
|
||||||
.await?;
|
.await?;
|
||||||
res.items.extend_limit(rp.query(), limit).await?;
|
res.items.extend_limit(rp.query(), limit).await?;
|
||||||
|
|
||||||
if txt {
|
match format {
|
||||||
|
Some(format) => print_data(&res, format, pretty),
|
||||||
|
None => {
|
||||||
if let Some(corr) = res.corrected_query {
|
if let Some(corr) = res.corrected_query {
|
||||||
anstream::println!("Did you mean `{}`?", corr.magenta());
|
anstream::println!("Did you mean `{}`?", corr.magenta());
|
||||||
}
|
}
|
||||||
print_entities(&res.items.items);
|
print_entities(&res.items.items);
|
||||||
} else {
|
}
|
||||||
print_data(&res, format, pretty);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Some(MusicSearchCategory::All) => {
|
Some(MusicSearchCategory::All) => {
|
||||||
let res = rp.query().music_search_main(&query).await?;
|
let res = rp.query().music_search_main(&query).await?;
|
||||||
print_music_search(&res, format, pretty, txt);
|
print_music_search(&res, format, pretty);
|
||||||
}
|
}
|
||||||
Some(MusicSearchCategory::Tracks) => {
|
Some(MusicSearchCategory::Tracks) => {
|
||||||
let mut res = rp.query().music_search_tracks(&query).await?;
|
let mut res = rp.query().music_search_tracks(&query).await?;
|
||||||
res.items.extend_limit(rp.query(), limit).await?;
|
res.items.extend_limit(rp.query(), limit).await?;
|
||||||
print_music_search(&res, format, pretty, txt);
|
print_music_search(&res, format, pretty);
|
||||||
}
|
}
|
||||||
Some(MusicSearchCategory::Videos) => {
|
Some(MusicSearchCategory::Videos) => {
|
||||||
let mut res = rp.query().music_search_videos(&query).await?;
|
let mut res = rp.query().music_search_videos(&query).await?;
|
||||||
res.items.extend_limit(rp.query(), limit).await?;
|
res.items.extend_limit(rp.query(), limit).await?;
|
||||||
print_music_search(&res, format, pretty, txt);
|
print_music_search(&res, format, pretty);
|
||||||
}
|
}
|
||||||
Some(MusicSearchCategory::Artists) => {
|
Some(MusicSearchCategory::Artists) => {
|
||||||
let mut res = rp.query().music_search_artists(&query).await?;
|
let mut res = rp.query().music_search_artists(&query).await?;
|
||||||
res.items.extend_limit(rp.query(), limit).await?;
|
res.items.extend_limit(rp.query(), limit).await?;
|
||||||
print_music_search(&res, format, pretty, txt);
|
print_music_search(&res, format, pretty);
|
||||||
}
|
}
|
||||||
Some(MusicSearchCategory::Albums) => {
|
Some(MusicSearchCategory::Albums) => {
|
||||||
let mut res = rp.query().music_search_albums(&query).await?;
|
let mut res = rp.query().music_search_albums(&query).await?;
|
||||||
res.items.extend_limit(rp.query(), limit).await?;
|
res.items.extend_limit(rp.query(), limit).await?;
|
||||||
print_music_search(&res, format, pretty, txt);
|
print_music_search(&res, format, pretty);
|
||||||
}
|
}
|
||||||
Some(MusicSearchCategory::PlaylistsYtm | MusicSearchCategory::PlaylistsCommunity) => {
|
Some(MusicSearchCategory::PlaylistsYtm | MusicSearchCategory::PlaylistsCommunity) => {
|
||||||
let mut res = rp
|
let mut res = rp
|
||||||
|
|
@ -1132,7 +1181,7 @@ async fn run() -> anyhow::Result<()> {
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
res.items.extend_limit(rp.query(), limit).await?;
|
res.items.extend_limit(rp.query(), limit).await?;
|
||||||
print_music_search(&res, format, pretty, txt);
|
print_music_search(&res, format, pretty);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Commands::Vdata => {
|
Commands::Vdata => {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,8 @@
|
||||||
# RustyPipe downloader
|
#  Downloader
|
||||||
|
|
||||||
|
[](https://crates.io/crates/rustypipe-downloader)
|
||||||
|
[](http://opensource.org/licenses/MIT)
|
||||||
|
[](https://code.thetadev.de/ThetaDev/rustypipe/actions/?workflow=ci.yaml)
|
||||||
|
|
||||||
The downloader is a companion crate for RustyPipe that allows for easy and fast
|
The downloader is a companion crate for RustyPipe that allows for easy and fast
|
||||||
downloading of video and audio files.
|
downloading of video and audio files.
|
||||||
|
|
@ -35,8 +39,8 @@ let dl = DownloaderBuilder::new()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let filter_audio = StreamFilter::new().no_video();
|
let filter_audio = StreamFilter::new().no_video();
|
||||||
dl.id("ZeerrnuLi5E").stream_filter(filter_audio).to_file("audio.opus").download().await;
|
dl.id("eRsGyueVLvQ").stream_filter(filter_audio).to_file("audio.opus").download().await;
|
||||||
|
|
||||||
let filter_video = StreamFilter::new().video_max_res(720);
|
let filter_video = StreamFilter::new().video_max_res(720);
|
||||||
dl.id("ZeerrnuLi5E").stream_filter(filter_video).to_file("video.mp4").download().await;
|
dl.id("eRsGyueVLvQ").stream_filter(filter_video).to_file("video.mp4").download().await;
|
||||||
```
|
```
|
||||||
|
|
|
||||||
Reference in a new issue