// yt - A fully featured command line YouTube client // // Copyright (C) 2024 Benedikt Peetz // SPDX-License-Identifier: GPL-3.0-or-later // // This file is part of Yt. // // You should have received a copy of the License along with this program. // If not, see . use std::{env::temp_dir, path::PathBuf}; use anyhow::Context; pub const HELP_STR: &str = include_str!("./select/selection_file/help.str"); pub const LOCAL_COMMENTS_LENGTH: usize = 1000; // NOTE: KEEP THIS IN SYNC WITH THE `mpv_playback_speed` in `cli.rs` <2024-08-20> pub const DEFAULT_MPV_PLAYBACK_SPEED: f64 = 2.7; pub const DEFAULT_SUBTITLE_LANGS: &str = "en"; pub const CONCURRENT_DOWNLOADS: u32 = 5; // We download to the temp dir to avoid taxing the disk pub fn download_dir() -> PathBuf { const DOWNLOAD_DIR: &str = "/tmp/yt"; PathBuf::from(DOWNLOAD_DIR) } const PREFIX: &str = "yt"; fn get_runtime_path(name: &'static str) -> anyhow::Result { let xdg_dirs = xdg::BaseDirectories::with_prefix(PREFIX)?; xdg_dirs .place_runtime_file(name) .with_context(|| format!("Failed to place runtime file: '{}'", name)) } fn get_data_path(name: &'static str) -> anyhow::Result { let xdg_dirs = xdg::BaseDirectories::with_prefix(PREFIX)?; xdg_dirs .place_data_file(name) .with_context(|| format!("Failed to place data file: '{}'", name)) } fn get_config_path(name: &'static str) -> anyhow::Result { let xdg_dirs = xdg::BaseDirectories::with_prefix(PREFIX)?; xdg_dirs .place_config_file(name) .with_context(|| format!("Failed to place config file: '{}'", name)) } pub fn mpv_config_path() -> anyhow::Result { const MPV_CONFIG_PATH: &str = "mpv.conf"; get_config_path(MPV_CONFIG_PATH) } pub fn mpv_input_path() -> anyhow::Result { const MPV_INPUT_CONFIG_PATH: &str = "mpv.input.conf"; get_config_path(MPV_INPUT_CONFIG_PATH) } pub fn status_path() -> anyhow::Result { const STATUS_PATH: &str = "running.info.json"; get_runtime_path(STATUS_PATH) } pub fn last_select() -> anyhow::Result { const LAST_SELECT: &str = "selected.yts"; get_runtime_path(LAST_SELECT) } pub fn database() -> anyhow::Result { const DATABASE: &str = "videos.sqlite"; get_data_path(DATABASE) } pub fn subscriptions() -> anyhow::Result { const SUBSCRIPTIONS: &str = "subscriptions.json"; get_data_path(SUBSCRIPTIONS) } pub fn cache_path() -> PathBuf { let temp_dir = temp_dir(); temp_dir.join("ytc") }