Porting XBMC (Kodi) modules to python
#1
xbmctopython

Porting XBMC modules to python. Following steps in xbmcstubs.

Description

This project has 7 python modules

The basic modules are: xbmc.py, xbmcaddon.py, xbmcplugin.py, xbmcgui.py and xbmcvfs.py.

This modules are the XBMC (KODI) modules and contains python code of some/all the members in it. Check the files to verify the objects that are ported in this version

The complementary modules:

KodiScriptImporter.py: This module is used to install a hook in the python importer system that makes available the basic modules and the Kodi Script modules
KodiServer.py: This module is used wih two purposes. The first, as a run module to test the KodiScriptImporter system with the video addons installed in your system. The second. as a debug module, to place breakpoints in the addon you are going to test and verify all you need.

You can find this project in
https://github.com/pybquillast/xbmctopython.git
Reply
#2
With this modules I can run kodi addons outside of kodi enviroment ?
Reply
#3
In this version, with KodiServer you can run the video addons installed in your system. You must be very carefull with the setup of the KodiScriptImporter in order to get KodiServer working properly.
With this modules you can forget the process outlined in HOW-TOBig Grinebug Python Scripts with Eclipse and do it as you do with a normal python script.
If you want to learn how to work with a script module, for example urlresolver, all you can do is:


Start an interactive session

Make available the path where you clone the project, for example c:/modxbmcpy, to python trought python path

>>> import sys
>>> sys.path.append('c:/modxbmcpy')

Create and install an importer instance
>>> import KodiScriptImporter as ksi
>>> importer = ksi.KodiScriptImporter() # For Win x86 users. See module for details
>>> importer.install() # Installed as a metha path importer

>>> import urlresolver # Here you must wait a little
>>> hmf = urlresolver.HostedMediaFile(url='http://vodlocker.com/lhtpwteyxhea') # A video url valid today
>>> hmf
{'url': 'http://vodlocker.com/lhtpwteyxhea', 'host': '', 'media_id': ''}
>>> hmf.resolve()
'http://77.81.98.229:8777/m2cearffcs4pcnokajccn2we6ripqt5ra435x5s377re4um3gx4grjmdyy/v.mp4' # Video URL
Reply
#4
(2016-03-22, 01:38)pybquillast Wrote: In this version, with KodiServer you can run the video addons installed in your system. You must be very carefull with the setup of the KodiScriptImporter in order to get KodiServer working properly.
With this modules you can forget the process outlined in HOW-TOBig Grinebug Python Scripts with Eclipse and do it as you do with a normal python script.
If you want to learn how to work with a script module, for example urlresolver, all you can do is:


Start an interactive session

Make available the path where you clone the project, for example c:/modxbmcpy, to python trought python path

>>> import sys
>>> sys.path.append('c:/modxbmcpy')

Create and install an importer instance
>>> import KodiScriptImporter as ksi
>>> importer = ksi.KodiScriptImporter() # For Win x86 users. See module for details
>>> importer.install() # Installed as a metha path importer

>>> import urlresolver # Here you must wait a little
>>> hmf = urlresolver.HostedMediaFile(url='http://vodlocker.com/lhtpwteyxhea') # A video url valid today
>>> hmf
{'url': 'http://vodlocker.com/lhtpwteyxhea', 'host': '', 'media_id': ''}
>>> hmf.resolve()
'http://77.81.98.229:8777/m2cearffcs4pcnokajccn2we6ripqt5ra435x5s377re4um3gx4grjmdyy/v.mp4' # Video URL

I will test tomorrow ! Thanks
Reply
#5
hi again, you can put here an example to test one video add on ?
I cant make this line: importer = ksi.KodiScriptImporter()
give me this error "Traceback (most recent call last):
File "<pyshell#10>", line 1, in <module>
importer = ksi.KodiScriptImporter()
File "c:/modxbmcpy\KodiScriptImporter.py", line 52, in __init__
self.initRootPaths()
File "c:/modxbmcpy\KodiScriptImporter.py", line 105, in initRootPaths
atype, alib = re.findall(pattern, content)[0]
IndexError: list index out of range"
Reply
#6
I updated the project so please clone it again (sorry). Then

KodiScriptImporter Interactive Session Setup

If you clone the repository, for example, to the directory c:/modxbmcpy in your system.

Start an interactive session

Make available c:/modxbmcpy to python trought python path
>>> import sys
>>> sys.path.append('c:/modxbmcpy')

Create and install an importer instance
>>> import KodiScriptImporter as ksi
>>> importer = ksi.KodiScriptImporter() # For Win x86 users. See module for details
>>> importer.install() # Installed as a metha path importer

Verify the installation (optional)
>>> import xbmc
>>> xbmc.translatePath(**'special://home'**)

KodiServer Interactive Session Setup

Check the importer installation that you test in KodiScriptImporter Interactive Session Setup
>>> import sys
>>> sys.path.append('c:/modxbmcpy')
>>> import KodiServer as ks
>>> http = ks.runServer() # Here you must apply the same parameters that you use for KodiScriptImporter

Now your default webbrowser must open in the address localhost:5000
The webbrowser must show all your installed addons in groups: video, audio (music), image (picture) and executable (program)
Click the addon you want to open. The audio and executable addons are based, specially when show the media, in the widgets defined in xbmcgui which are not ported yet

To stop the server
>>> httpd.shutdown() # Stop the server
>>> httpd.server_clase() # Close the socket
Reply
#7
I was just thinking about this sort of approach; I was looking for a way to be able to test kodi-library reliant scripts from within SublimeText.

Windows is a showstopper unfortunately, but I will have a look for Linux if I get a chance. I presume the Windows stuff is mostly about the socket handling?
Reply
#8
pybquillast its possible talk to you by email ? I want hire a developer to help me with a kodi project, if you are interested please contact me : )
My email: [email protected]

PS: I get an error when I try run kodi server:
Image

Thanks for help : )
Reply
#9
(2016-03-28, 08:52)Karnagious Wrote: I was just thinking about this sort of approach; I was looking for a way to be able to test kodi-library reliant scripts from within SublimeText.

Windows is a showstopper unfortunately, but I will have a look for Linux if I get a chance. I presume the Windows stuff is mostly about the socket handling?

Really there is no problem with systems differents to windows ( I hope).

The KodiScriptImporter and runServer has the following signature:

KodiScriptImporter.KodiScriptImporter(kodi, kodi_home)
KodiServer.runServer(kodi, kodi_home)

Where:
kodi ========> is the path point to by special://xbmc
kodi_home ===> is the path point to by special://home

In windows systems this two paths are mapped as:
kodi ========> $PROGRAMFILES/Kodi/addons
kodi_home ===> $APPDATA/Kodi/addons
So, is easy to code this paths as os.path.expandvars(path)

In other systems (i.e. linux) you must know the exact location of this tho paths, so if you are a linux user you can call this function with kodi and kodi_home mapped as :

>>> kodi = '/usr/share/kodi' # If you installed from a binary package (ie PPA, rpm, deb, etc). ??
>>> kodi_home = ' /home/[username]/.kodi' # Note: The '.', this directory is hidden so you may need to enable hidden files in your file
# manager to see it. ??

Then you can call:

>>> KodiScriptImporter.KodiScriptImporter(kodi, kodi_home) # To run the importer

or

>>> KodiServer.runServer(kodi, kodi_home) # To run the server

So is very important to verify, for your system, that kodi is mapped to the path where kodi is installed and kodi_home to the path where the addons are installed
Reply
#10
curtido: Problem solve, please try again. Thanks for the feedback
Reply
#11
Plese check the image: Image

What Im doing wrong ?

Thanks
Reply
#12
curtido: You must put Kodi and kodi_home as:


>>> kodi=r'C:\Program Files (x86)\Kodi\addons'
>>> kodi_home=r'C:\Users\Renato\AppData\Roaming\Kodi\addons'

the r is important here because it says that is a raw string. Without the r the \ is taken as a escape sequence.
Reply
#13
Thanks again,

But same error KeyError: 'audio' when I try run the server.

Image

Error In browser: A server error occurred. Please contact the administrator.
Reply
#14
(2016-03-30, 18:28)curtido Wrote: Thanks again,

But same error KeyError: 'audio' when I try run the server.

Image

Error In browser: A server error occurred. Please contact the administrator.


Please verify that you have the latest version for KosiServer.py. In the latest version the line 151 must be this:
Code:
if atype not in kdAddon.keys(): continue

To correct that mistake you must update the copy of the repository
Reply
#15
hi pybquillast if you are still here could you please check this

i used KodiScriptImporter to resolve
hmf = urlresolver.HostedMediaFile(url='https://openload.co/embed/Gu-VXlyFtKo')
but get the following message

Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
hmf.resolve()
File "C:\Users\zak\AppData\Roaming\Kodi\addons\script.module.urlresolver\lib\urlresolver\hmf.py", line 175, in resolve
stream_url = resolver.get_media_url(self._host, self._media_id)
File "C:\Users\zak\AppData\Roaming\Kodi\addons\script.module.urlresolver\lib\urlresolver\plugins\openload.py", line 60, in get_media_url
return ol_gmu.get_media_url(web_url)
File "C:\Users\zak\AppData\Roaming\Kodi\addons\script.module.urlresolver\lib\urlresolver\plugins\ol_gmu.py", line 79, in get_media_url
AttributeError: 'list' object has no attribute 'replace'
Reply

Logout Mark Read Team Forum Stats Members Help
Porting XBMC (Kodi) modules to python1