Multiple artists support

This commit is contained in:
DarkCat09 2024-05-03 18:38:11 +04:00
parent 77127d3476
commit 53a00570e7
Signed by: DarkCat09
GPG key ID: 0A26CD5B3345D6E3
2 changed files with 7 additions and 4 deletions

View file

@ -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

View file

@ -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: