lad1337 / XDM-main-plugin-repo

The official main Plugin Repository
19 stars 11 forks source link

Documentations on creating plugins #10

Open groenlid opened 10 years ago

groenlid commented 10 years ago

I'm currently making a couple of plugins for xdm, but feel a little restricted with the lack of documentation in that area. Seems that https://xdm.readthedocs.org/en/latest/ have not been updated in 7 months. Is there any other place where documentation exists?

I also seem to have a problem when I run forceReload on an Anime-show, a duplicate row in the Element table is added with the same field attributes (same id, title, images). Wouldn't something like this fix that?

        try:
            showElement = Element.getWhereField(mediaType, 'Show', {'id': item['id']}, self._tag, rootElement)
            log("Found element")
        except Element.DoesNotExist:
            log("Creating new element")
            showElement = Element()
            showElement.mediaType = mediaType
            showElement.parent = rootElement
            showElement.type = 'Show'
            showElement.setField('id', item['id'], self._tag)
        showElement.setField('title', item['title'].encode('utf-8'), self._tag)
        showElement.setField('poster_image', self._resize_url + item['image'], self._tag)
        showElement.setField('fanart_image', self._resize_url + item['fanart'], self._tag)

        showElement.saveTemp()

The entire code is here: https://github.com/groenlid/xdm-anime-plugin-repo/

lad1337 commented 10 years ago

that the same row is created again is intended ... since the saveTemp() saves it with the status "temporary" if you look for the anime that is already there and connect all the episodes to the old one it will have two of each

worst part is if you use the old "root" the comparison of the two trees will probably fail an update is designed to get a full new data tree and XDM will compare them and copy / overwrite new nodes and add new ones

the update code is here https://github.com/lad1337/XDM/blob/master/xdm/tasks.py#L315 the call to the provider is at https://github.com/lad1337/XDM/blob/master/xdm/tasks.py#L327

i am not sure if all this works for a an update on a single episode ... it is meant to get the full tree so a call to force update element on a single episode might not work

on terms of documentation ... there is nothing more then you found ... i'll stop features until i wrote more documentation because more ppl are interested in making plugins now ... yeah :)

edit: ok there was a bug when "compiling" the doc the i18n function _ and ngettext where not "installed" and the build would fail on those paths now i can write more doc now :)

funny thing though the read the docs does not display the correct version number but if i compile them localy it usese the current XDM version :/

lad1337 commented 10 years ago

i tried your plugin and i am not gettting much info from the api well none of the anime i tried have episodes it also looks like you are accessing some other server is there a documentation on the uranime api ?

lad1337 commented 10 years ago

i am playing around with your uranime provider and i noticed you are just missing a call to the details page but ... apparently your test server is down or you are working on it :/

groenlid commented 10 years ago

hmm.. yes, I've been running the api from my development server, which could be a reason for the instability but it should be up again now. I've also updated the code on the server-side so /api/search?q=query is deprecated and replaced with /api/anime?title=query. I've also pushed some new code to the plugin repo to accomodate this.

Regarding the last thing you said about the missing call to the details page. I do make such a call under the getElement func but not in searchForElement. Shouldn't getElement be called when manually running a forceRefresh for a serie ( http://x.x.x.x:xxxx/refreshinfo?id=43)?

Sorry, but I haven't currently written any documentation for the api, but since it's open-source, you can atleast view the endpoints :+1: https://github.com/groenlid/Uranime-api/blob/feature_animeoverview_yearselect/app.js#L46