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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
// yt - A fully featured command line YouTube client
//
// Copyright (C) 2024 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 serde_json::{json, Value};
use crate::{app::App, storage::video_database::YtDlpOptions};
// {
// "ratelimit": conf.ratelimit if conf.ratelimit > 0 else None,
// "retries": conf.retries,
// "merge_output_format": conf.merge_output_format,
// "restrictfilenames": conf.restrict_filenames,
// "ignoreerrors": False,
// "postprocessors": [{"key": "FFmpegMetadata"}],
// "logger": _ytdl_logger
// }
pub fn download_opts(
app: &App,
additional_opts: YtDlpOptions,
) -> serde_json::Map<String, serde_json::Value> {
match json!({
"extract_flat": false,
"extractor_args": {
"youtube": {
"comment_sort": [
"top"
],
"max_comments": [
"150",
"all",
"100"
]
}
},
"ffmpeg_location": env!("FFMPEG_LOCATION"),
"format": "bestvideo[height<=?1080]+bestaudio/best",
"fragment_retries": 10,
"getcomments": true,
"ignoreerrors": false,
"retries": 10,
"writeinfojson": true,
"writeannotations": true,
"writesubtitles": true,
"writeautomaticsub": true,
"outtmpl": {
"default": app.config.paths.download_dir.join("%(channel)s/%(title)s.%(ext)s"),
"chapter": "%(title)s - %(section_number)03d %(section_title)s [%(id)s].%(ext)s"
},
"compat_opts": {},
"forceprint": {},
"print_to_file": {},
"windowsfilenames": false,
"restrictfilenames": false,
"trim_file_names": false,
"postprocessors": [
{
"api": "https://sponsor.ajay.app",
"categories": [
"interaction",
"intro",
"music_offtopic",
"sponsor",
"outro",
"poi_highlight",
"preview",
"selfpromo",
"filler",
"chapter"
],
"key": "SponsorBlock",
"when": "after_filter"
},
{
"force_keyframes": false,
"key": "ModifyChapters",
"remove_chapters_patterns": [],
"remove_ranges": [],
"remove_sponsor_segments": [
"sponsor"
],
"sponsorblock_chapter_title": "[SponsorBlock]: %(category_names)l"
},
{
"add_chapters": true,
"add_infojson": null,
"add_metadata": false,
"key": "FFmpegMetadata"
},
{
"key": "FFmpegConcat",
"only_multi_video": true,
"when": "playlist"
}
]
}) {
serde_json::Value::Object(mut obj) => {
obj.insert(
"subtitleslangs".to_owned(),
serde_json::Value::Array(
additional_opts
.subtitle_langs
.split(',')
.map(|val| Value::String(val.to_owned()))
.collect::<Vec<_>>(),
),
);
obj
}
_ => unreachable!("This is an object"),
}
}
|