Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- import xbmcgui
- import xbmcplugin
- import urllib2
- import xbmcaddon # for user settings
- addon_handle = int(sys.argv[1])
- xbmcplugin.setContent(addon_handle, 'movies')
- def index():
- # Settings
- url = "https://example.com/"
- realm = "example"
- movieList = 'https://example.com/movies.xbmc'
- # Get username and password from addon config
- my_addon = xbmcaddon.Addon('plugin.video.chillstream')
- digUser = my_addon.getSetting('username')
- digPass = my_addon.getSetting('password')
- # Prepare Auth Digest
- mgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
- mgr.add_password(realm,url,digUser,digPass)
- authhandler = urllib2.HTTPDigestAuthHandler(mgr)
- opener = urllib2.build_opener(authhandler)
- urllib2.install_opener(opener)
- # Download movie list
- response = urllib2.urlopen(movieList)
- # Add to list
- for line in response:
- line = line.rstrip() # strip LF at the end of line
- lineArray = line.split(';;', 6)
- url = lineArray[0]
- cover = lineArray[1]
- trailer = lineArray[2]
- duration = lineArray[3]
- width = lineArray[4]
- height = lineArray[5]
- title = url.rsplit('/',1) # basename
- title = title[1].rsplit('.', 1) # cut off extension
- title = urllib2.unquote(title[0]) # urldecode (needed after extension removal)
- url = 'https://' + digUser + ':' + digPass + '@' + url[8:] + '|auth=anysafe' # http://wiki.xbmc.org/index.php?title=HTTP
- li = xbmcgui.ListItem(title, iconImage='DefaultVideo.png', thumbnailImage=cover)
- li.addStreamInfo('video', { 'width': width, 'height': height, 'duration': duration})
- #li.addContextMenuItems([ ('Refresh List', 'Container.Refresh') ]) #, replaceItems=True)
- li.addContextMenuItems([ ('Play trailer', 'PlayMedia(plugin://plugin.video.youtube/?action=play_video&videoid=%s)' % trailer) ])
- li.setProperty('fanart_image', cover)
- xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li)
- xbmcplugin.endOfDirectory(addon_handle)
- index()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement