diff options
author | Soispha <soispha@vhack.eu> | 2024-01-20 18:38:18 +0100 |
---|---|---|
committer | Soispha <soispha@vhack.eu> | 2024-01-20 18:38:18 +0100 |
commit | b53a8d82a07c29010a690b7126795fd7ddcabe0c (patch) | |
tree | 203dd0581950f9acb75881383d4b6fbc849e91af /sys/nixpkgs/pkgs/yt/src/constants.rs | |
parent | fix(sys/nixpkgs/yt/constants): Add extension to last selection path (diff) | |
download | nixos-config-b53a8d82a07c29010a690b7126795fd7ddcabe0c.zip |
feat(sys/nixpkgs/yt): Add support for the 'url' command
This simply opens the youtube url in the browser
Diffstat (limited to 'sys/nixpkgs/pkgs/yt/src/constants.rs')
-rw-r--r-- | sys/nixpkgs/pkgs/yt/src/constants.rs | 23 |
1 files changed, 10 insertions, 13 deletions
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<PathBuf> { +fn get_runtime_path(component: &'static str) -> anyhow::Result<PathBuf> { 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<PathBuf> { + get_runtime_path(STATUS_PATH) +} + const LAST_SELECT: &str = "ytcc/selected.yts"; pub fn last_select() -> anyhow::Result<PathBuf> { - 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) } |