This commit is contained in:
parent
653aded23e
commit
f376634dd0
|
@ -160,21 +160,20 @@ class ytdlLogger(object):
|
|||
|
||||
|
||||
def my_hook(d):
|
||||
global done, i
|
||||
global done, videoInc
|
||||
if d['status'] == 'finished':
|
||||
if not done:
|
||||
# print('\r[finished] {} '.format(d['filename']))
|
||||
done = True
|
||||
else:
|
||||
done = False
|
||||
elif d['status'] == 'downloading':
|
||||
if not done:
|
||||
if isURL:
|
||||
length = i
|
||||
length = videoInc
|
||||
else:
|
||||
length = i + '/' + len(lines)
|
||||
length = videoInc + '/' + len(lines)
|
||||
|
||||
sys.stdout.write('\x1b[2K') # erase last line
|
||||
sys.stdout.write('\x1b[2K')
|
||||
try:
|
||||
sys.stdout.write('\r[{}] {} -> "{}" | {} {} {} {}'.format(d['status'], length, d['filename'].strip('downloads/'),
|
||||
d['_speed_str'], d['_total_bytes_str'], d['_eta_str'], d['_percent_str']))
|
||||
|
@ -182,9 +181,9 @@ def my_hook(d):
|
|||
pass
|
||||
sys.stdout.flush()
|
||||
else:
|
||||
sys.stdout.write('\x1b[2K') # erase last line
|
||||
sys.stdout.write('\x1b[2K')
|
||||
try:
|
||||
sys.stdout.write('\r[{}] {} -> "{}"'.format(d['status'], length, d['filename'].strip('downloads/')))
|
||||
sys.stdout.write('\r[{}] {}'.format(d['status'], d['filename'].strip('downloads/')))
|
||||
except KeyError as error:
|
||||
pass
|
||||
sys.stdout.flush()
|
||||
|
@ -208,7 +207,7 @@ ydl_opts = {
|
|||
ytdlCMD = 'youtube-dl -i --add-metadata --all-subs --embed-subs --embed-thumbnail -f "{}" --merge-output-format mkv -o "downloads/%(title)s - %(id)s.%(ext)s" --write-annotations --write-info-json --write-description --write-all-thumbnails --write-sub --sub-format "best" --geo-bypass'.format(
|
||||
ytdlFormat)
|
||||
|
||||
i = 1
|
||||
videoInc = 1
|
||||
if not isURL:
|
||||
for line in lines:
|
||||
for x in getUrls(line):
|
||||
|
@ -229,11 +228,10 @@ if not isURL:
|
|||
compress('{}-{}'.format(args.output, i))
|
||||
else:
|
||||
compress(args.output)
|
||||
i = i + 1
|
||||
else:
|
||||
print('[info] Video too big')
|
||||
logger.info('skipping ' + x + ' because too big')
|
||||
i = i + 1
|
||||
videoInc = videoInc + 1
|
||||
else:
|
||||
for x in getUrls(args.file):
|
||||
if checkSize(x):
|
||||
|
@ -249,11 +247,10 @@ else:
|
|||
else:
|
||||
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
|
||||
ydl.download([x])
|
||||
i = i + 1
|
||||
else:
|
||||
print('[info] Video too big')
|
||||
logger.info('skipping ' + x + ' because too big')
|
||||
i = i + 1
|
||||
videoInc = videoInc + 1
|
||||
compress(args.output)
|
||||
|
||||
print()
|
||||
|
|
Reference in New Issue