Kodi Community Forum

Full Version: Media importing and library integration (UPnP, Emby, Plex, ...)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey Montellese, I just wanted to let you know I saw your post. I should have time to take a look tomorrow.
Montellese,

We should create a dependency add-on in python, for the new api in the xbmcmediaimport module. Without anything else. Then, provider add-ons can just plug into it to use the new api. I think we would have more control over things this way, when/if the api is updated. Is this the direction you were thinking?
or you depend on xbmc.python like any other add-on already does that needs a newer API
(2017-06-13, 20:11)angelblue05 Wrote: [ -> ]Montellese,

We should create a dependency add-on in python, for the new api in the xbmcmediaimport module. Without anything else. Then, provider add-ons can just plug into it to use the new api. I think we would have more control over things this way, when/if the api is updated. Is this the direction you were thinking?

TBH I'm not really familiar with Kodi's add-on ecosystem. I know how the python API works from the C/C++ side and how the whole thing is integrated into core but I have never written a python add-on myself. I'm just trying to figure out what needs to be in the API to be able to cover the whole use case right now.
Ok, Smile

Looking at the add-on you built, and trying to decide the best way to tackle this. Is it possible for me to view the api in your kodi fork?
(2017-06-13, 20:46)angelblue05 Wrote: [ -> ]Ok, Smile

Looking at the add-on you built, and trying to decide the best way to tackle this. Is it possible for me to view the api in your kodi fork?

Thanks for looking into it. I'm open to any suggestions.

For the API on the C++ side (which gets translated to a python API) you need to look at https://github.com/Montellese/xbmc/blob/...iaimport.h for the "xbmcmediaimport" module and the header files in https://github.com/Montellese/xbmc/tree/...ediaimport for the additional classes. Right now I'm looking into supporting "dynamic" settings for media providers and media imports from python.
(2017-06-13, 20:49)Montellese Wrote: [ -> ]Right now I'm looking into supporting "dynamic" settings for media providers and media imports from python.

Such as?
(2017-06-13, 21:03)angelblue05 Wrote: [ -> ]
(2017-06-13, 20:49)Montellese Wrote: [ -> ]Right now I'm looking into supporting "dynamic" settings for media providers and media imports from python.

Such as?

An Emby importer needs to be able to store settings like username and password for authentication, device identifier used in the API etc. These will be different for every media importer implementation.
Yes, are you saying you are looking to have this information imported within the xbmcmediaimport module? Sorry for the many questions, just want to make sure we are on the same page.
Yes, with the latest update from a few minutes ago it's partly integrated for media providers but not yet for media imports.
Ok, so technically, the python add-on would not make use of the settings.xml for this? If you don't mind me asking, what is the purpose of having this info within the xbmcmediaimport?

I don't want to complicate your life. I thought maybe all of this would be handled individually within the python add-on. Then, within the xbmcmediaimport, it would just use a provider id to refer to/retrieve the information provided by the add-on.

Edit: Anyway, I will build upon what you have in place and we'll see where it goes Smile
(2017-06-13, 21:53)angelblue05 Wrote: [ -> ]Ok, so technically, the python add-on would not make use of the settings.xml for this? If you don't mind me asking, what is the purpose of having this info within the xbmcmediaimport?

I don't want to complicate your life. I thought maybe all of this would be handled individually within the python add-on. Then, within the xbmcmediaimport, it would just use a provider id to refer to/retrieve the information provided by the add-on.

Well I initially did this whole setup and API for UPnP media importing which is implemented in C++ in Kodi's core. Therefore it was easiest to do all the setting handling etc. using the existing infrastructure and reusing existing dialogs. So I thought it would make sense to provide python importers the same possibilities. Obviously you can ignore that and do your own thing in the add-on and just implement the necessary actions / callbacks by returning no settings or showing your own dialog but since Kodi already comes with the functionality to store the settings per media provider and per media import for you and supports showing a dialog nicely integrated into the user interface you have that option as well.

Right now the settings for emby media providers are defined in https://github.com/Montellese/xbmc/blob/...er.py#L412 and are passed to Kodi. In addition to that "static" XML describing the settings the script registers a custom callback at https://github.com/Montellese/xbmc/blob/...er.py#L495 which allows it to dynamically provide a list of users available in the specific Emby server which is implemented at https://github.com/Montellese/xbmc/blob/...er.py#L341.
Since having to store XML in python doesn't make much sense I'm thinking about providing a way in the addon.xml to specify different XML files for media provider and media import settings and then all the python script needs to do is any additional dynamic handling.

I have to solve some localization issues right now because the labels defined for the settings aren't displayed in the settings dialog.

Please let me know if any of the naming in the python API could be improved to understand what's going on. I've been working on this for several years now so I probably cannot see the wood for the trees anymore Confused

EDIT: Forgot to mention that the add-on can still make use of the regular settings.xml but only for settings that affect all (potential) media providers and imports or how the add-on works on general. But for the settings specific to a provider or import they need to be stored with that object.
It's such a pain to work with XML in python, isn't it Tongue json is the easiest, in my opinion. Especially when dealing with string encoding.

I will let you know about the api, but so far, the naming seems fine to me. Ok, I will check it out and let you know if I have more questions. Thanks for taking the time to reply!

Edit: I hope it's ok to use requests rather than urllib2, it's just easier to manage all around.
@ Montellese Can you kick a new build of Kodi that matches the improvements that you have made to the plugin since the build above.
(2017-06-13, 23:42)angelblue05 Wrote: [ -> ]It's such a pain to work with XML in python, isn't it Tongue json is the easiest, in my opinion. Especially when dealing with string encoding.
Yeah unfortunately I haven't written a JSON parser for the settings system/library yet (which is somewhere on my long TODO list).

(2017-06-13, 23:42)angelblue05 Wrote: [ -> ]Edit: I hope it's ok to use requests rather than urllib2, it's just easier to manage all around.
Feel free to use whatever you want. The way I write this add-on is to google "python get current time", take the first code snippet and then I google "python http request" and so on. I'm sure there are a lot of "who wrote this piece of s**t code" moments in there for anyone with a bit of python coding experience.

(2017-06-14, 04:27)LongMan Wrote: [ -> ]@ Montellese Can you kick a new build of Kodi that matches the improvements that you have made to the plugin since the build above.
I noticed an annoying bug in the settings handling (which makes it unusable) which I want to fix and then I can provide another build.