ID3 tag metadata agent

Hey Guys,



after upgrading to Plex Nine I realized that album information (like cover or year) is fetched from LastFM or AllMusic.

Unfortunately some of my music is not properly tagged on both sites. Thus I got the idea to write an ID3 meta data agent (please correct me from wrong, but as far as I’ve seen, the scrapers do not provide such information like cover or release date).

For the time beeing I was able to code the basic structre of an agent (at least it shows up on Albums->LastFM), but now I’m kind of stuck and need the help of the comunity to kick-start the ID3 metadata agent.



I was able (or at least that’s what I currently assume from investigating the LastFM and AllMusic agents) to figure out that the class that takes an ‘Agent.Album’ as parameter has to provide to methods (namely ‘search’ and ‘update’). But I wasn’t able to find the definition of the parameters passed to these two methods. So, could somebody please point me to the classes defining those parameters (like ‘results’, ‘metadata’, ‘media’ and ‘lang’) or explain me what setters/getters or variables (sorry, I’m not the Python guru, and thus I’m missing the correct expression) the parameters provide.



In addition, I would highly appreciate someone explaining me how to access at least one filename (of a song) from the album to search/update.



Thanks a lot in advance,

Andreas

Developers: Please help this guy :smiley:



Metadata from LastFM and AllMusic really sucks :slight_smile:

A great option would be to fetch metadata form LastFM or AllMusic if available and if not use just the ID3 tags to have at least correct albmu informations and CD cover.

First open up ~/Library/Application Support/Plex Media Server/Plug-ins/Framework.bundle/Contents/Resources/Versions/2/Models/Metadata to have a look at the models and fields available.

Those .pym files are just text files so they should open in any text editor.

The media and metadata arguments will be instances of one of those


<br />
class MyAgent(Agent.Movies):<br />
# This should be a subclass of Agent.Movies, Agent.TV_Show or Agent.Artist<br />
<br />
  def search(self, results, media, lang):<br />
    # This provides the results you see in PMM's Fix incorrect match. The first one is chosen by default when you perform a scan<br />
    # self: the instance of your class that's being called. All methods you define should take this as the first argument<br />
    # results: The list of results. This is passed by reference. That means you write directly to this, no need to return anything<br />
    # media: Information passed to you from the scanner. Treat it as read-only.<br />
    # lang: The language you're looking for. No idea if this is useful here.<br />
    results.Append(MetadataSearchResult(id=id, name=name, year=year, score=score, lang=Locale.Language.English)) # Adding a result. NB: the lang argument is required<br />
<br />
  def update(self, metadata, media, lang):<br />
    # This fills in the information you see in Plex and PMM. It gets called once for each results list you filled in above<br />
    # self: same as in search method<br />
    # metadata: An instance of the model passed by reference. This is where you write info<br />
    # media: Information passed to you from the search results. Treat it as read-only.<br />
    # lang: not sure how that's configured.<br />
    metadata.title = 'title'<br />
    metadata.posters = Proxy.Media(HTTP.Request(PosterURL))<br />
    <br />




When filling in info be sure to get the right data type. Most of the names should be self-explanatory (e.g. Template.String is a string)
If you need some code to grab ID3 tags from files have a look at the IMDB agent.

Was anyone ever able to get an ID3 Metadata Agent functional?

Last.fm consistently incorrectly matches my albums and album covers.



:frowning:

I’m taking a crack at this as we speak. I’m running into some issues getting mutagen imported so I can pars the ID3 tags. Using LocalMedia.bundle as a guide, I duplicated the directory structure and copied over the mutagen source files. When I try to import the classes I need I get an import error: “ImportError: No module named mutagen.mp3”



I’m obviously missing something - can anyone point me in the right direction? Do I need to add the path to the mutagen source files somewhere?



Also, please bear with me as I am also learning python as I work through this. Any help is appreciated!

Any update on this? Would love the feature.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.