-
Notifications
You must be signed in to change notification settings - Fork 11
Plugin development #2
Comments
i am happy to explain
so your Provider needs to create object that are in this structure
first thing when the searchForElement() is called you should call self.progress.reset() used here https://github.com/lad1337/XDM-main-plugin-repo/blob/master/Discogs/Discogs.py#L52 searchForElement returns a Root Element mtm = common.PM.getMediaTypeManager('de.lad1337.music')[0]
fakeRoot = mtm.getFakeRoot(term) where term is the search term, this is used on the search page to identify the old searches. it can be anything but best is to just use the term that you get from the call. used here https://github.com/lad1337/XDM-main-plugin-repo/blob/master/Discogs/Discogs.py#L55 now you can call whatever it is that gets you information from last.fm to create object that represent the Artist, Albums and Songs you need a mediatype = MediaType.get(MediaType.identifier == 'de.lad1337.music') this is needed to connect each object to the mediatype (it could be done by traversing back to the root but its just how it is for now) to create actual objects according to the structure we first need an Artist artistElement = Element()
artistElement.mediaType = mediaType
artistElement.parent = fakeRoot
artistElement.type = 'Artist'
artistElement.setField('name', artistName, self.tag)
artistElement.setField('id', artistName, self.tag)
artistElement.saveTemp() used here: https://github.com/lad1337/XDM-main-plugin-repo/blob/master/Discogs/Discogs.py#L94
the self.tag is an identifier string used to identify information to different providers on one Element adding an album to the artist would then be albumElement = Element()
albumElement.mediaType = mediaType
albumElement.parent = artistElement
albumElement.type = 'Album'
albumElement.setField('name', release.title, self.tag)
albumElement.setField('year', release.data['year'], self.tag)
albumElement.setField('id', release.data['id'], self.tag) note that the .parent is now the just created artistElement this created the tree, do the same with songs for the album to know what the field names are have a look in the MediaTypeManager at the end you return fakeRoot oh i forgot to mention if you have a total count of you albums (the thing the use wil see in the gui) set self.progress.total and when you iterate over one of these use also start XDM with -D (for debug) and --dev (for development mode) i am sure i forgot something... |
Thanks for the info.
|
Hello,
I would like to create a last.fm provider plugin for music. I am a bit stuck though as I cannot seem to identify firstly the correct data structure and secondly how I should return it/where it should be stored. Can you provide further guidance?
The text was updated successfully, but these errors were encountered: