feat: copy selected video URL

This commit is contained in:
2026-10-22 15:38:59 +02:00
parent 01275e20b8
commit b12bba9125
9 changed files with 80 additions and 14 deletions
+13 -12
View File
@@ -863,6 +863,16 @@ fn failure(errors: &Receiver<io::Result<String>>, fallback: String) -> Option<Re
}
}
pub fn video_url(id: &str) -> io::Result<String> {
if valid_video_id(id) {
Ok(format!("https://www.youtube.com/watch?v={id}"))
} else {
tubular::miruro::Identity::from_key(id)
.and_then(|identity| identity.watch_url())
.map_err(|error| io::Error::new(io::ErrorKind::InvalidInput, error))
}
}
pub fn open_in_browser(id: &str) -> io::Result<Receiver<Result<(), String>>> {
if !valid_video_id(id) {
return Err(io::Error::new(
@@ -876,7 +886,7 @@ pub fn open_in_browser(id: &str) -> io::Result<Receiver<Result<(), String>>> {
"xdg-open"
};
let child = isolated_command(OsStr::new(opener))
.arg(format!("https://www.youtube.com/watch?v={id}"))
.arg(video_url(id)?)
.stdin(Stdio::null())
.stdout(Stdio::null())
.stderr(Stdio::piped())
@@ -926,19 +936,10 @@ impl PlayerLaunch {
"No videos selected",
));
}
let playback_url = |id: &str| {
if valid_video_id(id) {
Ok(format!("https://www.youtube.com/watch?v={id}"))
} else {
tubular::miruro::Identity::from_key(id)
.and_then(|identity| identity.watch_url())
.map_err(|error| io::Error::new(io::ErrorKind::InvalidInput, error))
}
};
let mut command = isolated_command(player);
command.arg("--new-instance");
if let [video] = videos {
let url = playback_url(&video.id)?;
let url = video_url(&video.id)?;
let report = state.progress_file(video)?;
crate::video_state::register_identity(&report, &video.id)?;
command
@@ -957,7 +958,7 @@ impl PlayerLaunch {
"Duplicate queue identity",
));
}
playback_url(&video.id)
video_url(&video.id)
})
.collect::<io::Result<Vec<_>>>()?;
let reports = state.progress_files(videos)?;