Multiple artists support
This commit is contained in:
parent
77127d3476
commit
53a00570e7
2 changed files with 7 additions and 4 deletions
|
@ -20,6 +20,8 @@ class InfoYouTubePP(PostProcessor):
|
|||
information['track'] = information['title']
|
||||
if not 'artist' in information:
|
||||
information['artist'] = information['channel'].removesuffix(' - Topic')
|
||||
if not 'artists' in information:
|
||||
information['artists'] = [information['artist']]
|
||||
|
||||
if not 'album' in information:
|
||||
try:
|
||||
|
@ -47,10 +49,10 @@ class ID3TagsPP(PostProcessor):
|
|||
file = mp3.MP3(information['filepath'])
|
||||
|
||||
title = information['track']
|
||||
artist = information['artist']
|
||||
artists: list[str] = information['artists']
|
||||
|
||||
file['TIT2'] = id3.TIT2(encoding=ENC_UTF8, text=title)
|
||||
file['TPE1'] = id3.TPE1(encoding=ENC_UTF8, text=artist)
|
||||
file['TPE1'] = id3.TPE1(encoding=ENC_UTF8, text=artists) # multiple values are null-separated
|
||||
if 'album' in information:
|
||||
file['TALB'] = id3.TALB(encoding=ENC_UTF8, text=information['album'])
|
||||
if 'release_year' in information:
|
||||
|
@ -61,7 +63,7 @@ class ID3TagsPP(PostProcessor):
|
|||
file['TCON'] = id3.TCON(encoding=ENC_UTF8, text=information['genre'])
|
||||
|
||||
try:
|
||||
lyr_url = genius.search(title, artist)
|
||||
lyr_url = genius.search(title, artists[0])
|
||||
file['USLT'] = id3.USLT(encoding=ENC_UTF8, text=genius.parse(lyr_url))
|
||||
except:
|
||||
pass
|
||||
|
|
|
@ -25,6 +25,7 @@ INFO_AFTER = {
|
|||
**INFO_BEFORE,
|
||||
"track": "A Line in the Sand",
|
||||
"artist": "Linkin Park",
|
||||
"artists": ["Linkin Park"],
|
||||
"album": "The Hunting Party",
|
||||
"track_number": 12,
|
||||
}
|
||||
|
@ -39,7 +40,7 @@ class TestPostProcessorsOnFakeData(TestCase):
|
|||
def test_infoytpp(self) -> None:
|
||||
|
||||
_, info = id3pp.InfoYouTubePP().run(INFO_BEFORE)
|
||||
self.assertEqual(info, INFO_AFTER)
|
||||
self.assertDictEqual(info, INFO_AFTER)
|
||||
|
||||
def test_id3(self) -> None:
|
||||
|
||||
|
|
Loading…
Reference in a new issue