Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- # Module: default
- # Author: Stroopwafel
- # Created on 19-03-2016
- # License: GPL v.3 https://www.gnu.org/copyleft/gpl.html
- import sys
- import urlparse
- from urlparse import parse_qsl
- import xbmcgui
- import xbmcplugin
- # Get the plugin url in plugin:// notation.
- _url = sys.argv[0]
- # Get the plugin handle an an integer number.
- _handle = int(sys.argv[1])
- # Define categories and videos:
- VIDEOS = {'Formula_E': [{'name': 'Being ePrix',
- 'thumb': 'http://i.imgur.com/D3KPxZC.png',
- 'video': 'https://fpdl.vimeocdn.com/vimeo-prod-skyfire-std-us/01/3702/5/143512140/431745863.mp4?token=56ee2293_0xcd6ca3c59947c169560a646f765a83a30ce51fdc',
- 'genre': 'Formula E'},
- {'name': 'Putajaya ePrix',
- 'thumb': 'http://i.imgur.com/D3KPxZC.png',
- 'video': 'https://fpdl.vimeocdn.com/vimeo-prod-skyfire-std-us/01/4055/5/145277671/438415327.mp4?token=56ee0771_0x0f9ffe25f9bb2e01cc93c125ec280ca9851143ac',
- 'genre': 'Formula E'},
- {'name': 'Punta del Este ePrix',
- 'thumb': 'http://i.imgur.com/D3KPxZC.png',
- 'video': 'https://fpdl.vimeocdn.com/vimeo-prod-skyfire-std-us/01/4959/5/149798140/457791125.mp4?token=56eddddb_0x3162cda754728bf7cd2906eb88d45854e2399b21',
- 'genre': 'Formula E'},
- {'name': 'Buenos Aires ePrix',
- 'thumb': 'http://i.imgur.com/D3KPxZC.png',
- 'video': 'https://fpdl.vimeocdn.com/vimeo-prod-skyfire-std-us/01/881/6/154405347/477062259.mp4?token=56eddf7b_0x82a460317bc35ae4278c2695a581772a10be44d4',
- 'genre': 'Formula E'},
- {'name': 'Mexico ePrix',
- 'thumb': 'http://i.imgur.com/D3KPxZC.png',
- 'video': 'https://fpdl.vimeocdn.com/vimeo-prod-skyfire-std-us/01/1746/6/158733095/496255968.mp4?token=56eddb4a_0xd4571e7c7d4d08914202b43f831fdbd17a559e00',
- 'genre': 'Formula E'}
- ]}
- def get_categories():
- return VIDEOS.keys()
- def get_videos(category):
- return VIDEOS[category]
- def list_categories():
- # Get video categories
- categories = get_categories()
- # Create a list for our items
- listing = []
- # Iterate through categories
- for category in categories:
- # Create a list item with a text label and a thumbnail image.
- list_item = xbmcgui.ListItem(label=category, thumbnailImage=VIDEOS[category][0]['thumb'])
- list_item.setArt({'thumb': VIDEOS[category][0]['thumb'],
- 'icon': VIDEOS[category][0]['thumb'],
- 'fanart': VIDEOS[category][0]['thumb']})
- list_item.setInfo('video', {'title': category, 'genre': category})
- url = '{0}?action=listing&category={1}'.format(_url, category)
- is_folder = True
- listing.append((url, list_item, is_folder))
- xbmcplugin.addDirectoryItems(_handle, listing, len(listing))
- xbmcplugin.addSortMethod(_handle, xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE)
- xbmcplugin.endOfDirectory(_handle)
- def list_videos(category):
- videos = get_videos(category)
- listing = []
- for video in videos:
- list_item = xbmcgui.ListItem(label=video['name'])
- list_item.setInfo('video', {'title': video['name'], 'genre': video['genre']})
- list_item.setArt({'video':video['thumb'], 'icon': video['thumb'], 'fanart':video['thumb']})
- list_item.setProperty('IsPlayable', 'true')
- url = '{0}?action=play&video={1}'.format(_url, video['video'])
- is_folder = False
- listing.append((url, list_item, is_folder))
- xbmcplugin.addDirectoryItems(_handle, listing, len(listing))
- xbmcplugin.addSortMethod(_handle, xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE)
- xbmcplugin.endOfDirectory(_handle)
- def play_video(path):
- play_item = xbmcgui.ListItem(path=path)
- xbmcplugin.setResolvedUrl(_handle, True, listitem=play_item)
- def router(paramstring):
- params = dict(parse_qsl(paramstring))
- if params:
- if params['action'] == 'listing':
- list_videos(params['category'])
- elif params['action'] == 'play':
- play_video(params['video'])
- else:
- list_categories()
- if __name__ == '__main__':
- router(sys.argv[2][1:])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement