0

Basically I have a python script which is an addon for Kodi. I would like to create some sort of IPTV and update channels accordingly but the addon won't get updated.

I've thought of a method where I have the python script hosted on the internet which includes several channels like this, then I call that script from the addon python script itself. Therefore when I want to add new channels, I only edit the script hosted on the internet. The internet script will look something like this:

url = 'link of channel'
li = xbmcgui.ListItem('Name of channel', iconImage='DefaultVideo.png')
xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li)

Is this possible? Can I call this script hosted on the internet through another local python script and so it gets executed inside that script itself?

Thanks

  • There are many frameworks that will let you execute code when a URL is visited or a certain input passed: flask, django... – Bob Dylan Sep 21 '15 at 16:21
  • No I don't want to execute any code when I visit a url. All I want is to run the code that is saved on a website from another local python script. – Jeffrey Spiteri Sep 21 '15 at 16:53
  • If you have access to the server on which the hosted script resides, you could try [Fabric](http://www.fabfile.org/). – Daniel Corin Sep 21 '15 at 16:56

1 Answers1

0

You can download your script:

from urllib2 import urlopen
script = urlopen('url of your script')

Store somewhere where your plugin has access (ie resources/lib inside your addon folder):

import xbmcaddon
addon = xbmcaddon.Addon()
addonPath = addon.getAddonInfo('path')
script_data = script.read()
import xbmc
import os
script_file_path = os.path.join(xbmc.translatePath(addonPath), 'resources', 'lib', 'your_plugin.py')
script_file = open(scrip_file_path, 'w')
script_file.write(script_data)
script_file.close()

Then import it, and then call some functions you need from it.

from resources.lib.your_plugin import your_func
your_func()

Another way is not to host script itself on the server, but the list of channels, for example in JSON format, and then download it from plugin.

  • Wow. Great thanks a lot man! Yes preferably I host the list of channels somewhere then have the addon to fetch the script and parse the list, however don't know how to do that yet. Thanks for the help so far :) – Jeffrey Spiteri Sep 30 '15 at 17:20