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
use duct::{cmd, Expression};

/// Creates a mp3 download expression based on the given params
pub fn mp3_download_expression(
    youtube_dl_path: &str,
    url: &str,
    download_folder: &str,
) -> Expression {
    let download_path = format!("{download_folder}\\%(title)s.%(ext)s");

    cmd!(
        youtube_dl_path,
        "-x",
        "--audio-format",
        "mp3",
        "-o",
        download_path,
        url
    )
}

/// Formats a mp4 download expression based on the given params
pub fn mp4_download_expression(
    youtube_dl_path: &str,
    url: &str,
    download_folder: &str,
) -> Expression {
    let download_path = format!("{download_folder}\\%(title)s.%(ext)s");

    cmd!(
        youtube_dl_path,
        "--merge-output-format",
        "mp4",
        "-o",
        download_path,
        url
    )
}