-
Notifications
You must be signed in to change notification settings - Fork 1
/
ytdlp_singlethread.py
58 lines (52 loc) · 2.21 KB
/
ytdlp_singlethread.py
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
from commands import *
import ytdlp_multithread
(dl, ch, chy, debug, wait, no_meta, no_subs, directory,
count_of_threads, channel_file_path, quality) = ytdlp_multithread.parse_arguments(OS.args)
if debug:
print(f"{channel_file_path=}")
channel = File.read(channel_file_path).strip()
cache_file_path = directory + Path.separator() + "channel_videos_cache.txt"
cookies_path = directory + Path.separator() + "cookies.txt"
cookies_exist = File.exist(cookies_path)
if (not dl and not ch) or directory is None:
print("usage: py ytdlp_multithread.py [dl] [ch] dir_with_config_and_files")
if not dl and not ch:
print("please, use at least argument 'dl' and/or 'ch'")
if directory is None:
print("please, specify working directory")
OS.exit(1)
if debug:
print(f"Working dir is {directory}")
if ch:
regen = True
try:
if File.get_size(cache_file_path):
if chy:
pass
elif not CLI.get_y_n("Cache file already written. Do you wish to recreate it?"):
regen = False
except OSError:
pass
if regen:
links = ytdlp_multithread.regen_cache(channel=channel,
cookies_path=cookies_path,
debug=debug,
cookies_exist=cookies_exist)
File.wipe(cache_file_path)
File.write(cache_file_path, links)
yt_ids = Str.nl(File.read(cache_file_path).strip())
total = len(yt_ids)
for cnt, line in enumerate(yt_ids):
ytdlp_multithread.download(youtube_video_id=line,
cnt=cnt,
total=total,
cookies_exist=cookies_exist,
cookies_path=cookies_path,
no_meta=no_meta,
no_subs=no_subs,
debug=debug,
directory=directory,
wait=False,
ytdlp_format=ytdlp_multithread.ytdlp_format,
quality=quality,
newline=True)