-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.py
63 lines (55 loc) · 1.85 KB
/
main.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
59
60
61
62
63
import argparse
import os
from api import SnaptikDownloader
def parse_arguments():
parser = argparse.ArgumentParser(description='Download TikTok videos using Snaptik')
parser.add_argument(
'-su',
'--single_url',
type=str,
help='Single TikTok url'
)
parser.add_argument(
'-fn',
'--filename',
type=str,
help='Text file containing a list of TikTok urls to download (one URL per line)'
)
parser.add_argument(
'-wk',
'--worker',
type=int,
help='Workers for concurrency (If not set, it will be automatically set based on the length of [url_list])'
)
parser.add_argument(
'-el',
'--enable_log',
action='store_true',
help='For debugging'
)
parser.add_argument(
'-ts',
'--transient',
action='store_true',
help='Close the progress bar after all the downloads/tasks are finished'
)
parser.add_argument(
'-ic',
'--instant_clear',
action='store_true',
help='Close the progress bar immediately after one task is completed'
)
return parser.parse_args()
def main():
os.system('cls' if os.name == 'nt' else 'clear')
args = parse_arguments()
if not args.single_url and not args.filename:
os.system('python main.py -h' if os.name == 'nt' else 'python3 main.py -h')
return
snaptik_instance = SnaptikDownloader(args.transient, args.instant_clear, args.enable_log)
sanitized_urls = snaptik_instance.url_sanitizer(args.filename, args.single_url)
worker = args.worker or len(sanitized_urls)
video_links = snaptik_instance.extract_multi_link(worker, sanitized_urls)
snaptik_instance.video_downloader(worker, video_links)
if __name__ == '__main__':
main()