Plugin api version 1 to version 2 differences or v1 docs

I have found a plugin that i want to use.
(Plugin - Tag first recorded date - #8 by craigshelley)
Unfortunately it uses version 1 of the pluin api and wont run on the current version of picard, so i will need to try to port it to version 2. Is there any where that the api v1 is documented? Or what changed or even a porting guide ( optimism!)

Im also looking for docs on what apis can be called from a v2 plugin
Thanks
Dpr

The date information that you’re looking for might be available as variables directly within Picard without needing a plugin. Have a look at _recording_firstreleasedate in the Basic Variables section of the Picard User Guide.

For information about plugin development, see the Plugins, Plugins API and Writing a Plugin sections.

3 Likes

Thanks for the suggestion. I’m after the first recording date, not when it was first released.

Unfortunately that a variable for that is missing.

The differences are not that big. Given that there is not really a defined API and plugins can access everything Picard provides this could vary.

The main general differences in the v2 API is porting to Python 3 and in case the plugin provides some UI probably also porting from PyQt4 to PyQt5 (not the case here).

The one thing in this specific plugin that is incompatible is the API call for getting the recording. self.album.tagger.xmlws does no longer exist, instead self.album.tagger.webservice would be used there. See e.g. https://github.com/metabrainz/picard-plugins/blob/943b4eaaaa10ac5ee47123df4e559487637f53f7/plugins/wikidata/init.py#L144-L149

Or for this specific case this might be a direct replacement:

self.album.tagger.mb_api.get_track_by_id(self.track_node.recording[0].id, self.myhandler, ['releases']);

The structure of the returned document in myhandler will also be a bit different, since the API changed from XML to JSON.

Then you will need to adapt the plugin. Looking at the plugin it fetches the earliest release date from all the releases the recording appears on. That is actually exactly what should be provided by the _recording_firstreleasedate variable.

For the recording date: If you are looking for the recording date of exactly this recording things might be a lot easier. This could be extracted from the already loaded recording data with a track metadata processor.

If you are looking for the first time this work has been recorded, even if it is a different recording from the one on the release, then it becomes more complicated. That probably involves loading all recordings for this work and getting the earliest recording date from them.

3 Likes

I have had a quick look at the code and came to pretty much the same conclusions as @outsidecontext.

I don’t think that it would be too difficult to make this plugin work in Picard v2, and then not too different to look in the metadata for the recording date rather than the earliest release date for the recording.

That said, I am not sure just how consistent the MusicBrainz metadata is for recording date. Supposing you had a copy of this CD of Let it Be by The Beatles and we look at the track 6 Let It Be. (I picked the Beatles because their recording dates are pretty well documented, and Let-It-Be because of the multitude of recordings available.)

Let It Be
    engineer: Glyn Johns and Phil McDonald (engineer and producer)
    producer: George Martin and Phil Spector
    drums (drum set): Ringo Starr (The Beatles) (on 1969-01-31, on 1970-01-04)
    electric bass guitar and maracas: Paul McCartney (The Beatles) (on 1970-01-04)
    electric guitar: George Harrison (The Beatles) (on 1970-01-04)
    guest Hammond organ and Rhodes piano: Billy Preston (on 1969-01-31)
    piano: Paul McCartney (The Beatles) (on 1969-01-31, on 1970-01-04)
    background vocals: George Harrison (The Beatles) (on 1969-01-31, on 1970-01-04), John Lennon (The Beatles) (on 1969-01-31), Linda McCartney (on 1970-01-04) and Paul McCartney (The Beatles) (on 1970-01-04)
    lead vocals: Paul McCartney (The Beatles) (on 1969-01-31)
    recorded at: Apple Studios in London, England, United Kingdom (on 1969-01-31) and Abbey Road Studios: Studio 2 in St John's Wood, Westminster, London, England, United Kingdom (on 1970-01-04)
    recording of: Let It Be (from 1969-01-31 until 1970-01-04)

As you can see, for this well documented recording there are a multitude of dates shown - and in this case they are reasonably consistent. But for other recordings of other songs by other artists, the data might be inconsistent or far more sparse. So the difficulty will be in coming up with an algorithm that will identify all the possible dates in the metadata that could indicate the recording date, and then make a decision about what date to use as THE (one and only) recording date - ideally eliminating any metadata which appears to be way out of line with the majority of other dates.

2 Likes

P.S. Based on this example, I would not recommend attempting to determine the earliest recording date of all recordings as this would include rehearsals etc. which have been released but do not IMO constitute a genuine recording.

To get a consistent and syntactic recording date, I think you would have to find the earliest release date of the work, and then try to get the recording date of the recording on that earliest release. And because works are related to recordings and recordings to releases, I am guessing that this is likely to require several API calls to MusicBrainz per track - i.e. get list of recordings for the work, and for each recording look up the earliest release date - which is several calls per track and would take an extended time to complete.

P.P.S. I haven’t analysed the code in detail but this Beets plugin (which uses MusicBrainz data) seems to be trying to do something to make sense of these multiple dates.

2 Likes

Thanks for the information.

I’m looking for the date of the recording - as in Heartbeat Hotel example we’ve discussed.

Thanks for the overview of the changes from v1 to v2. I’’m now thinking it would be simpler to build a new plugin based on an existing v2 one vs trying to port the v1 one

on heartbreak hotel -see below, what field is that?

is it the contents of a specific field or is it the result of an algorithm? i have added data in a specific field for some releases.

(post withdrawn by author, will be automatically deleted in 24 hours unless flagged)