Fixed downloads erroring out with private videos in playlist
This commit is contained in:
14
backend.py
14
backend.py
@@ -40,7 +40,7 @@ def process_general(url, ext, update=False):
|
|||||||
hour = str(current_time.hour)
|
hour = str(current_time.hour)
|
||||||
hour = hour if len(hour) > 1 else '0' + hour
|
hour = hour if len(hour) > 1 else '0' + hour
|
||||||
minute = str(current_time.minute)
|
minute = str(current_time.minute)
|
||||||
minute = minute if len(minute) > 1 else '0' + hour
|
minute = minute if len(minute) > 1 else '0' + minute
|
||||||
|
|
||||||
# add url and time to list of queued downloads
|
# add url and time to list of queued downloads
|
||||||
queued_downloads.append([url, hour + ':' + minute])
|
queued_downloads.append([url, hour + ':' + minute])
|
||||||
@@ -56,7 +56,7 @@ def process_general(url, ext, update=False):
|
|||||||
urls.clear()
|
urls.clear()
|
||||||
|
|
||||||
# get basic info for given url
|
# get basic info for given url
|
||||||
query = ydl.YoutubeDL({'quiet': True}).extract_info(url=url, download=False)
|
query = ydl.YoutubeDL({'quiet': True, 'ignoreerrors': True}).extract_info(url=url, download=False)
|
||||||
parent = query['title']
|
parent = query['title']
|
||||||
|
|
||||||
if update:
|
if update:
|
||||||
@@ -82,7 +82,7 @@ def process_download(url, ext, parent, query, current_thread):
|
|||||||
try:
|
try:
|
||||||
# this throws KeyError when downloading single file
|
# this throws KeyError when downloading single file
|
||||||
for video in query['entries']:
|
for video in query['entries']:
|
||||||
if check_already_exists(video['id']):
|
if video is not None and check_already_exists(video['id']):
|
||||||
add_new_video_to_collection(parent, video['id'])
|
add_new_video_to_collection(parent, video['id'])
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@@ -113,7 +113,7 @@ def process_download(url, ext, parent, query, current_thread):
|
|||||||
for tab in query['entries']:
|
for tab in query['entries']:
|
||||||
# for every video in their respective tabs
|
# for every video in their respective tabs
|
||||||
for video in tab['entries']:
|
for video in tab['entries']:
|
||||||
if check_already_exists(video['id']):
|
if video is not None and check_already_exists(video['id']):
|
||||||
add_new_video_to_collection(parent, video['id'])
|
add_new_video_to_collection(parent, video['id'])
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@@ -325,6 +325,7 @@ def yt_download(location, ext='mp3'):
|
|||||||
# base download options for audio
|
# base download options for audio
|
||||||
opts = {
|
opts = {
|
||||||
'quiet': True,
|
'quiet': True,
|
||||||
|
'ignoreerrors': True,
|
||||||
'windowsfilenames': True,
|
'windowsfilenames': True,
|
||||||
'outtmpl': location + '%(title)s.%(ext)s',
|
'outtmpl': location + '%(title)s.%(ext)s',
|
||||||
'format': 'bestaudio/best',
|
'format': 'bestaudio/best',
|
||||||
@@ -342,10 +343,7 @@ def yt_download(location, ext='mp3'):
|
|||||||
opts.pop('postprocessors')
|
opts.pop('postprocessors')
|
||||||
|
|
||||||
# try to download all new files
|
# try to download all new files
|
||||||
try:
|
ydl.YoutubeDL(opts).download(urls)
|
||||||
ydl.YoutubeDL(opts).download(urls)
|
|
||||||
except ydl.DownloadError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
12
frontend.py
12
frontend.py
@@ -61,7 +61,7 @@ def downloader():
|
|||||||
|
|
||||||
# show download start confirmation
|
# show download start confirmation
|
||||||
flash('Download enqueued and will finish in background.', 'primary')
|
flash('Download enqueued and will finish in background.', 'primary')
|
||||||
return render_template('flash-message.html')
|
return redirect('/downloader')
|
||||||
|
|
||||||
|
|
||||||
@frontend.route('/library', methods=['GET'])
|
@frontend.route('/library', methods=['GET'])
|
||||||
@@ -104,14 +104,10 @@ def download():
|
|||||||
if '.' in file_path:
|
if '.' in file_path:
|
||||||
path, name, ext = dissect_file_name(file_path)
|
path, name, ext = dissect_file_name(file_path)
|
||||||
|
|
||||||
video = query_db('SELECT path, name, ext FROM video '
|
# this is flaky for whatever reason; might be because of special chars?
|
||||||
'WHERE name = :name AND path = :path AND ext = :ext',
|
|
||||||
{'name': name, 'path': path, 'ext': ext},
|
|
||||||
True)
|
|
||||||
|
|
||||||
return send_from_directory(
|
return send_from_directory(
|
||||||
downloads_path() + video['path'],
|
'downloads\\' + path,
|
||||||
video['name'] + video['ext']
|
name + ext
|
||||||
)
|
)
|
||||||
|
|
||||||
# else a directory is requested
|
# else a directory is requested
|
||||||
|
|||||||
Reference in New Issue
Block a user