Advertisement
Guest User

addon

a guest
Mar 19th, 2016
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.88 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. # Module: default
  3. # Author: Stroopwafel
  4. # Created on 19-03-2016
  5. # License: GPL v.3 https://www.gnu.org/copyleft/gpl.html
  6.  
  7. import sys
  8. import urlparse import parse_qsl
  9. import xbmcgui
  10. import xbmcplugin
  11.  
  12. # Get the plugin url in plugin:// notation.
  13. _url = sys.argv[0]
  14. # Get the plugin handle an an integer number.
  15. _handle = int(sys.argv[1])
  16.  
  17. # Define categories and videos:
  18. VIDEOS = {'Formula_E': [{'name': 'Being ePrix',
  19. 'thumb': 'http://i.imgur.com/D3KPxZC.png',
  20. 'video': 'https://fpdl.vimeocdn.com/vimeo-prod-skyfire-std-us/01/3702/5/143512140/431745863.mp4?token=56ee2293_0xcd6ca3c59947c169560a646f765a83a30ce51fdc',
  21. 'genre': 'Formula E'},
  22. {'name': 'Putajaya ePrix',
  23. 'thumb': 'http://i.imgur.com/D3KPxZC.png',
  24. 'video': 'https://fpdl.vimeocdn.com/vimeo-prod-skyfire-std-us/01/4055/5/145277671/438415327.mp4?token=56ee0771_0x0f9ffe25f9bb2e01cc93c125ec280ca9851143ac',
  25. 'genre': 'Formula E'},
  26. {'name': 'Punta del Este ePrix',
  27. 'thumb': 'http://i.imgur.com/D3KPxZC.png',
  28. 'video': 'https://fpdl.vimeocdn.com/vimeo-prod-skyfire-std-us/01/4959/5/149798140/457791125.mp4?token=56eddddb_0x3162cda754728bf7cd2906eb88d45854e2399b21',
  29. 'genre': 'Formula E'},
  30. {'name': 'Buenos Aires ePrix',
  31. 'thumb': 'http://i.imgur.com/D3KPxZC.png',
  32. 'video': 'https://fpdl.vimeocdn.com/vimeo-prod-skyfire-std-us/01/881/6/154405347/477062259.mp4?token=56eddf7b_0x82a460317bc35ae4278c2695a581772a10be44d4',
  33. 'genre': 'Formula E'},
  34. {'name': 'Mexico ePrix',
  35. 'thumb': 'http://i.imgur.com/D3KPxZC.png',
  36. 'video': 'https://fpdl.vimeocdn.com/vimeo-prod-skyfire-std-us/01/1746/6/158733095/496255968.mp4?token=56eddb4a_0xd4571e7c7d4d08914202b43f831fdbd17a559e00',
  37. 'genre': 'Formula E'}
  38. ]}
  39.  
  40.  
  41. def get_categories():
  42.  
  43. return VIDEOS.keys()
  44.  
  45. def get_videos(category):
  46.  
  47. return VIDEOS[category]
  48.  
  49. def list_categories():
  50. # Get video categories
  51. categories = get_categories()
  52. # Create a list for our items
  53. listing = []
  54. # Iterate through categories
  55. for category in categories:
  56. # Create a list item with a text label and a thumbnail image.
  57. list_item = xbmcgui.ListItem(label=category, thumbnailImage=VIDEOS[category][0]['thumb'])
  58. list_item.setArt({'thumb': VIDEOS[category][0]['thumb'],
  59. 'icon': VIDEOS[category][0]['thumb'],
  60. 'fanart': VIDEOS[category][0]['thumb']})
  61. list_item.setInfo('video', {'title': category, 'genre': category})
  62. url = '{0}?action=listing&category={1}'.format(_url, category)
  63. is_folder = True
  64. listing.append((url, list_item, is_folder))
  65. xbmcplugin.addDirectoryItems(_handle, listing, len(listing))
  66. xbmcplugin.addSortMethod(_handle, xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE)
  67. xbmcplugin.endOfDirectory(_handle)
  68.  
  69. def list_videos(category):
  70. videos = get_videos(category)
  71. listing = []
  72. for video in videos:
  73. list_item = xbmcgui.ListItem(label=video['name'])
  74. list_item.setInfo('video', {'title': video['name'], 'genre': video['genre']})
  75. list_item.setArt({'video':video['thumb'], 'icon': video['thumb'], 'fanart':video['thumb']})
  76. list_item.setProperty('IsPlayable', 'true')
  77. url = '{0}?action=play&video={1}'.format(_url, video['video'])
  78. is_folder = False
  79. listing.append((url, list_item, is_folder))
  80. xbmcplugin.addDirectoryItems(_handle, listing, len(listing))
  81. xbmcplugin.addSortMethod(_handle, xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE)
  82. xbmcplugin.endOfDirectory(_handle)
  83.  
  84. def play_video
  85. play_item = xbmcgui.ListItem(path=path)
  86. xbmcplugin.setResolvedUrl(_handle, True, listitem=play_item)
  87.  
  88. def router(paramstring)
  89. params = dict(parse_qsl(paramstring))
  90. if params:
  91. if params['action'] == 'listing':
  92. list_videos(params['category'])
  93. elif params['action'] == 'play':
  94. play_video(params['video'])
  95. else:
  96. list_categories()
  97.  
  98. if __name__ = '__main__'
  99. router(sys.argv[2][1:])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement