Switch to MP3, add ID3 tag support
RIP opus
This commit is contained in:
parent
19a01589e7
commit
fbc76ea62a
15
badwitch.py
15
badwitch.py
@ -11,6 +11,7 @@
|
||||
from appdirs import AppDirs
|
||||
from pathlib import Path
|
||||
import argparse
|
||||
import eyed3
|
||||
import json
|
||||
import logging
|
||||
import pathlib
|
||||
@ -69,9 +70,9 @@ class Library:
|
||||
Path(destpath).mkdir(parents=True, exist_ok=True)
|
||||
for song, songcontent in albumcontent.items():
|
||||
destfile = str(destpath / song) + '.%(ext)s'
|
||||
logging.debug('Saving to: ' + destfile)
|
||||
# See if we already have it
|
||||
matches = sorted(Path(destpath).glob(song + '.*'))
|
||||
if not matches == []:
|
||||
if Path(destfile).exists():
|
||||
logging.info('Already have song: ' + song)
|
||||
continue
|
||||
# Download the song
|
||||
@ -88,6 +89,16 @@ class Library:
|
||||
}
|
||||
with youtube_dl.YoutubeDL(ytdl_opts) as ydl:
|
||||
ydl.download([songcontent['source']])
|
||||
# Add tags
|
||||
logging.debug('Adding tags')
|
||||
resultfile = eyed3.load(str(destpath / song) + '.mp3')
|
||||
print(resultfile)
|
||||
|
||||
resultfile.tag.artist = songcontent['artist']
|
||||
resultfile.tag.album = album
|
||||
resultfile.tag.title = song
|
||||
resultfile.tag.track_num = songcontent['track']
|
||||
resultfile.tag.save()
|
||||
print('Downloaded song: ' + song)
|
||||
|
||||
class BadWitch:
|
||||
|
@ -1,2 +1,3 @@
|
||||
appdirs>=1.4.3
|
||||
eyed3>=0.8.8
|
||||
youtube-dl
|
||||
|
Loading…
Reference in New Issue
Block a user