aboutsummaryrefslogtreecommitdiffstats
path: root/src/select
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-08-22 14:23:38 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-08-22 14:23:38 +0200
commit2fd17e51868b5f25e888b6aee1c1f56f3fbec40b (patch)
tree5ce49ca4092438e47fcb677e6594174bd346fbdb /src/select
parentfeat(download): Support limiting the downloader by maximal cache size (diff)
downloadyt-2fd17e51868b5f25e888b6aee1c1f56f3fbec40b.zip
feat(select/file): Allow `--priority` argument to all functions
This allows setting a priority even on picked videos.
Diffstat (limited to 'src/select')
-rw-r--r--src/select/cmds.rs25
-rw-r--r--src/select/selection_file/help.str6
2 files changed, 18 insertions, 13 deletions
diff --git a/src/select/cmds.rs b/src/select/cmds.rs
index 40e5b17..85e655f 100644
--- a/src/select/cmds.rs
+++ b/src/select/cmds.rs
@@ -25,41 +25,46 @@ pub async fn handle_select_cmd(
cmd: SelectCommand,
line_number: Option<i64>,
) -> Result<()> {
+ fn compute_priority(line_number: Option<i64>, priority: Option<i64>) -> Option<i64> {
+ if let Some(pri) = priority {
+ Some(pri)
+ } else if let Some(pri) = line_number {
+ Some(pri)
+ } else {
+ None
+ }
+ }
+
match cmd {
SelectCommand::Pick { shared } => {
+ let priority = compute_priority(line_number, shared.priority);
set_video_status(
app,
&shared.hash.realize(app).await?,
VideoStatus::Pick,
- line_number,
+ priority,
)
.await?
}
SelectCommand::Drop { shared } => {
+ let priority = compute_priority(line_number, shared.priority);
set_video_status(
app,
&shared.hash.realize(app).await?,
VideoStatus::Drop,
- line_number,
+ priority,
)
.await?
}
SelectCommand::Watch {
shared,
- priority,
subtitle_langs,
speed,
} => {
let hash = shared.hash.realize(&app).await?;
let video = get_video_by_hash(app, &hash).await?;
let video_options = VideoOptions::new(subtitle_langs, speed);
- let priority = if let Some(pri) = priority {
- Some(pri)
- } else if let Some(pri) = line_number {
- Some(pri)
- } else {
- None
- };
+ let priority = compute_priority(line_number, shared.priority);
if let Some(_) = video.cache_path {
set_video_status(app, &hash, VideoStatus::Cached, priority).await?;
diff --git a/src/select/selection_file/help.str b/src/select/selection_file/help.str
index 6e296f6..295bc4d 100644
--- a/src/select/selection_file/help.str
+++ b/src/select/selection_file/help.str
@@ -1,8 +1,8 @@
# Commands:
# w, watch [-p,-s,-l] Mark the video given by the hash to be watched
-# d, drop Mark the video given by the hash to be dropped
-# u, url Open the video URL in Firefox's `timesinks.youtube` profile
-# p, pick Reset the videos status to 'Pick'
+# d, drop [-p] Mark the video given by the hash to be dropped
+# u, url [-p] Open the video URL in Firefox's `timesinks.youtube` profile
+# p, pick [-p] Reset the videos status to 'Pick'
#
# See `yt select <cmd_name> --help` for more help.
#