I'm working an agent for my mp3 collection to extract more data from my ID3 tags than the default LocalMediaAgent does. For genre, I'd like to accumulate all of the genres associated with all an artists files.
For example:
Barenaked Ladies
- \ Gordon
- - \ genre: Rock
- \ Stunt
- - \ genre: Pop
- \ Barenaked for the Holidays
- - \ genre: Rock; Christmas
When I go into Plex to view my music, I'd like to see all three genres (Rock, Pop, Christmas) associated with Barenaked Ladies.
Currently, only the genres from one of the subdirectories is applied to the artist. In this case Barenaked Ladies only has the genre Rock.
Here's a sample of my code:
class myLocalMediaArtist(Agent.Artist): def update(self, metadata, media, lang): for album in media.albums: for track in media.albums[album].tracks: for item in media.albums[album].tracks[track].items: for part in item.parts: # If there is an appropriate AudioHelper, use it. audio_helper = audiohelpers.AudioHelpers(part.file) if audio_helper != None: try: audio_helper.process_artist_metadata(metadata) except: pass class MP3AudioHelper(AudioHelper): def process_artist_metadata(self, metadata):# Genres
try:
genres = tags.getall(‘TCON’)
for genre in genres:
for g1 in genre.genres:
genre_list = g1.split(’;’)
for g in genre_list:
if g not in metadata.genres: metadata.genres.add(g)
except:
Log(“MyLocalMedia: Genre Exception”)
pass
It works to collect the data from an individual album, but does not collect it from all of the albums.
Any idea what I'm doing wrong?
-D. Dwarf