Fix detecting wrong file, embed thumbnails

This commit is contained in:
Salt 2020-03-06 04:03:07 -06:00
parent cb2dbde126
commit c57009b77f

View File

@ -80,21 +80,24 @@ class Library:
destfile = str(destpath / filename) + '.%(ext)s' destfile = str(destpath / filename) + '.%(ext)s'
logging.debug('Saving to: ' + destfile) logging.debug('Saving to: ' + destfile)
# See if we already have it # See if we already have it
if Path(str(destpath / song) + '.mp3').exists(): if Path(str(destpath / filename) + '.mp3').exists():
# Skip downloading # Skip downloading
logging.info('Already have song: ' + song) logging.info('Already have song: ' + song)
else: else:
# Download the song # Download the song
ytdl_opts = { ytdl_opts = {
'format': 'bestaudio', 'format': 'bestaudio',
'outtmpl': destfile,
'playlist_items': 1,
'quiet': True,
'writethumbnail': True,
'postprocessors': [{ 'postprocessors': [{
'key': 'FFmpegExtractAudio', 'key': 'FFmpegExtractAudio',
'preferredcodec': 'mp3', 'preferredcodec': 'mp3',
'preferredquality': '192' 'preferredquality': '192'
}], },{
'quiet': True, 'key': 'EmbedThumbnail'
'playlist_items': 1, }]
'outtmpl': destfile
} }
with youtube_dl.YoutubeDL(ytdl_opts) as ydl: with youtube_dl.YoutubeDL(ytdl_opts) as ydl:
ydl.download([songcontent['source']]) ydl.download([songcontent['source']])