From b53a8d82a07c29010a690b7126795fd7ddcabe0c Mon Sep 17 00:00:00 2001 From: Soispha Date: Sat, 20 Jan 2024 18:38:18 +0100 Subject: feat(sys/nixpkgs/yt): Add support for the 'url' command This simply opens the youtube url in the browser --- sys/nixpkgs/pkgs/yt/src/constants.rs | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'sys/nixpkgs/pkgs/yt/src/constants.rs') diff --git a/sys/nixpkgs/pkgs/yt/src/constants.rs b/sys/nixpkgs/pkgs/yt/src/constants.rs index 5250820c..6385df54 100644 --- a/sys/nixpkgs/pkgs/yt/src/constants.rs +++ b/sys/nixpkgs/pkgs/yt/src/constants.rs @@ -1,6 +1,6 @@ use std::{env, fs, path::PathBuf}; -pub const HELP_STR: &'static str = include_str!("./help.str"); +pub const HELP_STR: &str = include_str!("./help.str"); pub const YT_DLP_FLAGS: [&str; 13] = [ // Ignore errors arising of unavailable sponsor block API @@ -24,26 +24,23 @@ pub const CONCURRENT: u32 = 5; pub const DOWNLOAD_DIR: &str = "/tmp/ytcc"; -const STATUS_PATH: &str = "ytcc/running"; -pub fn status_path() -> anyhow::Result { +fn get_runtime_path(component: &'static str) -> anyhow::Result { let out: PathBuf = format!( "{}/{}", env::var("XDG_RUNTIME_DIR").expect("This should always exist"), - STATUS_PATH + component ) .into(); - fs::create_dir_all(&out.parent().expect("Parent should exist"))?; + fs::create_dir_all(out.parent().expect("Parent should exist"))?; Ok(out) } +const STATUS_PATH: &str = "ytcc/running"; +pub fn status_path() -> anyhow::Result { + get_runtime_path(STATUS_PATH) +} + const LAST_SELECT: &str = "ytcc/selected.yts"; pub fn last_select() -> anyhow::Result { - let out: PathBuf = format!( - "{}/{}", - env::var("XDG_RUNTIME_DIR").expect("This should always exist"), - LAST_SELECT - ) - .into(); - fs::create_dir_all(&out.parent().expect("Parent should exist"))?; - Ok(out) + get_runtime_path(LAST_SELECT) } -- cgit 1.4.1