about summary refs log tree commit diff stats
path: root/sys/nixpkgs/pkgs/yt/src/constants.rs
blob: 96995f08bdba3ef1f3bba243345b4650cf98aede (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
use std::{env, fs, path::PathBuf};

pub const HELP_STR: &'static str = include_str!("./help.str");

pub const YT_DLP_FLAGS: [&str; 13] = [
    // Ignore errors arising of unavailable sponsor block API
    "--ignore-errors",
    "--format",
    "bestvideo[height<=?1080]+bestaudio/best",
    "--embed-chapters",
    "--progress",
    "--write-comments",
    "--extractor-args",
    "youtube:max_comments=150,all,100;comment_sort=top",
    "--write-info-json",
    "--sponsorblock-mark",
    "default",
    "--sponsorblock-remove",
    "sponsor",
];
pub const MPV_FLAGS: [&str; 2] = ["--speed=2.7", "--volume=75"];

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> {
    let out: PathBuf = format!(
        "{}/{}",
        env::var("XDG_RUNTIME_DIR").expect("This should always exist"),
        STATUS_PATH
    )
    .into();
    fs::create_dir_all(&out.parent().expect("Parent should exist"))?;
    Ok(out)
}

const LAST_SELECT: &str = "ytcc/selected";
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)
}