diff options
Diffstat (limited to 'crates/yt/src/config/default.rs')
-rw-r--r-- | crates/yt/src/config/default.rs | 110 |
1 files changed, 0 insertions, 110 deletions
diff --git a/crates/yt/src/config/default.rs b/crates/yt/src/config/default.rs deleted file mode 100644 index 4ed643b..0000000 --- a/crates/yt/src/config/default.rs +++ /dev/null @@ -1,110 +0,0 @@ -// yt - A fully featured command line YouTube client -// -// Copyright (C) 2024 Benedikt Peetz <benedikt.peetz@b-peetz.de> -// Copyright (C) 2025 Benedikt Peetz <benedikt.peetz@b-peetz.de> -// 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 <https://www.gnu.org/licenses/gpl-3.0.txt>. - -use std::path::PathBuf; - -use anyhow::{Context, Result}; - -fn get_runtime_path(name: &'static str) -> Result<PathBuf> { - 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) -> Result<PathBuf> { - 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) -> Result<PathBuf> { - let xdg_dirs = xdg::BaseDirectories::with_prefix(PREFIX); - xdg_dirs - .place_config_file(name) - .with_context(|| format!("Failed to place config file: '{name}'")) -} - -pub(super) fn create_path(path: PathBuf) -> Result<PathBuf> { - if !path.exists() { - if let Some(parent) = path.parent() { - std::fs::create_dir_all(parent) - .with_context(|| format!("Failed to create the '{}' directory", path.display()))?; - } - } - - Ok(path) -} - -pub(crate) const PREFIX: &str = "yt"; - -pub(crate) mod global { - pub(crate) fn display_colors() -> bool { - // TODO: This should probably check if the output is a tty and otherwise return `false` <2025-02-14> - true - } -} - -pub(crate) mod select { - pub(crate) fn playback_speed() -> f64 { - 2.7 - } - pub(crate) fn subtitle_langs() -> &'static str { - "" - } -} - -pub(crate) mod watch { - pub(crate) fn local_displays_length() -> usize { - 1000 - } -} - -pub(crate) mod update { - pub(crate) fn max_backlog() -> usize { - 20 - } -} - -pub(crate) mod paths { - use std::{env::temp_dir, path::PathBuf}; - - use anyhow::Result; - - use super::{PREFIX, create_path, get_config_path, get_data_path, get_runtime_path}; - - // We download to the temp dir to avoid taxing the disk - pub(crate) fn download_dir() -> Result<PathBuf> { - let temp_dir = temp_dir(); - - create_path(temp_dir.join(PREFIX)) - } - pub(crate) fn mpv_config_path() -> Result<PathBuf> { - get_config_path("mpv.conf") - } - pub(crate) fn mpv_input_path() -> Result<PathBuf> { - get_config_path("mpv.input.conf") - } - pub(crate) fn database_path() -> Result<PathBuf> { - get_data_path("videos.sqlite") - } - pub(crate) fn config_path() -> Result<PathBuf> { - get_config_path("config.toml") - } - pub(crate) fn last_selection_path() -> Result<PathBuf> { - get_runtime_path("selected.yts") - } -} - -pub(crate) mod download { - pub(crate) fn max_cache_size() -> &'static str { - "3 GiB" - } -} |