Advertisement
Guest User

plugin.video.r4e

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