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_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)