def _getVideoInfo(self, video, time_zone = None): title = u'{0} ({1} {2} - {3} {4})'.format(video['name'], nw.getTranslation(30011), video['seasonNumber'], nw.getTranslation(30012), video['episodeNumber']) descr = video['description'] if 'publishEnd' in video: if time_zone == None: time_zone = nw.gettzlocal() date = nw.strptime(video['publishEnd'], '%Y-%m-%dT%H:%M:%SZ') date = date.replace(tzinfo = nw.gettz('UTC')) date = date.astimezone(time_zone) descr = u'{0}\n\n{1} {2}'.format(descr, nw.getTranslation(30013), date.strftime(nw.datetime_format)) plus = False if 'packages' in video: descr = descr + "\n" + nw.getTranslation(30015) + ":" # cambiare stringa for p in video['packages']: if p == "Premium" : pp = "Dplay plus" plus = True title = title + " (PLUS)" else: pp = p descr = descr + " " + pp # aggiungere immagini return { 'img' : '' , 'title' : title, 'descr' : descr , 'plus' : plus}
def _getVideoInfo(self, video, time_zone = None): title = u'{0} ({1} {2} - {3} {4})'.format(video['Name'], nw.getTranslation(30011), video['SeasonNumber'], nw.getTranslation(30012), video['EpisodeNumber']) descr = video['Description'] if video['PublishEndDate'] != None: if time_zone == None: time_zone = nw.gettzlocal() date = nw.strptime(video['PublishEndDate'], '%Y-%m-%dT%H:%M:%SZ') date = date.replace(tzinfo = nw.gettz('UTC')) date = date.astimezone(time_zone) descr = u'{0}\n\n{1} {2}'.format(descr, nw.getTranslation(30013), date.strftime(nw.datetime_format)) return { 'img' : video['Images'][0]['Src'], 'title' : title, 'descr' : descr }
def _getShowsPage(self, url, page, hide_show_no_ep, channel): shows = nw.getResponseJson(url.format(page)) if shows.isSucceeded: for show in shows.body['data']: episodes = 0 channel_id = 0 for ti in show['taxonomy_items']: if ti['type'] == 'show': episodes = ti['metadata']['episodes'] elif ti['type'] == 'home-channel': channel_id = ti['term_id'] if hide_show_no_ep == 'false' or episodes != '0': title = nw.getTranslation(30015).format(show = show['title'], number = episodes) img = show['image_data'] self._addItem(title, { 'action' : 's', 'showid' : show['id'], 'channel' : channel_id }, self._getUrlImgPreview(img), self._findFanart(channel_id), show['description']) pages = shows.body['total_pages'] page = int(page) if page < pages - 1: if xbmcplugin.getSetting(self._handle, 'use_pagination') == 'true': if channel != None: nw.createNextPageItem(self._handle, page + 2, { 'action' : 'p', 'page' : page + 1, 'channel' : channel }) else: nw.createNextPageItem(self._handle, page + 2, { 'action' : 'p', 'page' : page + 1 }) xbmcplugin.endOfDirectory(self._handle) else: self._getShowsPage(url, page + 1, hide_show_no_ep, channel) else: xbmcplugin.endOfDirectory(self._handle)
def __init__(self): fanart = nw.addon.getAddonInfo('fanart') if len(self._params) == 0: response = self._getResponseJson(None) if response.isSucceeded: #~ for menu in response.body['Menu']: #~ if menu['Url'] == None: #~ self._addItem(menu['Label'], { 'at' : self._access_token, 'action' : 'm', 'value' : re.sub('\s+', '', menu['Label']) }, fanart = fanart) #~ xbmcplugin.endOfDirectory(self._handle) response = self._getResponseJson('http://dplayproxy.azurewebsites.net//api/Show/GetList') for show in response.body: self._addItem(show['Name'], { 'at' : self._access_token, 'action' : 's', 'value' : show['Id'] }, show['Images'][0]['Src'], fanart, show['Description']) xbmcplugin.endOfDirectory(self._handle) else: self._access_token = self._params['at'] if self._params['action'] == 's': response = self._getResponseJson('http://dplayproxy.azurewebsites.net/api/Show/GetById/?id={0}'.format(self._params['value'])) if response.isSucceeded: if len(response.body['Sections']) > 0: fanart = response.body['Images'][0]['Src'] time_zone = nw.gettzlocal() haveFFmpeg = os.path.isfile(nw.addon.getSetting('ffmpeg_path')) and os.path.isdir(nw.addon.getSetting('download_path')) for video in response.body['Sections'][0]['Items']: season_number = video['SeasonNumber'] for video in video['Episodes']: vd = self._getVideoInfo(video, time_zone) cm = None params = { 'at' : self._access_token, 'action' : 'd', 'value' : video['Id'] } if haveFFmpeg: cm = nw.getDownloadContextMenu('RunPlugin({0})'.format(nw.formatUrl(params)), vd['title']) params['action'] = 'v' self._addItem(vd['title'], params, vd['img'], fanart, vd['descr'], self._getDuration(video['Duration']), True, cm) xbmcplugin.endOfDirectory(self._handle) else: nw.showNotification(nw.getTranslation(30014)) elif self._params['action'] == 'v': result = self._getStream(self._params['value']) if not result: nw.showVideoNotAvailable() else: nw.playStream(self._handle, result['title'], result['img'], result['url'], 'video', { 'title' : result['title'], 'plot' : result['descr'] }) elif self._params['action'] == 'd': result = self._getStream(self._params['value']) if not result: nw.showVideoNotAvailable() else: name = ''.join([i if ord(i) < 128 else '' for i in result['title'].replace(' ', '_')]) name = '{0}.ts'.format(name) os.chdir(nw.addon.getSetting('download_path')) #~ subprocess.call([nw.addon.getSetting('ffmpeg_path'), '-i', result['url'], '-c', 'copy', name]) subprocess.Popen([nw.addon.getSetting('ffmpeg_path'), '-i', result['url'], '-c', 'copy', name])
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 = nw.getResponseJson(url) if episodes.isSucceeded: for episode in episodes.body['data']: if episode['title'].lower().find('episodio') > -1: title = episode['title'] else: title = nw.getTranslation(30017).format(episode = episode['title'], number = episode['episode']) fanart = None for ti in episode['taxonomy_items']: if ti['type'] == 'home-channel': fanart = self._findFanart(ti['term_id']) break # Stops "for ti in show['taxonomy_items']:". img = episode['image_data'] desc = episode['description'] or episode['video_metadata_longDescription'] time = self._getDuration(int(episode['video_metadata_length'])) self._addItem(title, { 'action' : 'v', 'url' : episode['hls'] }, self._getUrlImgPreview(img), fanart, desc, time, True) xbmcplugin.endOfDirectory(self._handle)
def __init__(self): fanart = nw.addon.getAddonInfo('fanart') if len(self._params) == 0: response = self._getResponseJson(None) if response.isSucceeded: response = self._getResponseJson('https://eu2-prod.disco-api.com/content/shows?sort=name&page[size]=100&include=images', self._getHeaders(True)) pages = response.body["meta"]["totalPages"] for p in range(1,pages+1): response = self._getResponseJson('https://eu2-prod.disco-api.com/content/shows?sort=name&page[size]=100&include=images&page[number]={0}'.format(p), self._getHeaders(True)) imgList = self.loadImagesFromJson(response.body["included"]) for show in response.body['data']: attr = show["attributes"] desc = attr['description'] if 'description' in attr else '' title = attr['name'] rel = show.get("relationships",{}) plus = False try: packages = rel["contentPackages"]["data"] for p in packages: if p.get("id","") == "Premium" : pp = "Dplay plus" plus = True title = title + " (PLUS)" else: pp = p except: pass images = rel.get("images",[]) if images: icon_code = images["data"][0]["id"] if icon_code in imgList: icon = imgList[icon_code] else: icon = "" else: icon = "" self._addItem(title, { 'at' : self._access_token, 'action' : 's', 'value' : show['id'] }, icon , fanart, desc) xbmcplugin.endOfDirectory(self._handle) else: self._access_token = self._params['at'] if self._params['action'] == 's': url = 'https://eu2-prod.disco-api.com/content/videos?filter[show.id]={0}&page[size]=100&include=images&sort=seasonNumber,episodeNumber&filter[videoType]=EPISODE'.format(self._params['value']) xbmc.log("Dplay. OPEN URL: %s" % url) response = self._getResponseJson(url, self._getHeaders(True)) if response.isSucceeded: #if len(response.body['Sections']) > 0: # fanart = response.body['Images'][0]['Src'] fanart = "" # da aggiustare time_zone = nw.gettzlocal() haveFFmpeg = os.path.isfile(nw.addon.getSetting('ffmpeg_path')) and os.path.isdir(nw.addon.getSetting('download_path')) xbmc.log("Dplay. start reading images") imgList = self.loadImagesFromJson(response.body["included"]) xbmc.log("Dplay. end reading images") for video in response.body["data"]: attr = video["attributes"] season_number = attr.get("seasonNumber", 0) episode_number = attr.get("episodeNumber",0) vd = self._getVideoInfo(attr, time_zone) rel = video.get("relationships",{}) images = rel.get("images",[]) if images: icon_code = images["data"][0]["id"] if icon_code in imgList: icon = imgList[icon_code] else: icon = "" else: icon = "" cm = nw.getDownloadContextMenu('RunPlugin({0})'.format(nw.formatUrl(params)), vd['title']) if haveFFmpeg else None params = { 'at' : self._access_token, 'action' : 'v', 'value' : video['id'] } #'v' instead of 'd' #params['action'] = 'v' self._addItem(vd['title'], params, icon, icon, vd['descr'], self._getDuration(attr["videoDuration"]), True, cm) xbmcplugin.setContent(self._handle, 'episodes') xbmcplugin.endOfDirectory(self._handle) else: nw.showNotification(nw.getTranslation(30014)) elif self._params['action'] == 'v': result = self._getStream(self._params['value']) if not result: nw.showVideoNotAvailable() else: # Force XBMC to set the User-Agent HTTP header to the correct value result_url = result['url'] + "|User-Agent=%s" % Dplay.USER_AGENT nw.playStream(self._handle, result['title'], result['img'], result_url, 'video', { 'title' : result['title'], 'plot' : result['descr'] }) elif self._params['action'] == 'd': result = self._getStream(self._params['value']) if not result: nw.showVideoNotAvailable() else: name = ''.join([i if ord(i) < 128 else '' for i in result['title'].replace(' ', '_')]) name = '{0}.ts'.format(name) os.chdir(nw.addon.getSetting('download_path')) #~ subprocess.call([nw.addon.getSetting('ffmpeg_path'), '-i', result['url'], '-c', 'copy', name]) subprocess.Popen([nw.addon.getSetting('ffmpeg_path'), '-user-agent', Dplay.USER_AGENT, '-i', result['url'], '-c', 'copy', name])
def __init__(self): if len(self._params) == 0: # Visualizzazione del menu. # Shows. title = nw.getTranslation(30000) li = nw.createListItem(title, streamtype = 'video', infolabels = { 'title' : title }) xbmcplugin.addDirectoryItem(self._handle, nw.formatUrl({ 'id' : 'a', 'page' : self._getLaCosaUrl('archivio') }), li, True) shows = nw.getResponseBS(self._getLaCosaUrl('rubriche')) if shows.isSucceeded: shows = shows.body.findAll('div', 'icon_programmi') for show in shows: title = show.h3.a.text li = nw.createListItem(title, thumbnailImage = show.img['src'], streamtype = 'video', infolabels = { 'title' : title, 'plot' : show.p.text }) xbmcplugin.addDirectoryItem(self._handle, nw.formatUrl({ 'id' : 's', 'page' : show.a['href'] }), li, True) xbmcplugin.endOfDirectory(self._handle) if shows == None or not shows: nw.showNotification(nw.getTranslation(30001)) # Errore recupero shows. else: response = nw.getResponseBS(self._params['page']) if response.isSucceeded: # Archivio. if self._params['id'] == 'a': videos = response.body.find('div', id='video-recenti').findAll('div', 'video-block') for video in videos: title = re.search('<a title="(.+?)"', video.renderContents()) if title != None: title = nw.htmlDecode(title.group(1)) time = self._getTime(video) self._setEpItem(video, title, time) if len(videos) > 0: nextPage = response.body.find('span', 'current') nextPage = nextPage.findNext('a') if nextPage.get('class') and nextPage['class'] == 'page-numbers': nw.createNextPageItem(self._handle, nextPage.text, { 'id' : 'a', 'page' : nextPage['href'] }) xbmcplugin.endOfDirectory(self._handle) else: nw.showNotification(nw.getTranslation(30002)) # Errore recupero dei videos shows. # Videos. if self._params['id'] == 's': # Visualizzazione dei videos di uno show. videos = response.body.find('div', id='recenti_canale').findAll('li') for video in videos: title = video.h4.text time = self._getTime(video) self._setEpItem(video, title, time) if len(videos) > 0: xbmcplugin.endOfDirectory(self._handle) else: nw.showNotification(nw.getTranslation(30002)) # Errore recupero dei videos shows. # 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('meta', { 'property' : 'og:description' })['content'] streams = response.body.find('iframe') if streams != None: response = nw.getResponseForRegEx(streams['src']) found_stream = None if response.isSucceeded: streams = re.findall('mp4_[0-9]+":"(.*?)",', response.body) if not streams: streams = re.search('hd_src_no_ratelimit":"(.+?)"', response.body) found_stream = streams.group(1).replace('\/', '/') if streams == None: streams = re.search('sd_src_no_ratelimit":"(.+?)"', response.body) found_stream = streams.group(1).replace('\/', '/') if streams == None: streams = re.search('hd_src":"(.+?)"', response.body) found_stream = streams.group(1).replace('\/', '/') if streams == None: streams = re.search('sd_src":"(.+?)"', response.body) found_stream = streams.group(1).replace('\/', '/') if found_stream == None: for stream in reversed(streams): if stream != '': found_stream = stream break if found_stream is not None: nw.playStream(self._handle, title, img, found_stream, 'video', { 'title' : title, 'plot' : descr }) else: nw.showVideoNotAvailable() # Video non disponibile. else: nw.showVideoNotAvailable() # Video non disponibile.
def __init__(self): if len(self._params) == 0: # Scelta tra Audio o Video nw.createAudioVideoItems(self._handle) # Show items. xbmcplugin.endOfDirectory(self._handle) elif len(self._params) == 1 and self._params['content_type'] == 'video': # Visualizzazione del menu video (diretta e video). qlty = int(xbmcplugin.getSetting(self._handle, 'vid_quality')) + 1 streamParam = self._getStreamParam(qlty) if streamParam != None: response = self._getVirginResponse('/video') if response.isSucceeded: title = nw.getTranslation(30003) img = '{0}/resources/images/VirginRadioTV.png'.format(os.path.dirname(os.path.abspath(__file__))) li = nw.createListItem(title, thumbnailImage = img, streamtype = 'video', infolabels = { 'title' : title }) # Diretta. url = 'rtmp://{0}:1935/{1}/{2} app={1} playpath={2} swfUrl=http://video.virginradioitaly.it/com/universalmind/swf/video_player_102.swf?xmlPath=http://video.virginradioitaly.it/com/universalmind/tv/virgin/videoXML.xml&advXML=http://video.virginradioitaly.it/com/universalmind/adsWizzConfig/1.xml pageURL=http://www.virginradio.it swfVfy=true live=true timeout=30 flashVer=LNX 11,2,202,297'.format(streamParam[0], streamParam[1], streamParam[2]) xbmcplugin.addDirectoryItem(self._handle, url, li, False) videos = response.body.findAll('div', 'anteprima_articolo article_cont vrg_article_preview_tree_medium') for video in videos: title = video.a.img['title'] img = self._makeUrl(video.a.img['data-original']).replace('206/122', '600/315') descr = '' if video.h3 != None: descr = video.h3.a.text li = nw.createListItem(title, thumbnailImage = img, streamtype = 'video', infolabels = { 'title' : title, 'plot' : descr }, isPlayable = True) url = nw.formatUrl({ 'id' : 'v', 'page' : video.a['href'].replace('http://www.virginradio.it', '') }) xbmcplugin.addDirectoryItem(self._handle, url, li, False) nw.createNextPageItem(self._handle, 1, { 'id' : 'p', 'page' : 1 }) # Show items. xbmcplugin.endOfDirectory(self._handle) if (streamParam == None or not streamParam) and (response == None or not response or not response.isSucceeded): nw.showNotification(nw.getTranslation(30004)) elif len(self._params) == 1 and self._params['content_type'] == 'audio': # Visualizzazione delle web radio. response = self._getVirginResponse('/webradio') if response.isSucceeded: divs = response.body.findAll('div', { 'class' : re.compile('.+') }) for div in divs: if div['class'].find('overbox_vrg_article_preview_webradio') > -1: radios = div.findAll('div', 'anteprima_articolo article_cont') for radio in radios: title = self._webradioRe.sub('', radio.a.img['title']).strip() img = self._makeImageUrl(radio.a.img['data-original']) li = nw.createListItem(title, thumbnailImage = img, streamtype = 'music', infolabels = { 'title' : title }, isPlayable = True) url = nw.formatUrl({ 'id' : 'r', 'page' : radio.a['href'].replace('http://www.virginradio.it', '') }) xbmcplugin.addDirectoryItem(self._handle, url, li, False) elif div['class'].find('text_edit') > -1 and div['class'].find('vrg_box_title_webradio') > -1 and div['class'].find('last') > -1: break # Stops "for div in divs:". xbmcplugin.endOfDirectory(self._handle) elif self._params['id'] == 'p': response = self._getVirginResponse('/archivio/1099/video?sortElement=data_pubblicazione,true&page={0}'.format(self._params['page'])) if response.isSucceeded: videos = response.body.findAll('div', 'anteprima_ricerca_archivio vrg_archive_results VRG') for video in videos: title = video.a.img['title'] img = self._makeUrl(video.a.img['src']).replace('130/90', '600/315') descr = video.find('p', 'testo').a.text li = nw.createListItem(title, thumbnailImage = img, streamtype = 'video', infolabels = { 'title' : title, 'plot' : descr }, isPlayable = True) url = nw.formatUrl({ 'id' : 'v', 'page' : video.a['href'].replace('http://www.virginradio.it', '') }) xbmcplugin.addDirectoryItem(self._handle, url, li, False) if len(response.body.findAll('a', id='prossimi')) == 1: page = int(self._params['page']) + 1 nw.createNextPageItem(self._handle, page, { 'id' : 'p', 'page' : page }) xbmcplugin.endOfDirectory(self._handle) else: response = self._getVirginResponse(self._params['page']) if response.isSucceeded: # Riproduzione di un video. if 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('meta', { 'property' : 'og:description' })['content'] play = response.body.find('a', 'player plain') if play == None: play = response.body.find('div', 'multimedia video') play = re.search('embed/(.+?)\\"', play.renderContents()) if play == None: nw.showVideoNotAvailable() else: play = 'plugin://plugin.video.youtube/play/?video_id={0}'.format(play.group(1)) else: server = re.search('netConnectionUrl: "rtmp://(.+?)/(.+?)/', response.body.renderContents()) play = play['href'] play = re.search('(.+?):(.+)', play) play = 'rtmp://{0}:1935/{1}/{2} app={1} playpath={3}:{2} pageURL=http://www.virginradio.it swfVfy=true live=false flashVer=LNX 10,1,82,76'.format(server.group(1), server.group(2), play.group(2), play.group(1)) nw.playStream(self._handle, title, img, play, 'video', { 'title' : title, 'plot' : descr }) # Riproduzione di una radio. elif self._params['id'] == 'r': stream = re.search("radioUrl_AdsWizz='(.+?)'", response.body.renderContents()) if stream != None: title = self._webradioRe.sub('', response.body.find('meta', { 'property' : 'og:title' })['content']).strip() img = self._makeImageUrl(response.body.find('img', 'lazy')['data-original']) nw.playStream(self._handle, title, img, stream.group(1), 'music', { 'title' : title })
def __init__(self): # Audio, Video, Foto. if len(self._params) == 0: nw.createAudioVideoItems(self._handle, self._fanart) xbmcplugin.addDirectoryItem(self._handle, nw.formatUrl({ 'content_type' : 'image' }), nw.createListItem(nw.getTranslation(30005), thumbnailImage = 'DefaultPicture.png', fanart = self._fanart), True) xbmcplugin.endOfDirectory(self._handle) elif 'content_type' in self._params: # Video. if self._params['content_type'] == 'video': qlty = int(xbmcplugin.getSetting(self._handle, 'vid_quality')) + 1 streamParam = self._getStreamParam(qlty) if streamParam != None: title = nw.getTranslation(30003) img = '{0}/resources/images/VirginRadioTV.png'.format(os.path.dirname(os.path.abspath(__file__))) li = nw.createListItem(title, thumbnailImage = img, fanart = self._fanart, streamtype = 'video', infolabels = { 'title' : title }) # Diretta. url = 'rtmp://{0}:1935/{1}/{2} app={1} playpath={2} swfUrl=http://video.virginradioitaly.it/com/universalmind/swf/video_player_102.swf?xmlPath=http://video.virginradioitaly.it/com/universalmind/tv/virgin/videoXML.xml&advXML=http://video.virginradioitaly.it/com/universalmind/adsWizzConfig/1.xml pageURL=http://www.virginradio.it swfVfy=true live=true timeout=30 flashVer=LNX 11,2,202,297'.format(streamParam[0], streamParam[1], streamParam[2]) xbmcplugin.addDirectoryItem(self._handle, url, li) page_num = 700 addon_page = 2 response = self._getVirginResponse('VideoList.jsp?x_pag={0}&page=1'.format(page_num)) if response.isSucceeded: for video in response.body['videos']: li = self._setVideoListItem(video) nw.createNextPageItem(self._handle, addon_page, { 'action' : 'v', 'page' : page_num + 1, 'page_tot' : response.body['total'], 'addon_page' : addon_page + 1 }, self._fanart) xbmcplugin.endOfDirectory(self._handle) if (streamParam == None or not streamParam) or (response == None or not response or not response.isSucceeded): nw.showNotification(nw.getTranslation(30004)) # Audio. elif self._params['content_type'] == 'audio': xbmcplugin.addDirectoryItem(self._handle, nw.formatUrl({ 'action' : 'r' }), nw.createListItem('Radio', thumbnailImage = 'DefaultFolder.png', fanart = self._fanart), True) xbmcplugin.addDirectoryItem(self._handle, nw.formatUrl({ 'action' : 'p' }), nw.createListItem('Podcast', thumbnailImage = 'DefaultFolder.png', fanart = self._fanart), True) xbmcplugin.endOfDirectory(self._handle) # Foto. elif self._params['content_type'] == 'image': response = self._getVirginResponse('GalleryList.jsp') if response.isSucceeded: response = self._getVirginResponse('GalleryList.jsp?thumbSize=1280x720&x_pag={0}'.format(response.body['total'])) if response.isSucceeded: for gallery in response.body['gallery']: title = self._formatTitle(gallery) img = gallery['thumb'] descr = self._formatDescr(gallery) li = nw.createListItem(title, thumbnailImage = img, fanart = self._fanart, streamtype = 'video', infolabels = { 'title' : title, 'plot' : descr }) xbmcplugin.addDirectoryItem(self._handle, nw.formatUrl({ 'action' : 'f', 'id' : gallery['id'], 'fanart' : img }), li, True) xbmcplugin.endOfDirectory(self._handle) # Video - pagina o riproduzione. elif self._params['action'] == 'v': if 'id' in self._params: response = self._getVirginResponse('Video.jsp?id={0}'.format(self._params['id'])) if response.isSucceeded: video = response.body['videos'] vd = self._getVideoInfo(video) nw.playStream(self._handle, vd['title'], vd['img'], video['file_video'], 'video', { 'title' : vd['title'], 'plot' : vd['descr'] }) elif 'page' in self._params: video_num = 0 page_num = int(self._params['page']) page_tot = int(self._params['page_tot']) addon_page = int(self._params['addon_page']) while video_num < 30 and page_num <= page_tot: response = self._getVirginResponse('VideoList.jsp?x_pag=1&page={0}'.format(page_num), show_error_msg = False) if response.isSucceeded: page_tot = response.body['total'] if response.body['videos'] != None and len(response.body['videos']) > 0: for video in response.body['videos']: li = self._setVideoListItem(video) video_num += 1 page_num += 1 if page_num < page_tot: nw.createNextPageItem(self._handle, addon_page, { 'action' : 'v', 'page' : page_num + 1, 'page_tot' : page_tot, 'addon_page' : addon_page + 1 }, self._fanart) xbmcplugin.endOfDirectory(self._handle) # Video - download. elif self._params['action'] == 'd': response = self._getVirginResponse('Video.jsp?id={0}'.format(self._params['id'])) if response.isSucceeded: video = response.body['videos'] vd = self._getVideoInfo(video) name = ''.join([i if ord(i) < 128 else '' for i in vd['title'].replace(' ', '_')]) name = '{0}.mp4'.format(name) os.chdir(nw.addon.getSetting('download_path')) #~ subprocess.call([nw.addon.getSetting('ffmpeg_path'), '-i', video['file_video'], '-c', 'copy', name]) subprocess.Popen([nw.addon.getSetting('ffmpeg_path'), '-i', video['file_video'], '-c', 'copy', name]) else: nw.showVideoNotAvailable() # Radio elif self._params['action'] == 'r': response = self._getVirginResponse('WebRadioList.jsp') if response.isSucceeded: self._setRadiosListItem(response.body['webradios']['webradioChannel']) self._setRadiosListItem(response.body['webradios']['musicStar']) xbmcplugin.endOfDirectory(self._handle) if response == None or not response or not response.isSucceeded: nw.showNotification(nw.getTranslation(30004)) # Podcast. elif self._params['action'] == 'p': if 'id' in self._params: response = self._getVirginResponse('PodcastAudio.jsp?slug={0}'.format(self._params['id'])) if response.isSucceeded: for podcast in response.body['podcast_audio']['podcasts']: title = self._formatTitle(podcast) li = nw.createListItem(title, fanart = self._params['fanart'], streamtype = 'music', infolabels = { 'title' : title }, isPlayable = True) xbmcplugin.addDirectoryItem(self._handle, podcast['file'], li) else: response = self._getVirginResponse('PodcastAudioList.jsp?imageSize=1280x720') if response.isSucceeded: for podcast in response.body['podcast_audio']: title = podcast['titolo'] img = podcast['immagine'] descr = self._formatDescr(podcast) li = nw.createListItem(title, thumbnailImage = img, fanart = self._fanart, streamtype = 'video', infolabels = { 'title' : title, 'plot' : descr }) xbmcplugin.addDirectoryItem(self._handle, nw.formatUrl({ 'action' : 'p', 'id' : podcast['slug'], 'fanart' : img }), li, True) xbmcplugin.endOfDirectory(self._handle) # Foto. elif self._params['action'] == 'f': response = self._getVirginResponse('Gallery.jsp?id={0}'.format(self._params['id'])) if response.isSucceeded: for idx, photo in enumerate(response.body['gallery']['immagini']): title = '{0} {1}'.format(nw.getTranslation(30005), idx + 1) img = photo['thumb'].replace('100/100', self._def_size_img) li = nw.createListItem(title, thumbnailImage = img, fanart = self._params['fanart'], streamtype = 'image', infolabels = { 'title' : title }) xbmcplugin.addDirectoryItem(self._handle, photo['original'], li) xbmcplugin.endOfDirectory(self._handle)
def __init__(self): # Data. self._channels.append({ 'id' : 13, 'text' : 'DMAX', 'logo' : 'v1435134631/DMAX_logo_makrqn.jpg', 'fanart' : 'v1476968287/DMAX_channel_3_quxfpy.jpg' }) self._channels.append({ 'id' : 11964, 'text' : 'Focus', 'logo' : 'v1430902724/Focus_channel_logo_x5ffc6.png', 'fanart' : 'v1430902770/Focus_channel_3_image_qcotbl.jpg' }) self._channels.append({ 'id' : 18010, 'text' : 'Frisbee', 'logo' : 'v1447775998/FRISBEE_LOGO_Mktg_tepxuy.png', 'fanart' : 'v1475572068/Frisbee_channel_image_tsxtgk.jpg' }) self._channels.append({ 'id' : 8882, 'text' : 'Giallo', 'logo' : 'v1430903282/Logo_Giallo_png_360_qok7dz.png', 'fanart' : 'v1442327197/Dplay_Giallo_imgchannelpage_1600_bsvcqo.jpg' }) self._channels.append({ 'id' : 16414, 'text' : 'K2', 'logo' : 'v1444060838/K2_channel_logo_oz9qxo.png', 'fanart' : 'v1444222560/K2_channel_2_image_u7wa6t.jpg' }) self._channels.append({ 'id' : 20186, 'text' : 'NOVE', 'logo' : 'v1475055469/NOVE_Channel_Logo_WHite_NEW_jc5tgy.png', 'fanart' : 'v1475481860/Deejay_channel_2000_4_mbjrnd.jpg' }) self._channels.append({ 'id' : 14, 'text' : 'Real Time', 'logo' : 'v1426782642/Realtime_Channel_Logo_bmawaq.png', 'fanart' : 'v1472842523/Real_Time_img_canale_nuovo_3_best_fvhoww.jpg' }) self._channels.append({ 'id' : 21663, 'text' : 'Dplay original', 'logo' : 'v1456912515/Dplay_Original_bug_king2w.png', 'fanart' : 'v1456912849/Dplay_Original_poster_frame_qtr878.jpg' }) show_channels = xbmcplugin.getSetting(self._handle, 'show_channels') # Main menu. if len(self._params) == 0 and show_channels == 'true': fanart = os.path.join(nw.addon.getAddonInfo('path'), 'fanart.jpg') self._addItem(nw.getTranslation(30013), { 'action' : 'p', 'page' : 0 }, fanart = fanart) self._addItem(nw.getTranslation(30014), { 'action' : 'c' }, fanart = fanart) xbmcplugin.endOfDirectory(self._handle) # Shows. elif show_channels == 'false' or self._params['action'] == 'p': page = self._params['page'] if 'page' in self._params else 0 items = xbmcplugin.getSetting(self._handle, 'items_per_page') hide_show_no_ep = xbmcplugin.getSetting(self._handle, 'hide_show_no_ep') url = None channel = None if 'channel' in self._params: channel = self._params['channel'] url = 'http://it.dplay.com/api/v2/ajax/shows/?items={0}&homechannel_id={2}&page={1}&sort='.format(items, '{0}', channel) else: url = 'http://it.dplay.com/api/v2/ajax/modules?items={0}&page_id=32&module_id=26&page={1}'.format(items, '{0}') self._getShowsPage(url, page, hide_show_no_ep, channel) # Channels. elif self._params['action'] == 'c': for channel in self._channels: self._addChannel(channel['text'], { 'action' : 'p', 'page' : 0, 'channel' : channel['id'] }, channel['logo'], channel['fanart']) xbmcplugin.endOfDirectory(self._handle) # Seasons. elif self._params['action'] == 's': 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 = nw.getResponseJson(url) if seasons.isSucceeded: if xbmcplugin.getSetting(self._handle, 'show_seasons') == 'false' or len(seasons.body['data']) > 1: for season in seasons.body['data']: title = nw.getTranslation(30016).format(season = season['name'], numberof = season['episodes_available'], numbertot = season['episodes_total']) self._addItem(title, { 'action' : 'e', 'showid' : self._params['showid'], 'seasonid' : season['id'] }, 'DefaultFolder.png', self._findFanart(self._params['channel'])) 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 = nw.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.strip() )) items = sorted(items, key = lambda item: item[0]) nw.playStream(self._handle, '', path = items[0][1])