youtube_dl_parser/
expressions.rs

1use duct::{cmd, Expression};
2
3/// Creates a mp3 download expression based on the given params
4pub fn mp3_download_expression(
5    youtube_dl_path: &str,
6    url: &str,
7    download_folder: &str,
8) -> Expression {
9    let download_path = format!("{download_folder}\\%(title)s.%(ext)s");
10
11    cmd!(
12        youtube_dl_path,
13        "-x",
14        "--audio-format",
15        "mp3",
16        "-o",
17        download_path,
18        url
19    )
20}
21
22/// Formats a mp4 download expression based on the given params
23pub fn mp4_download_expression(
24    youtube_dl_path: &str,
25    url: &str,
26    download_folder: &str,
27) -> Expression {
28    let download_path = format!("{download_folder}\\%(title)s.%(ext)s");
29
30    cmd!(
31        youtube_dl_path,
32        "--merge-output-format",
33        "mp4",
34        "-o",
35        download_path,
36        url
37    )
38}