Advertisement
Guest User

Untitled

a guest
Apr 19th, 2014
3
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.07 KB | None | 0 0
  1. import sys
  2. import xbmcgui
  3. import xbmcplugin
  4. import urllib2
  5. import xbmcaddon # for user settings
  6.  
  7. addon_handle = int(sys.argv[1])
  8. xbmcplugin.setContent(addon_handle, 'movies')
  9.  
  10. def index():
  11. # Settings
  12. url = "https://example.com/"
  13. realm = "example"
  14. movieList = 'https://example.com/movies.xbmc'
  15.  
  16. # Get username and password from addon config
  17. my_addon = xbmcaddon.Addon('plugin.video.chillstream')
  18. digUser = my_addon.getSetting('username')
  19. digPass = my_addon.getSetting('password')
  20.  
  21. # Prepare Auth Digest
  22. mgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
  23. mgr.add_password(realm,url,digUser,digPass)
  24. authhandler = urllib2.HTTPDigestAuthHandler(mgr)
  25. opener = urllib2.build_opener(authhandler)
  26. urllib2.install_opener(opener)
  27.  
  28. # Download movie list
  29. response = urllib2.urlopen(movieList)
  30.  
  31. # Add to list
  32. for line in response:
  33. line = line.rstrip() # strip LF at the end of line
  34. lineArray = line.split(';;', 6)
  35. url = lineArray[0]
  36. cover = lineArray[1]
  37. trailer = lineArray[2]
  38. duration = lineArray[3]
  39. width = lineArray[4]
  40. height = lineArray[5]
  41.  
  42.  
  43. title = url.rsplit('/',1) # basename
  44. title = title[1].rsplit('.', 1) # cut off extension
  45. title = urllib2.unquote(title[0]) # urldecode (needed after extension removal)
  46.  
  47. url = 'https://' + digUser + ':' + digPass + '@' + url[8:] + '|auth=anysafe' # http://wiki.xbmc.org/index.php?title=HTTP
  48. li = xbmcgui.ListItem(title, iconImage='DefaultVideo.png', thumbnailImage=cover)
  49. li.addStreamInfo('video', { 'width': width, 'height': height, 'duration': duration})
  50. #li.addContextMenuItems([ ('Refresh List', 'Container.Refresh') ]) #, replaceItems=True)
  51. li.addContextMenuItems([ ('Play trailer', 'PlayMedia(plugin://plugin.video.youtube/?action=play_video&videoid=%s)' % trailer) ])
  52. li.setProperty('fanart_image', cover)
  53. xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li)
  54. xbmcplugin.endOfDirectory(addon_handle)
  55.  
  56. index()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement