def _getShowsPage(self, Page, Items): shows = Util.getResponseJson( 'http://it.dplay.com/api/v2/ajax/modules?items={0}&page_id=32&module_id=26&page={1}' .format(Items, Page)) if shows.isSucceeded: for show in shows.body['data']: episodes = 0 for ti in show['taxonomy_items']: if ti['type'] == 'show': episodes = ti['metadata']['episodes'] break # Stops "for ti in show['taxonomy_items']:". title = Util.getTranslation(30009).format(show=show['title'], number=episodes) img = show['image_data'] li = Util.createListItem(title, thumbnailImage=self._getImage(img), streamtype='video', infolabels={ 'title': title, 'plot': show['description'] }) xbmcplugin.addDirectoryItem( self._handle, Util.formatUrl({ 'action': 's', 'showid': show['id'] }), li, True) pages = shows.body['total_pages'] if Page < pages - 1: self._getShowsPage(Page + 1, Items) else: xbmcplugin.endOfDirectory(self._handle)
def _getShowsPage(self, Page, Items): shows = Util.getResponseJson( "http://it.dplay.com/api/v2/ajax/modules?items={0}&page_id=32&module_id=26&page={1}".format(Items, Page) ) if shows.isSucceeded: for show in shows.body["data"]: episodes = 0 for ti in show["taxonomy_items"]: if ti["type"] == "show": episodes = ti["metadata"]["episodes"] break # Stops "for ti in show['taxonomy_items']:". title = Util.getTranslation(30009).format(show=show["title"], number=episodes) img = show["image_data"] li = Util.createListItem( title, thumbnailImage=self._getImage(img), streamtype="video", infolabels={"title": title, "plot": show["description"]}, ) xbmcplugin.addDirectoryItem( self._handle, Util.formatUrl({"action": "s", "showid": show["id"]}), li, True ) pages = shows.body["total_pages"] if Page < pages - 1: self._getShowsPage(Page + 1, Items) else: xbmcplugin.endOfDirectory(self._handle)
def _getEpisodes(self, showId, seasonId): url = 'http://it.dplay.com/api/v2/ajax/shows/{0}/seasons/{1}?show_id={0}&items=50&sort=episode_number_asc&video_types=-clip&season_id={1}'.format( showId, seasonId) episodes = Util.getResponseJson(url) if episodes.isSucceeded: for episode in episodes.body['data']: if episode['title'].lower().find('episodio') > -1: title = episode['title'] else: title = Util.getTranslation(30011).format( episode=episode['title'], number=episode['episode']) img = episode['image_data'] desc = episode['description'] or episode[ 'video_metadata_longDescription'] time = self._getDuration(int(episode['video_metadata_length'])) li = Util.createListItem(title, thumbnailImage=self._getImage(img), streamtype='video', infolabels={ 'title': title, 'plot': desc }, duration=time, isPlayable=True) xbmcplugin.addDirectoryItem( self._handle, Util.formatUrl({ 'action': 'v', 'url': episode['hls'] }), li) xbmcplugin.endOfDirectory(self._handle)
def _getEpisodes(self, showId, seasonId): url = 'http://it.dplay.com/api/v2/ajax/shows/{0}/seasons/{1}?show_id={0}&items=50&sort=episode_number_asc&video_types=-clip&season_id={1}'.format(showId, seasonId) episodes = Util.getResponseJson(url) if episodes.isSucceeded: for episode in episodes.body['data']: if episode['title'].lower().find('episodio') > -1: title = episode['title'] else: title = Util.getTranslation(30011).format(episode = episode['title'], number = episode['episode']) img = episode['image_data'] desc = episode['description'] or episode['video_metadata_longDescription'] time = self._getDuration(int(episode['video_metadata_length'])) li = Util.createListItem(title, thumbnailImage = self._getImage(img), streamtype = 'video', infolabels = { 'title' : title, 'plot' : desc }, duration = time, isPlayable = True) xbmcplugin.addDirectoryItem(self._handle, Util.formatUrl({ 'action' : 'v', 'url' : episode['hls'] }), li) xbmcplugin.endOfDirectory(self._handle)
def _getEpisodes(self, showId, seasonId): url = "http://it.dplay.com/api/v2/ajax/shows/{0}/seasons/{1}?show_id={0}&items=50&sort=episode_number_asc&video_types=-clip&season_id={1}".format( showId, seasonId ) episodes = Util.getResponseJson(url) if episodes.isSucceeded: for episode in episodes.body["data"]: if episode["title"].lower().find("episodio") > -1: title = episode["title"] else: title = Util.getTranslation(30011).format(episode=episode["title"], number=episode["episode"]) img = episode["image_data"] desc = episode["description"] or episode["video_metadata_longDescription"] time = self._getDuration(int(episode["video_metadata_length"])) li = Util.createListItem( title, thumbnailImage=self._getImage(img), streamtype="video", infolabels={"title": title, "plot": desc}, duration=time, isPlayable=True, ) xbmcplugin.addDirectoryItem(self._handle, Util.formatUrl({"action": "v", "url": episode["hls"]}), li) xbmcplugin.endOfDirectory(self._handle)
def __init__(self): # Shows. if len(self._params) == 0: self._getShowsPage(0, xbmcplugin.getSetting(self._handle, "items_per_page")) # Seasons. elif self._params["action"] == "s": headers = {"User-Agent": "Dalvik/2.1.0 (Linux; U; Android 5.1.1; D6503 Build/23.4.A.0.546)"} url = "http://it.dplay.com/api/v1/content/device/shows/{0}/seasons?realm=DPLAYIT&appVersion=2.0.0&platform=ANDROID&platformVersion=5.1.1".format( self._params["showid"] ) seasons = Util.getResponseJson(url, headers) if seasons.isSucceeded: if xbmcplugin.getSetting(self._handle, "show_seasons") == "false" or len(seasons.body["data"]) > 1: for season in seasons.body["data"]: title = Util.getTranslation(30010).format( season=season["name"], numberof=season["episodes_available"], numbertot=season["episodes_total"], ) li = Util.createListItem( title, thumbnailImage="DefaultFolder.png", streamtype="video", infolabels={"title": title} ) xbmcplugin.addDirectoryItem( self._handle, Util.formatUrl({"action": "e", "showid": self._params["showid"], "seasonid": season["id"]}), li, True, ) xbmcplugin.endOfDirectory(self._handle) else: self._getEpisodes(self._params["showid"], seasons.body["data"][0]["id"]) # Episodes. elif self._params["action"] == "e": self._getEpisodes(self._params["showid"], self._params["seasonid"]) # Play video. elif self._params["action"] == "v": stream = Util.getResponseForRegEx(self._params["url"]) if stream.isSucceeded: qlySetting = xbmcplugin.getSetting(self._handle, "vid_quality") if qlySetting == "0": qlySetting = 180 elif qlySetting == "1": qlySetting = 270 elif qlySetting == "2": qlySetting = 360 elif qlySetting == "3": qlySetting = 432 elif qlySetting == "4": qlySetting = 576 elif qlySetting == "5": qlySetting = 720 elif qlySetting == "6": qlySetting = 1080 urls = re.findall('RESOLUTION=.+?x(.+?),CODECS=".+?"(.+?)#', stream.body) items = [] for qly, url in urls: items.append((abs(qlySetting - int(qly)), url)) items = sorted(items, key=lambda item: item[0]) Util.playStream(self._handle, "", path=items[0][1])
def __init__(self): if len(self._params) == 0: # Scelta tra Audio o Video Util.createAudioVideoItems(self._handle) # Show items. xbmcplugin.endOfDirectory(self._handle) elif len(self._params) == 1 and self._params['content_type'] == 'video': # Visualizzazione del menu video. # Menu. response = Util.getResponseBS('http://tv.ilfattoquotidiano.it') if response.isSucceeded: menuItems = [] for ul in response.body.findAll('ul', 'nav-list'): for li in ul.findAll('li'): title = li.a.text link = li.a['href'] li = Util.createListItem(title) menuItems.append(( li, link, title )) div = response.body.find('div', 'submenu-categories') for li in div.findAll('li'): link = li.a['href'] found = False for item in menuItems: if item[1] == link: found = True break if not found: title = li.a.text li = Util.createListItem(title) menuItems.append(( li, link, title )) for item in sorted(menuItems, key = lambda item: item[2]): xbmcplugin.addDirectoryItem(self._handle, Util.formatUrl({ 'id' : 'c', 'page' : item[1] }), item[0], True) # Show items. xbmcplugin.endOfDirectory(self._handle) elif len(self._params) == 1 and self._params['content_type'] == 'audio': # Visualizzazione del menu audio. img = '{0}/resources/images/fqRadio.png'.format(os.path.dirname(os.path.abspath(__file__))) li = Util.createListItem(Util.getTranslation(30000), thumbnailImage = img) # Radio. xbmcplugin.addDirectoryItem(self._handle, 'http://fqradio.ns0.it:8000/;audio.mp3', li, False) xbmcplugin.addDirectoryItem(self._handle, Util.formatUrl({ 'id' : 'p', 'page' : self._getUrlPodcast() }), Util.createListItem(Util.getTranslation(30001), thumbnailImage = 'DefaultAddonLyrics.png'), True) # Show items. xbmcplugin.endOfDirectory(self._handle) else: response = Util.getResponseBS(self._params['page']) if response.isSucceeded: # Videos. if self._params['id'] == 'c': # Visualizzazione video di una categoria. videos = response.body.findAll('section', 'article-preview') for video in videos: divTitle = video.find('div', 'article-wrapper') title = divTitle.h3.a.text img = None if video.picture.img != None: img = video.picture.img['src'] li = Util.createListItem(title, thumbnailImage = img, streamtype = 'video', infolabels = { 'title' : title }, isPlayable = True) xbmcplugin.addDirectoryItem(self._handle, Util.formatUrl({ 'id' : 'v', 'page' : divTitle.h3.a['href'] }), li, False) # Next page. self._nextPage(response.body, 'c', '{0}') # Show items. xbmcplugin.endOfDirectory(self._handle) # Podcast. if self._params['id'] == 'p': # Visualizzazione podcast. podcasts = response.body.find('section', 'fqRadio fqRadio-palinsesto') podcasts = podcasts.findAll('div', 'ungrid-row') for podcast in podcasts: title = u'{0} ({1})'.format(podcast.find('div', 'ungrid-col program').a.text, podcast.find('div', 'ungrid-col program-date').text) url = podcast.find('div', 'ungrid-col dwl-podcast').a['href'] li = Util.createListItem(title, thumbnailImage = 'DefaultAudio.png', streamtype = 'audio', infolabels = { 'title' : title }) xbmcplugin.addDirectoryItem(self._handle, url, li, False) # Next page. self._nextPage(response.body, 'p', '{0}/{1}'.format(self._getUrlPodcast(), '{0}')) # Show items. xbmcplugin.endOfDirectory(self._handle) # Play video. elif self._params['id'] == 'v': title = response.body.find('meta', { 'property' : 'og:title' })['content'] img = response.body.find('meta', { 'property' : 'og:image' })['content'] descr = response.body.find('div', 'tv-desc-body').text # Video del fatto. video = response.body.find('video', { 'id' : 'bcPlayer' }) if video != None: #playerID = 2274739660001 #publisherID = 1328010481001 url = 'https://edge.api.brightcove.com/playback/v1/accounts/{0}/videos/{1}'.format(video['data-account'], video['data-video-id']) headers = { 'Accept' : 'application/json;pk=BCpkADawqM0xNxj2Rs11iwmFoNJoG2nXUQs67brI7oR2qm0Dwn__kPcbvLJb7M34IY2ar-WxWvi8wHr6cRbP7nmgilWaDrqZEeQm4O5K6z6B2A3afiPFbv7T4LcsQKN2PqIIgIIr3AXq43vL' } response = Util.getResponseJson(url, headers) if response.isSucceeded: sources = sorted(response.body['sources'], key = lambda item: item['avg_bitrate'] if 'avg_bitrate' in item else 0, reverse = True) if 'src' in sources[0]: source = sources[0]['src'] else: source = sources[1]['src'] Util.playStream(self._handle, title, img, source, 'video', { 'title' : title, 'plot' : descr }) # Altri video. else: responseString = response.body.renderContents() # Video di youtube. if responseString.find('www.youtube.com/embed') > -1: video = re.search('http://www.youtube.com/embed/(.+?)\?', response.body.find('iframe')['src']) if video != None: Util.playStream(self._handle, title, img, 'plugin://plugin.video.youtube/play/?video_id={0}'.format(video.group(1)), 'video', { 'title' : title, 'plot' : descr }) # Video servizio pubblico. elif responseString.find('meride-video-container') > -1: params = { 'id' : 'e', 'page' : self._params['page'], 'title' : title, 'img' : img, 'descr' : descr } url = Util.formatUrl(params, 'plugin://plugin.video.serviziopubblico/') Util.playStream(self._handle, title, img, url, 'video', { 'title' : title, 'plot' : descr }) # Video non gestito. else: Util.showVideoNotAvailableDialog()
def __init__(self): # Shows. if len(self._params) == 0: self._getShowsPage( 0, xbmcplugin.getSetting(self._handle, 'items_per_page')) # Seasons. elif self._params['action'] == 's': headers = { 'User-Agent': 'Dalvik/2.1.0 (Linux; U; Android 5.1.1; D6503 Build/23.4.A.0.546)' } url = 'http://it.dplay.com/api/v1/content/device/shows/{0}/seasons?realm=DPLAYIT&appVersion=2.0.0&platform=ANDROID&platformVersion=5.1.1'.format( self._params['showid']) seasons = Util.getResponseJson(url, headers) if seasons.isSucceeded: if xbmcplugin.getSetting(self._handle, 'show_seasons') == 'false' or len( seasons.body['data']) > 1: for season in seasons.body['data']: title = Util.getTranslation(30010).format( season=season['name'], numberof=season['episodes_available'], numbertot=season['episodes_total']) li = Util.createListItem( title, thumbnailImage='DefaultFolder.png', streamtype='video', infolabels={'title': title}) xbmcplugin.addDirectoryItem( self._handle, Util.formatUrl({ 'action': 'e', 'showid': self._params['showid'], 'seasonid': season['id'] }), li, True) xbmcplugin.endOfDirectory(self._handle) else: self._getEpisodes(self._params['showid'], seasons.body['data'][0]['id']) # Episodes. elif self._params['action'] == 'e': self._getEpisodes(self._params['showid'], self._params['seasonid']) # Play video. elif self._params['action'] == 'v': stream = Util.getResponseForRegEx(self._params['url']) if stream.isSucceeded: qlySetting = xbmcplugin.getSetting(self._handle, 'vid_quality') if qlySetting == '0': qlySetting = 180 elif qlySetting == '1': qlySetting = 270 elif qlySetting == '2': qlySetting = 360 elif qlySetting == '3': qlySetting = 432 elif qlySetting == '4': qlySetting = 576 elif qlySetting == '5': qlySetting = 720 elif qlySetting == '6': qlySetting = 1080 urls = re.findall('RESOLUTION=.+?x(.+?),CODECS=".+?"(.+?)#', stream.body) items = [] for qly, url in urls: items.append((abs(qlySetting - int(qly)), url)) items = sorted(items, key=lambda item: item[0]) Util.playStream(self._handle, '', path=items[0][1])
def __init__(self): # Shows. if len(self._params) == 0: shows = Util.getResponseJson('http://it.dplay.com/api/v2/ajax/modules?items=1000&page_id=32&module_id=26') if shows.isSucceeded: for show in shows.body['data']: episodes = 0 for ti in show['taxonomy_items']: if ti['type'] == 'show': episodes = ti['metadata']['episodes'] break # Stops "for ti in show['taxonomy_items']:". title = Util.getTranslation(30009).format(show = show['title'], number = episodes) img = show['image_data'] li = Util.createListItem(title, thumbnailImage = self._getImage(img), streamtype = 'video', infolabels = { 'title' : title, 'plot' : show['description'] }) xbmcplugin.addDirectoryItem(self._handle, Util.formatUrl({ 'action' : 's', 'showid' : show['id'] }), li, True) xbmcplugin.endOfDirectory(self._handle) # Seasons. elif self._params['action'] == 's': headers = { 'User-Agent' : 'Dalvik/2.1.0 (Linux; U; Android 5.1.1; D6503 Build/23.4.A.0.546)' } url = 'http://it.dplay.com/api/v1/content/device/shows/{0}/seasons?realm=DPLAYIT&appVersion=2.0.0&platform=ANDROID&platformVersion=5.1.1'.format(self._params['showid']) seasons = Util.getResponseJson(url, headers) if seasons.isSucceeded: if xbmcplugin.getSetting(self._handle, 'show_seasons') == 'false' or len(seasons.body['data']) > 1: for season in seasons.body['data']: title = Util.getTranslation(30010).format(season = season['name'], numberof = season['episodes_available'], numbertot = season['episodes_total']) li = Util.createListItem(title, thumbnailImage = 'DefaultFolder.png', streamtype = 'video', infolabels = { 'title' : title }) xbmcplugin.addDirectoryItem(self._handle, Util.formatUrl({ 'action' : 'e', 'showid' : self._params['showid'], 'seasonid' : season['id'] }), li, True) xbmcplugin.endOfDirectory(self._handle) else: self._getEpisodes(self._params['showid'], seasons.body['data'][0]['id']) # Episodes. elif self._params['action'] == 'e': self._getEpisodes(self._params['showid'], self._params['seasonid']) # Play video. elif self._params['action'] == 'v': stream = Util.getResponseForRegEx(self._params['url']) if stream.isSucceeded: qlySetting = xbmcplugin.getSetting(self._handle, 'vid_quality') if qlySetting == '0': qlySetting = 180 elif qlySetting == '1': qlySetting = 270 elif qlySetting == '2': qlySetting = 360 elif qlySetting == '3': qlySetting = 432 elif qlySetting == '4': qlySetting = 576 elif qlySetting == '5': qlySetting = 720 elif qlySetting == '6': qlySetting = 1080 urls = re.findall('RESOLUTION=.+?x(.+?),CODECS=".+?"(.+?)#', stream.body) items = [] for qly, url in urls: items.append(( abs(qlySetting - int(qly)), url )) items = sorted(items, key = lambda item: item[0]) Util.playStream(self._handle, '', path = items[0][1])