fix: prefer topic channel for album artist

This commit is contained in:
Your GitHub Name 2026-07-16 12:34:03 -07:00
parent c104e30451
commit 220f991fae
2 changed files with 48 additions and 2 deletions

View file

@ -87,6 +87,40 @@ class AlbumArtistPostProcessorTests(unittest.TestCase):
self.assertEqual(result['album_artist'], 'ScHoolboy Q')
def test_uses_topic_channel_artist_for_joint_album(self):
info = {
'album': 'Watch the Throne',
'artists': ['JAY-Z', 'Kanye West'],
'channel': 'JAY-Z & Kanye West - Topic',
}
_, result = self.postprocessor.run(info)
self.assertEqual(result['album_artist'], 'JAY-Z & Kanye West')
def test_uses_topic_uploader_and_strips_suffix_for_compilation(self):
info = {
'album': 'Compilation',
'artist': 'Track Artist',
'channel': 'Regular Channel',
'uploader': 'Various Artists - Topic',
}
_, result = self.postprocessor.run(info)
self.assertEqual(result['album_artist'], 'Various Artists')
def test_regular_channel_falls_back_to_main_artist(self):
info = {
'album': 'Album',
'artist': 'Track Artist',
'channel': 'Label Channel',
}
_, result = self.postprocessor.run(info)
self.assertEqual(result['album_artist'], 'Track Artist')
def test_preserves_explicit_various_artists(self):
info = {
'album': 'Revenge of the Dreamers III',

View file

@ -54,7 +54,9 @@ _LIVE_PROBE_MAX_FAILURES = 5
class _AlbumArtistPostProcessor(PostProcessor):
"""Fill missing album-artist metadata from yt-dlp's main track artist."""
"""Fill missing album-artist metadata from yt-dlp's album-level signals."""
_TOPIC_SUFFIX = ' - Topic'
@staticmethod
def _has_value(value: Any) -> bool:
@ -76,13 +78,23 @@ class _AlbumArtistPostProcessor(PostProcessor):
return candidate.split(' · ', 1)[0].strip()
return None
@classmethod
def _topic_artist(cls, info) -> Optional[str]:
for field in ('channel', 'uploader'):
value = info.get(field)
if not isinstance(value, str) or not value.endswith(cls._TOPIC_SUFFIX):
continue
if artist := value[:-len(cls._TOPIC_SUFFIX)].strip():
return artist
return None
def run(self, info):
if not self._has_value(info.get('album')):
return [], info
if self._has_value(info.get('album_artist')) or self._has_value(info.get('album_artists')):
return [], info
if artist := self._main_artist(info):
if artist := self._topic_artist(info) or self._main_artist(info):
info['album_artist'] = artist
return [], info