feat: add option to fetch RSS feed
This commit is contained in:
parent
f25fb2fb9b
commit
02bf7ee7fe
2 changed files with 42 additions and 8 deletions
|
|
@ -41,7 +41,7 @@ rustls-tls-native-roots = [
|
||||||
]
|
]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
rustypipe.workspace = true
|
rustypipe = { workspace = true, features = ["rss"] }
|
||||||
rustypipe-downloader.workspace = true
|
rustypipe-downloader.workspace = true
|
||||||
reqwest.workspace = true
|
reqwest.workspace = true
|
||||||
tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }
|
tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }
|
||||||
|
|
|
||||||
|
|
@ -134,6 +134,9 @@ enum Commands {
|
||||||
/// Use YouTube Music
|
/// Use YouTube Music
|
||||||
#[clap(short, long)]
|
#[clap(short, long)]
|
||||||
music: bool,
|
music: bool,
|
||||||
|
/// Use the RSS feed of a channel
|
||||||
|
#[clap(long)]
|
||||||
|
rss: bool,
|
||||||
/// Get comments
|
/// Get comments
|
||||||
#[clap(long)]
|
#[clap(long)]
|
||||||
comments: Option<CommentsOrder>,
|
comments: Option<CommentsOrder>,
|
||||||
|
|
@ -654,6 +657,7 @@ async fn run() -> anyhow::Result<()> {
|
||||||
limit,
|
limit,
|
||||||
tab,
|
tab,
|
||||||
music,
|
music,
|
||||||
|
rss,
|
||||||
comments,
|
comments,
|
||||||
lyrics,
|
lyrics,
|
||||||
player,
|
player,
|
||||||
|
|
@ -669,7 +673,7 @@ async fn run() -> anyhow::Result<()> {
|
||||||
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 {
|
if txt {
|
||||||
println!("{}\n\n{}", lyrics.body, lyrics.footer);
|
println!("{}\n\n{}", lyrics.body, lyrics.footer.blue());
|
||||||
} else {
|
} else {
|
||||||
print_data(&lyrics, format, pretty);
|
print_data(&lyrics, format, pretty);
|
||||||
}
|
}
|
||||||
|
|
@ -680,18 +684,23 @@ async fn run() -> anyhow::Result<()> {
|
||||||
let details = rp.query().music_details(&id).await?;
|
let details = rp.query().music_details(&id).await?;
|
||||||
if txt {
|
if txt {
|
||||||
if details.track.is_video {
|
if details.track.is_video {
|
||||||
println!("[MV]");
|
anstream::println!("{}", "[MV]".on_green().black());
|
||||||
} else {
|
} else {
|
||||||
println!("[Track]");
|
anstream::println!("{}", "[Track]".on_green().black());
|
||||||
}
|
}
|
||||||
print!("{} [{}]", details.track.name, details.track.id);
|
anstream::print!(
|
||||||
|
"{} [{}]",
|
||||||
|
details.track.name.green().bold(),
|
||||||
|
details.track.id
|
||||||
|
);
|
||||||
print_duration(details.track.duration);
|
print_duration(details.track.duration);
|
||||||
println!();
|
println!();
|
||||||
print_artists(&details.track.artists);
|
print_artists(&details.track.artists);
|
||||||
println!();
|
println!();
|
||||||
if !details.track.is_video {
|
if !details.track.is_video {
|
||||||
println!(
|
anstream::println!(
|
||||||
"Album: {}",
|
"{} {}",
|
||||||
|
"Album:".blue(),
|
||||||
details
|
details
|
||||||
.track
|
.track
|
||||||
.album
|
.album
|
||||||
|
|
@ -701,7 +710,7 @@ async fn run() -> anyhow::Result<()> {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if let Some(view_count) = details.track.view_count {
|
if let Some(view_count) = details.track.view_count {
|
||||||
println!("Views: {view_count}");
|
anstream::println!("{} {}", "Views:".blue(), view_count);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
print_data(&details, format, pretty);
|
print_data(&details, format, pretty);
|
||||||
|
|
@ -852,6 +861,31 @@ async fn run() -> anyhow::Result<()> {
|
||||||
} else {
|
} else {
|
||||||
print_data(&artist, format, pretty);
|
print_data(&artist, format, pretty);
|
||||||
}
|
}
|
||||||
|
} else if rss {
|
||||||
|
let rss = rp.query().channel_rss(&id).await?;
|
||||||
|
|
||||||
|
if txt {
|
||||||
|
anstream::println!(
|
||||||
|
"{}\n{} [{}]\n{} {}",
|
||||||
|
"[Channel RSS]".on_green().black(),
|
||||||
|
rss.name.green().bold(),
|
||||||
|
rss.id,
|
||||||
|
"Created on:".blue(),
|
||||||
|
rss.create_date,
|
||||||
|
);
|
||||||
|
if let Some(v) = rss.videos.first() {
|
||||||
|
anstream::println!(
|
||||||
|
"{} {} [{}]",
|
||||||
|
"Latest video:".blue(),
|
||||||
|
v.publish_date,
|
||||||
|
v.id
|
||||||
|
);
|
||||||
|
}
|
||||||
|
println!();
|
||||||
|
print_entities(&rss.videos);
|
||||||
|
} else {
|
||||||
|
print_data(&rss, format, pretty);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
match tab {
|
match tab {
|
||||||
ChannelTab::Videos | ChannelTab::Shorts | ChannelTab::Live => {
|
ChannelTab::Videos | ChannelTab::Shorts | ChannelTab::Live => {
|
||||||
|
|
|
||||||
Reference in a new issue