feat(cli): add channel search
This commit is contained in:
parent
2e06d9c572
commit
19820db6d0
1 changed files with 23 additions and 10 deletions
|
|
@ -90,6 +90,9 @@ enum Commands {
|
||||||
/// Sort search resulus
|
/// Sort search resulus
|
||||||
#[clap(long)]
|
#[clap(long)]
|
||||||
order: Option<SearchOrder>,
|
order: Option<SearchOrder>,
|
||||||
|
/// Channel ID for searching channel videos
|
||||||
|
#[clap(long)]
|
||||||
|
channel: Option<String>,
|
||||||
/// YouTube Music search filter
|
/// YouTube Music search filter
|
||||||
#[clap(long)]
|
#[clap(long)]
|
||||||
music: Option<MusicSearchCategory>,
|
music: Option<MusicSearchCategory>,
|
||||||
|
|
@ -607,18 +610,28 @@ async fn main() {
|
||||||
length,
|
length,
|
||||||
date,
|
date,
|
||||||
order,
|
order,
|
||||||
|
channel,
|
||||||
music,
|
music,
|
||||||
} => match music {
|
} => match music {
|
||||||
None => {
|
None => match channel {
|
||||||
let filter = search_filter::SearchFilter::new()
|
Some(channel) => {
|
||||||
.item_type_opt(item_type.map(search_filter::ItemType::from))
|
if !rustypipe::validate::channel_id(&channel) {
|
||||||
.length_opt(length.map(search_filter::Length::from))
|
panic!("invalid channel id")
|
||||||
.date_opt(date.map(search_filter::UploadDate::from))
|
}
|
||||||
.sort_opt(order.map(search_filter::Order::from));
|
let res = rp.query().channel_search(&channel, &query).await.unwrap();
|
||||||
let mut res = rp.query().search_filter(&query, &filter).await.unwrap();
|
print_data(&res, format, pretty);
|
||||||
res.items.extend_limit(rp.query(), limit).await.unwrap();
|
}
|
||||||
print_data(&res, format, pretty);
|
None => {
|
||||||
}
|
let filter = search_filter::SearchFilter::new()
|
||||||
|
.item_type_opt(item_type.map(search_filter::ItemType::from))
|
||||||
|
.length_opt(length.map(search_filter::Length::from))
|
||||||
|
.date_opt(date.map(search_filter::UploadDate::from))
|
||||||
|
.sort_opt(order.map(search_filter::Order::from));
|
||||||
|
let mut res = rp.query().search_filter(&query, &filter).await.unwrap();
|
||||||
|
res.items.extend_limit(rp.query(), limit).await.unwrap();
|
||||||
|
print_data(&res, format, pretty);
|
||||||
|
}
|
||||||
|
},
|
||||||
Some(MusicSearchCategory::All) => {
|
Some(MusicSearchCategory::All) => {
|
||||||
let res = rp.query().music_search(&query).await.unwrap();
|
let res = rp.query().music_search(&query).await.unwrap();
|
||||||
print_data(&res, format, pretty);
|
print_data(&res, format, pretty);
|
||||||
|
|
|
||||||
Reference in a new issue