def _add_api_favourites(self): OK = False FOLDER = self.args.folder listitems = [] self.AppendFolder(FOLDER, listitems) try: #genres = scraper.getGenres() emissions = scraper.GET_HTML_AUTH( 'https://services.radio-canada.ca/toutv/profiling/' + self.args.url + '?device=web&version=4') emissions = json.loads(emissions) toutesEmissions = json.loads( scraper.CALL_HTML_AUTH( 'https://services.radio-canada.ca/toutv/presentation/search?includeMedias=false&device=web&version=4', 'GET', None, 'client-key 90505c8d-9c34-4f34-8da1-3a85bdc6d4f4')) for emission in emissions['LineupItems']: self._add_api_favoris(listitems, emission, toutesEmissions) except: print_exc() if listitems: OK = self._add_directory_items(listitems) # fake content movies to show container.foldername self._set_content(OK, "tvshows", False)
def _add_api_enecoute(self): OK = False FOLDER = self.args.folder listitems = [] self.AppendFolder(FOLDER, listitems) try: emissionsRC = scraper.GET_HTML_AUTH( 'https://services.radio-canada.ca/toutv/profiling/MyViews?device=phone_android&version=4' ) emissionsRC = json.loads(emissionsRC) toutesEmissions = json.loads( scraper.CALL_HTML_AUTH( 'https://services.radio-canada.ca/toutv/presentation/search?includeMedias=false&device=web&version=4', 'GET', None, 'client-key 90505c8d-9c34-4f34-8da1-3a85bdc6d4f4')) for lineup in emissionsRC['Lineup']['LineupItems']: self._add_api_enecoutelist( listitems, lineup, episodeContextMenu=False, MediaPlaybackStatuses=emissionsRC["MediaPlaybackStatuses"], ToutesEmissions=toutesEmissions) except: print_exc() if listitems: OK = self._add_directory_items(listitems) # fake content movies to show container.foldername self._set_content(OK, "episodes", False)
def goSync(new=None, refresh=False): global watched_db, watched_pending_db if scraper.isLoggedIn(): try: if new: url = new.keys()[0] put_data = { 'SeekTime': int(new[url]['currentTime']), 'Device': 'web', 'Version': '4' } scraper.CALL_HTML_AUTH( 'https://services.radio-canada.ca/toutv/profiling/playbackstatus' + url, "PUT", json.dumps(put_data)) except: print_exc() if refresh: xbmc.executebuiltin('Container.Refresh') return None
def _add_directory_episodesExtra(self, emissionId): OK = False listitems = [] try: # get show element instance #episodes = scraper.getPageEmission( emissionId )[ "Episodes" ] print "-------------------ATTENTION----------------" print emissionId emissionId = emissionId.replace("%2F", "/").replace("%2f", "/") print emissionId episodes = scraper.CALL_HTML_AUTH( 'https://services.radio-canada.ca/toutv/presentation' + emissionId + '?device=web&version=4', 'GET', None, 'client-key 90505c8d-9c34-4f34-8da1-3a85bdc6d4f4') show = json.loads(episodes) #load toutes les emissions toutesEmissions = json.loads( scraper.CALL_HTML_AUTH( 'https://services.radio-canada.ca/toutv/presentation/search?includeMedias=false&device=web&version=4', 'GET', None, 'client-key 90505c8d-9c34-4f34-8da1-3a85bdc6d4f4')) if scraper.isLoggedIn(): playStatus = scraper.CALL_HTML_AUTH( 'https://services.radio-canada.ca/toutv/profiling/playbackstatus' + emissionId + '?device=phone_android&version=4') playStatus = json.loads(playStatus) mediaPlaybackStatuses = playStatus["MediaPlaybackStatuses"] else: mediaPlaybackStatuses = None if show['EmisodeLineups']: for season in reversed(show['EmisodeLineups']): listitem = xbmcgui.ListItem("[COLOR blue][B]" + season["Title"] + "[/B][/COLOR]") totals = len(season) OK = self._add_directory_item(None, listitem, False, totals) for episode in reversed(season['LineupItems']): #print "START PRINT ===" #print episode # set listitem url, listitem = self._get_episode_listitem_extra( show, season, episode, episode['Key'], False, MediaPlaybackStatuses=mediaPlaybackStatuses, ToutesEmissions=toutesEmissions) #listitems.append( ( url, listitem, False ) ) if episode["Key"] == self.args.Key: listitem.select(True) OK = self._add_directory_item(url, listitem, False, totals) else: listitem = xbmcgui.ListItem("[COLOR blue][B]" + show["Title"] + "[/B][/COLOR]") url, listitem = self._get_episode_listitem_extra( show, show, show, show['IdMedia'], False, ToutesEmissions=toutesEmissions) OK = self._add_directory_item(url, listitem, False, 1) except: print_exc() if listitems: OK = self._add_directory_items(listitems) if not OK: #elif ACTION_INFO: xbmc.executebuiltin("Action(info)") return self._set_content(OK, "episodes")
def _add_api_url(self): print "_add_api_url" OK = False FOLDER = self.args.folder listitems = [] self.AppendFolder(FOLDER, listitems) toutesEmissions = json.loads( scraper.CALL_HTML_AUTH( 'https://services.radio-canada.ca/toutv/presentation/search?includeMedias=false&device=web&version=4', 'GET', None, 'client-key 90505c8d-9c34-4f34-8da1-3a85bdc6d4f4')) try: url = urllib.unquote_plus(self.args.url) join = '?' if '?' in url: join = '&' genres = scraper.CALL_HTML_AUTH( 'https://services.radio-canada.ca/toutv/presentation' + urllib.unquote_plus(self.args.url) + join + 'device=web&version=4', 'GET', None, 'client-key 90505c8d-9c34-4f34-8da1-3a85bdc6d4f4') genres = json.loads(genres) if 'Lineups' in genres: for Lineup in genres['Lineups']: FOLDER = self.args.folder + " / " + Lineup["Title"] url = '%s?url="%s"&folder="%s"&lineup="%s"' % ( sys.argv[0], self.args.url, FOLDER, Lineup["Name"]) if self.args.lineup == "": listitem = xbmcgui.ListItem("[B][COLOR blue]" + Lineup["Title"] + "[/COLOR][/B]") self._add_context_menu_items([], listitem) listitems.append((url, listitem, True)) else: print self.args.lineup print Lineup["Name"] if Lineup["Name"] == self.args.lineup: for genre in Lineup['LineupItems']: self._add_api_favoris(listitems, genre, toutesEmissions) else: if 'A-Z' in FOLDER: for Lineup in genres: self._add_api_favoris_a_z(listitems, Lineup, toutesEmissions) else: for Lineup in genres['LineupItems']: self._add_api_favoris(listitems, Lineup, toutesEmissions) except: print_exc() if listitems: OK = self._add_directory_items(listitems) # fake content movies to show container.foldername self._set_content(OK, "episodes", False)
def _add_api_live(self): OK = False FOLDER = self.args.folder listitems = [] items = [] uri = sys.argv[0] self.AppendFolder(FOLDER, listitems) try: items.append(((uri, 'live/17'), ('Acadie', 'En direct - Acadie', 'DefaultVideo.png'))) items.append(((uri, 'live/13'), ('Alberta', 'En direct - Alberta', 'DefaultVideo.png'))) items.append( ((uri, 'live/14'), ('Colombie-Britannique–Yukon', 'En direct - Colombie-Britannique–Yukon', 'DefaultVideo.png'))) items.append(((uri, 'live/18'), ('Est du Québec', 'En direct - Est du Québec', 'DefaultVideo.png'))) items.append(((uri, 'live/4'), ('Estrie', 'En direct - Estrie', 'DefaultVideo.png'))) items.append( ((uri, 'live/29'), ('Grand Nord', 'En direct - Grand Nord', 'DefaultVideo.png'))) items.append( ((uri, 'live/15'), ('Manitoba', 'En direct - Manitoba', 'DefaultVideo.png'))) items.append( ((uri, 'live/7'), ('Mauricie–Centre-du-Québec', 'En direct - Mauricie–Centre-du-Québec', 'DefaultVideo.png'))) items.append(((uri, 'live/11'), ('Ontario', 'En direct - Ontario', 'DefaultVideo.png'))) items.append(((uri, 'live/12'), ('Ottawa–Gatineau', 'En direct - Ottawa–Gatineau', 'DefaultVideo.png'))) items.append(((uri, 'live/9'), ('Québec', 'En direct - Québec', 'DefaultVideo.png'))) items.append( ((uri, 'live/10'), ('Saguenay–Lac-St-Jean', 'En direct - Saguenay–Lac-St-Jean', 'DefaultVideo.png'))) items.append( ((uri, 'live/16'), ('Saskatchewan', 'En direct - Saskatchewan', 'DefaultVideo.png'))) items.append( ((uri, 'live/19'), ('Terre-Neuve-et-Labrador', 'En direct - Terre-Neuve-et-Labrador', 'DefaultVideo.png'))) toutesEmissions = json.loads( scraper.CALL_HTML_AUTH( 'https://services.radio-canada.ca/toutv/presentation/search?includeMedias=false&device=web&version=4', 'GET', None, 'client-key 90505c8d-9c34-4f34-8da1-3a85bdc6d4f4')) #for key, value in regions: # items.append((( uri, 'live/' + key ), ( value, 'En direct - ' + value, 'DefaultVideo.png' ))) for uri, item in items: listitem = xbmcgui.ListItem(*item) try: id = [int(s) for s in uri[1].split('/') if s.isdigit()] emissionsRC = scraper.CALL_HTML_AUTH( 'https://services.radio-canada.ca/toutv/presentation/live?device=web&version=4&channel=IciTele®ionId=' + str(id[0]), 'GET', None, 'client-key 90505c8d-9c34-4f34-8da1-3a85bdc6d4f4') emissionsRC = json.loads(emissionsRC) #print emissionsRC #listitem.setProperty( "fanart_image", fanart ) listitem.setArt({ 'thumb': emissionsRC['broadcasts'][0]['picture']['url'] }) #listitem.setLabel(listitem.getLabel() + " - " + str(emissionsRC['broadcasts'][0]['displayTitle'])) print emissionsRC['broadcasts'][0]['displayTitle'] ##listitem.setInfo(type='video', infoLabels={'plot': emissionsRC['broadcasts'][0]['displayTitle'].decode('ascii').encode('utf-8') }) self._add_context_menu_items([], listitem) if isinstance(uri, tuple): FOLDER = " / " + item[1] url = '%s?url="%s"&folder="%s"' % (uri[0], uri[1], FOLDER) listitems.append((url, listitem, False)) else: listitems.append((uri, listitem, False)) except: pass #for key, value in regions #self._add_api_livelist(listitems, emissionsRC, episodeContextMenu=False, ToutesEmissions = toutesEmissions) #for lineup in emissionsRC['Lineup']['LineupItems']: # self._add_api_enecoutelist(listitems, lineup, episodeContextMenu=False, MediaPlaybackStatuses=emissionsRC["MediaPlaybackStatuses"], ToutesEmissions = toutesEmissions) except: print_exc() if listitems: OK = self._add_directory_items(listitems) # fake content movies to show container.foldername self._set_content(OK, "episodes", False)
def _add_directory_root_extra(self): OK = False listitems = [] try: uri = sys.argv[0] #sections = scraper.GET_HTML('https://services.radio-canada.ca/toutv/presentation/home?device=web&version=4')#'https://ici.tou.tv/presentation/section/') sections = scraper.CALL_HTML_AUTH( 'https://services.radio-canada.ca/toutv/presentation/TagMenu?sort=Sequence&device=web&version=4', 'GET', None, 'client-key 90505c8d-9c34-4f34-8da1-3a85bdc6d4f4') print "----------DEBUG---------" print sections sections = json.loads(sections) items = [] items.append(((uri, 'ouvrirconfig'), ('[COLOR blue][B]' + LOGIN[1] + '[/B][/COLOR]', '', 'DefaultUser.png'))) if scraper.isLoggedIn(): goSync() items.append(((uri, 'enecoute'), (u'Mes visionnements', 'Mes visionnements', 'DefaultInProgressShows.png'))) items.append(((uri, 'bookmark'), ('Mes Favoris', 'Mes Favoris', 'DefaultMusicTop100.png'))) #items.append((None, ( u'[COLOR blue][B]Menu[/B][/COLOR]', 'Mes Favoris', 'DefaultAddonScreensaver.png' ))) #print sections items.append(((uri, 'live'), ('En direct', 'En direct - NON FONCTIONNEL ENCORE', 'DefaultVideo.png'))) items.append(((uri, '/Search?includeMedias=false'), ('A-Z', 'A-Z', 'DefaultTVShowTitle.png'))) items.append(((uri, '/CatchUp'), ('Rattrapage', 'Rattrapage', 'DefaultAddonScreensaver.png'))) for section in sections['Types']: #print section #if section['Category'] != None: imageicon = sections['ImagePerTag'][section['Key']] if "parcourir_types" in imageicon: imageicon = 'DefaultFolder.png' items.append( ((uri, "/Category/" + urllib.quote_plus(section['Key'] or "")), (section['Title'], section['Title'], imageicon))) for section in sections['Network']: #print section #if section['Category'] != None: items.append( ((uri, "/Category/" + urllib.quote_plus(section['Key'] or "")), (section['Title'], section['Title'], sections['ImagePerTag'][section['Key']] or 'DefaultFolder.png'))) for section in sections['GenresThemes']: #print section #if section['Category'] != None: items.append( ((uri, "/Category/" + urllib.quote_plus(section['Key'] or "")), (section['Title'], section['Title'], sections['ImagePerTag'][section['Key']] or 'DefaultFolder.png'))) fanart = ADDON.getAddonInfo("fanart") for uri, item in items: listitem = xbmcgui.ListItem(*item) listitem.setProperty("fanart_image", fanart) self._add_context_menu_items([], listitem) if isinstance(uri, tuple): FOLDER = " / " + item[1] url = '%s?url="%s"&folder="%s"' % (uri[0], uri[1], FOLDER) listitems.append((url, listitem, True)) else: listitems.append((uri, listitem, False)) except: print_exc() if listitems: OK = self._add_directory_items(listitems) # fake content movies to show container.foldername self._set_content(OK, "episodes", False)