Now for ID3
This commit is contained in:
Salt 2020-03-04 00:23:52 -06:00
parent 9f5a9ac810
commit ad3ebe9a77

View File

@ -64,10 +64,11 @@ class Library:
destpath = (Path.home() / 'Music' / artist / album)
Path(destpath).mkdir(parents=True, exist_ok=True)
for song, songcontent in albumcontent.items():
destfile = str(destpath / song) + '.%(ext)s'
# See if we already have it
matches = sorted(Path(destpath).glob(song + '.*'))
if not matches == []:
logging.debug('Using cached song: ' + song)
logging.info('Already have song: ' + song)
continue
# Download the song
ytdl_opts = {
@ -77,8 +78,9 @@ class Library:
'preferredcodec': 'opus',
'preferredquality': '192'
}],
'extract_audio': True,
'quiet': True,
'playlist_items': 1,
'outtmpl': destfile
}
with youtube_dl.YoutubeDL(ytdl_opts) as ydl:
ydl.download([songcontent['source']])