def shufflePlay(self): import random self.window = windows.smart_play_background() self.window.setBackground(self.poster) self.window.setProgress(0) self.window.show() self.window.setText(tools.lang(32096).encode('utf-8')) tools.playList.clear() showInfo = {} showInfo['showInfo'] = self.info_dictionary season_list = TraktAPI().json_response( 'shows/%s/seasons?extended=episodes' % self.show_trakt_id) if season_list[0]['number'] == 0: season_list.pop(0) self.window.setProgress(50) self.window.setText(tools.lang(32097).encode('utf-8')) episode_list = [ episode for season in season_list for episode in season['episodes'] ] random.shuffle(episode_list) episode_list = episode_list[:40] # mill the episodes playlist = tvshowMenus.Menus().episodeListBuilder(episode_list, showInfo, smartPlay=True) self.window.setProgress(100) self.window.setText(tools.lang(32098).encode('utf-8')) for episode in playlist: if episode is not None: tools.playList.add(url=episode[0], listitem=episode[1]) self.window.setProgress(100) self.window.close() tools.playList.shuffle() tools.player().play(tools.playList)
def shufflePlay(self): import random self.window = windows.smart_play_background() self.window.setBackground(self.poster) self.window.setProgress(0) self.window.show() self.window.setText(tools.lang(32096)) tools.playList.clear() season_list = TraktAPI().json_response( 'shows/%s/seasons?extended=episodes' % self.show_trakt_id) if season_list[0]['number'] == 0: season_list.pop(0) self.window.setProgress(50) self.window.setText(tools.lang(32097)) episode_list = [ episode for season in season_list for episode in season['episodes'] ] random.shuffle(episode_list) episode_list = episode_list[:40] shuffle_list = [] for episode in episode_list: shuffle_list.append({ 'episode': episode, 'show': { 'ids': { 'trakt': self.show_trakt_id } } }) # mill the episodes playlist = tvshowMenus.Menus().mixedEpisodeBuilder(shuffle_list, sort=False, smartPlay=True) self.window.setProgress(100) self.window.setText(tools.lang(32098)) for episode in playlist: if episode is not None: tools.playList.add(url=episode[0], listitem=episode[1]) self.window.setProgress(100) self.window.close() tools.playList.shuffle() tools.player().play(tools.playList)
def smart_play_show(self): self.window = windows.smart_play_background() self.window.setBackground(self.poster) self.window.setText(tools.lang(32094).encode('utf-8')) self.window.show() self.window.setProgress(0) self.window.setProgress(40) self.window.setText(tools.lang(32095).encode('utf-8')) tools.playList.clear() if 'episodeInfo' not in self.info_dictionary: if tools.getSetting('trakt.auth') == '': tools.showDialog.ok(tools.addonName, tools.lang(32093).encode('utf-8')) return season, episode = self.get_resume_episode() if self.final_episode_check(season, episode) is True: season = 1 episode = 1 season_object = TraktAPI().json_response( 'shows/%s/seasons?extended=full' % self.info_dictionary['ids']['trakt']) season_object = [x for x in season_object if x['number'] == season] self.info_dictionary = tvshowMenus.Menus().seasonListBuilder( season_object, self.info_dictionary, smartPlay=True) self.info_dictionary = json.loads( tools.unquote(self.info_dictionary)) else: season = self.info_dictionary['episodeInfo']['info']['season'] episode = self.info_dictionary['episodeInfo']['info']['episode'] self.window.setText(tools.lang(32096).encode('utf-8')) self.window.setProgress(60) episode_list = database.get( TraktAPI().json_response, 12, 'shows/%s/seasons/%s?extended=full' % (self.show_trakt_id, str(season))) playlist = [] for i in episode_list: if i['number'] < episode: continue playlist.append(i) self.window.setText(tools.lang(32097).encode('utf-8')) self.window.setProgress(80) actionArgs = {} actionArgs['playlist'] = playlist actionArgs['info_dictionary'] = self.info_dictionary actionArgs = tools.quote(json.dumps(actionArgs)) # Begin nasty Kodi 18 Skin workaround tools.execute( 'RunPlugin(plugin://plugin.video.%s?action=buildPlaylist&actionArgs=%s)' % (tools.addonName.lower(), actionArgs)) self.window.close()
def smart_play_show(self, append_playlist=False): self.window = windows.smart_play_background() self.window.setBackground(self.poster) self.window.setText(tools.lang(32094)) if not append_playlist: self.window.show() self.window.setProgress(0) self.window.setProgress(40) self.window.setText(tools.lang(32095)) if not append_playlist: tools.playList.clear() if 'episodeInfo' not in self.info_dictionary: if tools.getSetting('trakt.auth') == '': tools.showDialog.ok(tools.addonName, tools.lang(32093)) return else: self.user_history = TraktAPI().json_response( 'sync/history/shows/%s' % self.show_trakt_id) season, episode = self.get_resume_episode() if self.final_episode_check(season, episode) is True: season = 1 episode = 1 else: season = self.info_dictionary['episodeInfo']['info']['season'] episode = self.info_dictionary['episodeInfo']['info']['episode'] self.window.setText(tools.lang(32096)) self.window.setProgress(60) if append_playlist: # Add next seasons episodes to the currently playing playlist and then finish up playlist = tvshowMenus.Menus().episodeListBuilder( self.show_trakt_id, season, hide_unaired=True, smartPlay=True) for i in playlist: # Confirm that the episode meta we have received from TVDB are for the correct episodes # If trakt provides the incorrect TVDB ID it's possible to begin play from the incorrect episode params = dict(tools.parse_qsl(i[0].replace('?', ''))) actionArgs = json.loads(params.get('actionArgs')) if actionArgs['episodeInfo']['info']['episode'] < episode: continue # If the episode is confirmed ok, add it to our playlist. if tvshowMenus.Menus().is_aired( actionArgs['episodeInfo']['info']): tools.playList.add(url=i[0], listitem=i[1]) return season_episodes = tvshowMenus.Menus().episodeListBuilder( self.show_trakt_id, season, smartPlay=True) self.window.setText(tools.lang(32097)) self.window.setProgress(80) playlist = [] for ep in season_episodes: path_arguments = dict(tools.parse_qsl(ep[0].replace('?', ''))) episode_args = json.loads( tools.unquote(path_arguments['actionArgs'])) ep_no = int(episode_args['episodeInfo']['info']['episode']) if ep_no >= episode and tvshowMenus.Menus().is_aired( episode_args['episodeInfo']['info']): playlist.append(ep) self.window.setText('Starting Playback') self.window.setProgress(100) for i in playlist: tools.playList.add(url=i[0], listitem=i[1]) tools.log( 'Begining play from Season %s Episode %s' % (season, episode), 'info') self.window.close() tools.player().play(tools.playList)
def smart_play_show(self, append_playlist=False): self.window = windows.smart_play_background() self.window.setBackground(self.poster) self.window.setText(tools.lang(32094).encode('utf-8')) if not append_playlist: self.window.show() self.window.setProgress(0) self.window.setProgress(40) self.window.setText(tools.lang(32095).encode('utf-8')) if not append_playlist: tools.playList.clear() if 'episodeInfo' not in self.info_dictionary: if tools.getSetting('trakt.auth') == '': tools.showDialog.ok(tools.addonName, tools.lang(32093).encode('utf-8')) return season, episode = self.get_resume_episode() if self.final_episode_check(season, episode) is True: season = 1 episode = 1 season_object = TraktAPI().json_response( 'shows/%s/seasons?extended=full' % self.info_dictionary['ids']['trakt']) season_object = [x for x in season_object if x['number'] == season] self.info_dictionary = tvshowMenus.Menus().seasonListBuilder( season_object, self.info_dictionary, smartPlay=True) self.info_dictionary = json.loads( tools.unquote(self.info_dictionary)) else: season = self.info_dictionary['episodeInfo']['info']['season'] episode = self.info_dictionary['episodeInfo']['info']['episode'] self.window.setText(tools.lang(32096).encode('utf-8')) self.window.setProgress(60) episode_list = database.get( TraktAPI().json_response, 12, 'shows/%s/seasons/%s?extended=full' % (self.show_trakt_id, str(season))) playlist = [] for i in episode_list: if i['number'] < episode: continue playlist.append(i) if append_playlist: tools.log("STARTING PLAYLIST GENERATION") playlist = tvshowMenus.Menus().episodeListBuilder( playlist, self.info_dictionary, smartPlay=True) for i in playlist: # Confirm that the episode meta we have received from TVDB are for the correct episodes # If trakt provides the incorrect TVDB ID it's possible to begin play from the incorrect episode params = dict(tools.parse_qsl(i[0].replace('?', ''))) actionArgs = json.loads(params.get('actionArgs')) if actionArgs['episodeInfo']['info']['episode'] < episode: continue # If the episode is confirmed ok, add it to our playlist. tools.log("ADDING ITEM TO PLAYLIST") tools.playList.add(url=i[0], listitem=i[1]) return self.window.setText(tools.lang(32097).encode('utf-8')) self.window.setProgress(80) actionArgs = {} actionArgs['playlist'] = playlist actionArgs['info_dictionary'] = self.info_dictionary actionArgs = tools.quote(json.dumps(actionArgs)) # Begin nasty Kodi 18 Skin workaround tools.execute( 'RunPlugin(plugin://plugin.video.%s?action=buildPlaylist&actionArgs=%s)' % (tools.addonName.lower(), actionArgs)) self.window.close()