Add progress bar to download script
Browse files- download.py +7 -0
download.py
CHANGED
@@ -4,6 +4,7 @@ import argparse
|
|
4 |
import twitchdl.commands as twitch_downloader
|
5 |
import twitchdl.twitch
|
6 |
from twitchdl.commands.download import _parse_playlists
|
|
|
7 |
|
8 |
VIDEO_FOLDER = 'videos'
|
9 |
AUDIO_FOLDER = 'audios'
|
@@ -114,12 +115,18 @@ def download_youtube(url, type):
|
|
114 |
|
115 |
def main(args):
|
116 |
url = args.url
|
|
|
|
|
117 |
if 'twitch' in url.lower():
|
118 |
download_twitch(url, DOWNLOAD_VIDEO)
|
|
|
119 |
download_twitch(url, DOWNLOAD_AUDIO)
|
|
|
120 |
elif 'youtube' in url.lower() or 'youtu.be' in url.lower():
|
121 |
download_youtube(url, DOWNLOAD_VIDEO)
|
|
|
122 |
download_youtube(url, DOWNLOAD_AUDIO)
|
|
|
123 |
else:
|
124 |
print('Unknown video source')
|
125 |
|
|
|
4 |
import twitchdl.commands as twitch_downloader
|
5 |
import twitchdl.twitch
|
6 |
from twitchdl.commands.download import _parse_playlists
|
7 |
+
from tqdm import tqdm
|
8 |
|
9 |
VIDEO_FOLDER = 'videos'
|
10 |
AUDIO_FOLDER = 'audios'
|
|
|
115 |
|
116 |
def main(args):
|
117 |
url = args.url
|
118 |
+
num_works = 2
|
119 |
+
download_progress_bar = tqdm(total=num_works, desc='Downloading video and audio progress')
|
120 |
if 'twitch' in url.lower():
|
121 |
download_twitch(url, DOWNLOAD_VIDEO)
|
122 |
+
download_progress_bar.update(1)
|
123 |
download_twitch(url, DOWNLOAD_AUDIO)
|
124 |
+
download_progress_bar.update(1)
|
125 |
elif 'youtube' in url.lower() or 'youtu.be' in url.lower():
|
126 |
download_youtube(url, DOWNLOAD_VIDEO)
|
127 |
+
download_progress_bar.update(1)
|
128 |
download_youtube(url, DOWNLOAD_AUDIO)
|
129 |
+
download_progress_bar.update(1)
|
130 |
else:
|
131 |
print('Unknown video source')
|
132 |
|