def _get_next_item_item_information(): current_position = g.PLAYLIST.getposition() url = g.PLAYLIST[ # pylint: disable=unsubscriptable-object current_position + 1].getPath() params = dict(tools.parse_qsl(tools.unquote(url.split("?")[1]))) return tools.get_item_information( tools.deconstruct_action_args(params.get("action_args")))
def __init__(self, xml_file, location, actionArgs=None): super(BaseWindow, self).__init__(xml_file, location) if actionArgs is None: return tools.closeBusyDialog() self.canceled = False self.item_information = tools.get_item_information(actionArgs) self.setProperty('texture.white', os.path.join(tools.IMAGES_PATH, 'white.png')) self.setProperty('seren.logo', tools.SEREN_LOGO_PATH) self.setProperty('settings.color', tools.get_user_text_color()) self.setProperty('test_pattern', os.path.join(tools.IMAGES_PATH, 'test_pattern.png')) for i in self.item_information['art'].keys(): self.setProperty('item.art.%s' % i, str(self.item_information['art'][i])) for i in self.item_information['info'].keys(): value = self.item_information['info'][i] if i == 'aired' or i == 'premiered': value = value[:10] try: self.setProperty('item.info.%s' % i, str(value)) except UnicodeEncodeError: self.setProperty('item.info.%s' % i, value)
def showSeasons(self, args): args = tools.get_item_information(args) self.seasonListBuilder(args['ids']['trakt']) tools.closeDirectory('seasons')
def next_info(self): current_info = self.args current_episode = {} current_episode["episodeid"] = current_info['ids']['trakt'] current_episode["tvshowid"] = current_info['showInfo']['info']['imdbnumber'] current_episode["title"] = current_info['info']['title'] current_episode["art"] = {} current_episode["art"]["tvshow.poster"] = current_info['art']['poster'] current_episode["art"]["thumb"] = current_info['art']['thumb'] current_episode["art"]["tvshow.fanart"] = current_info['art']['fanart'] current_episode["art"]["tvshow.landscape"] = current_info['art']['fanart'] current_episode["art"]["tvshow.clearart"] = current_info['art'].get('clearart', '') current_episode["art"]["tvshow.clearlogo"] = current_info['art'].get('clearlogo', '') current_episode["plot"] = current_info['info']['plot'] current_episode["showtitle"] = current_info['showInfo']['info']['tvshowtitle'] current_episode["playcount"] = current_info['info'].get('playcount', 0) current_episode["season"] = current_info['info']['season'] current_episode["episode"] = current_info['info']['episode'] current_episode["rating"] = current_info['info']['rating'] current_episode["firstaired"] = current_info['info']['premiered'][:10] current_position = tools.playList.getposition() url = tools.playList[current_position + 1].getPath() params = dict(tools.parse_qsl(url.replace('?', ''))) next_info = tools.get_item_information(params.get('actionArgs')) next_episode = {} next_episode["episodeid"] = next_info['ids']['trakt'] next_episode["tvshowid"] = next_info['showInfo']['info']['imdbnumber'] next_episode["title"] = next_info['info']['title'] next_episode["art"] = {} next_episode["art"]["tvshow.poster"] = next_info['art']['poster'] next_episode["art"]["thumb"] = next_info['art']['thumb'] next_episode["art"]["tvshow.fanart"] = next_info['art']['fanart'] next_episode["art"]["tvshow.landscape"] = next_info['art']['fanart'] next_episode["art"]["tvshow.clearart"] = next_info['art'].get('clearart', '') next_episode["art"]["tvshow.clearlogo"] = next_info['art'].get('clearlogo', '') next_episode["plot"] = next_info['info']['plot'] next_episode["showtitle"] = next_info['showInfo']['info']['tvshowtitle'] next_episode["playcount"] = next_info['info'].get('playcount', 0) next_episode["season"] = next_info['info']['season'] next_episode["episode"] = next_info['info']['episode'] next_episode["rating"] = next_info['info']['rating'] next_episode["firstaired"] = next_info['info']['premiered'][:10] play_info = {} play_info["item_id"] = current_info['ids']['trakt'] next_info = { "current_episode": current_episode, "next_episode": next_episode, "play_info": play_info, "notification_time": int(tools.getSetting('smartplay.upnexttime')) } return next_info
def play_source(self, stream_link, args, resume_time=None, params=None): try: self.pre_cache_initiated = False if resume_time is not None: self.offset = float(resume_time) self.params = params if stream_link is None: tools.cancelPlayback() raise Exception self.playing_file = stream_link self.original_action_args = args self.smart_module = smartPlay.SmartPlay(self.original_action_args) args = tools.get_item_information(args) self.args = args if 'showInfo' in args: self.media_type = 'episode' # Workaround for estuary skin to allow episode information to be displayed in Video Top Info args['art']['tvshow.clearlogo'] = args['art'].get( 'clearlogo', '') else: self.media_type = 'movie' self.trakt_id = args['ids']['trakt'] orginalArgs = json.loads(tools.unquote(self.original_action_args)) if 'resume' in orginalArgs: if orginalArgs['resume'] == 'true': self.tryGetBookmark() self.handleBookmark() item = tools.menuItem(path=stream_link) args['info']['FileNameAndPath'] = tools.unquote(stream_link) item.setInfo(type='video', infoLabels=args['info']) item.setArt(args['art']) item.setCast(args['cast']) item.setUniqueIDs(args['ids']) tools.closeBusyDialog() tools.closeAllDialogs() tools.resolvedUrl(syshandle, True, item) self.keepAlive() except: traceback.print_exc() pass
def seasonEpisodes(self, args): args = tools.get_item_information(args) show_id = args['showInfo']['ids']['trakt'] if 'seasonInfo' in args: season_number = args['seasonInfo']['info']['season'] else: season_number = args['info']['season'] self.episodeListBuilder(show_id, season_number) tools.closeDirectory('episodes', sort='episode')
def resolve_item(self): if tools.getSetting('general.autotrynext') == 'true': sources = self.sources[self.position:] else: sources = [self.sources[self.position]] self.stream_link = database.get(self.Resolver.doModal, 1, sources, tools.get_item_information(self.actionArgs), False) if self.stream_link is None: tools.showDialog.notification(tools.addonName, 'Failed to resolve item, please try another source') return else: self.close()
def __init__(self, actionArgs): self.actionArgs = actionArgs self.info_dictionary = tools.get_item_information(actionArgs) if type(self.info_dictionary) is not dict: raise Exception try: self.show_trakt_id = self.info_dictionary['showInfo']['ids'][ 'trakt'] except: self.show_trakt_id = self.info_dictionary['ids']['trakt'] self.display_style = tools.getSetting('smartplay.displaystyle') self.window = BackgroundWindowAdapter()
def getSourcesWorkaround2(self, actionArgs): item_information = tools.get_item_information(actionArgs) item = tools.menuItem(label=item_information['info']['title']) item.setArt(item_information['art']) item.setUniqueIDs(item_information['ids']) item.setInfo(type='video', infoLabels=tools.clean_info_keys( item_information['info'])) tools.playList.add( url='plugin://plugin.video.%s?action=getSources&actionArgs=%s' % (tools.addonName.lower(), tools.quote(actionArgs)), listitem=item) tools.player().play(tools.playList)
def __init__(self, item_information): self.list_builder = ListBuilder() if "info" not in item_information: item_information = tools.get_item_information(item_information) self.item_information = item_information if not isinstance(self.item_information, dict): raise TypeError("Item Information is not a dictionary") self.show_trakt_id = self.item_information.get("trakt_show_id") if not self.show_trakt_id and "action_args" in self.item_information: self.show_trakt_id = self._extract_show_id_from_args( self.item_information["action_args"]) self.display_style = g.get_int_setting("smartplay.displaystyle") self.trakt_api = TraktAPI()
def resolve_item(self): if tools.getSetting('general.autotrynext') == 'true': sources = self.sources[self.position:] else: sources = [self.sources[self.position]] resolver = Resolver(*SkinManager().confirm_skin_path('resolver.xml'), actionArgs=self.actionArgs) self.stream_link = database.get(resolver.doModal, 1, sources, tools.get_item_information(self.actionArgs), False) if self.stream_link is None: tools.showDialog.notification(tools.addonName, tools.lang(32047), time=2000) return else: self.close()
def get_sources(self, action_args, overwrite_cache=False): """ Method to handle automatic background or foreground scraping :param action_args: action arguments from request uri :param overwrite_cache: Set to true if you wish to overwrite the current cached return value :return: """ item_information = tools.get_item_information(action_args) if not ProviderCache().get_provider_packages(): yesno = xbmcgui.Dialog().yesno(g.ADDON_NAME, g.get_language_string(30443)) if not yesno: return sources = Sources(item_information).get_sources( overwrite_torrent_cache=overwrite_cache) return sources
def __init__(self, actionArgs): self.actionArgs = actionArgs self.info_dictionary = tools.get_item_information(actionArgs) if type(self.info_dictionary) is not dict: raise Exception try: self.poster = self.info_dictionary['showInfo']['art'].get( 'fanart', '') self.show_trakt_id = self.info_dictionary['showInfo']['ids'][ 'trakt'] except: self.poster = self.info_dictionary['art'].get('fanart', '') self.show_trakt_id = self.info_dictionary['ids']['trakt'] self.window = None
def get_sources(self, action_args, overwrite_cache=None): """ Method to handle automatic background or foreground scraping :param action_args: action arguments from request uri :param overwrite_cache: Set to true if you wish to overwrite the current cached return value :return: """ item_information = tools.get_item_information(action_args) if not ProviderCache().get_provider_packages(): yesno = xbmcgui.Dialog().yesno(g.ADDON_NAME, g.get_language_string(30465)) if not yesno: return sources = Sources(item_information).get_sources() if sources is None or len(sources) <= 0 or len(sources[1]) <= 0: g.cancel_playback() g.notification(g.ADDON_NAME, g.get_language_string(30032), time=5000) return sources
def play_source(self, stream_link, args): try: self.pre_cache_initiated = False if stream_link is None: tools.cancelPlayback() raise Exception self.original_action_args = args args = tools.get_item_information(args) self.args = args item = tools.menuItem(path=stream_link) if 'showInfo' in args: self.media_type = 'episode' self.trakt_id = args['ids']['trakt'] item.setArt(args['art']) item.setUniqueIDs(args['ids']) item.setInfo(type='video', infoLabels=args['info']) else: self.media_type = 'movie' self.trakt_id = args['ids']['trakt'] item.setUniqueIDs(args['ids']) item.setArt(args['art']) item.setInfo(type='video', infoLabels=args['info']) if tools.playList.getposition() == 0 and tools.getSetting('smartPlay.traktresume') == 'true' \ and tools.getSetting('trakt.auth') is not '': tools.log('Getting Trakt Resume Point', 'info') self.traktBookmark() tools.resolvedUrl(syshandle, True, item) self.keepAlive() try: tools.closeBusyDialog() except: pass except: import traceback traceback.print_exc()
def build_playlist(self, season=None, minimum_episode=None, params=None): if season is None: season = self.info_dictionary['info']['season'] if minimum_episode is None: minimum_episode = int(self.info_dictionary['info']['episode']) + 1 url_params = self.clean_playback_params(params) playlist = tvshowMenus.Menus().episodeListBuilder(self.show_trakt_id, season, smartPlay=True) for i in playlist: params = dict(tools.parse_qsl(i[0].replace('?', ''))) actionArgs = params.get('actionArgs') if not tvshowMenus.Menus().is_aired( tools.get_item_information(actionArgs)['info']): tools.log('Episode not Aired, skipping') continue actionArgs = json.loads(actionArgs) if actionArgs['episode'] < minimum_episode: continue url = i[0] if actionArgs['episode'] == minimum_episode: request_args = json.loads(tools.unquote(self.actionArgs)) # actionArgs['resume'] = request_args['resume'] if 'resume' in request_args else 'false' url = '&actionArgs='.join([ url.split('&actionArgs=')[0], tools.quote(json.dumps(actionArgs, sort_keys=True)) ]) if url_params is not None: url += '&{}'.format(url_params) tools.playList.add(url=url, listitem=i[1])
def _build_playlist(self, season, minimum_episode): playlist = tvshowMenus.Menus().episodeListBuilder(self.show_trakt_id, season, 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['episode'] < minimum_episode: continue # If the episode is confirmed ok, add it to our playlist. if tvshowMenus.Menus().is_aired( tools.get_item_information( json.dumps(actionArgs))['info']): tools.playList.add(url=i[0], listitem=i[1])
# -*- coding: utf-8 -*- from __future__ import absolute_import, division, unicode_literals import xbmc from resources.lib.common import tools from resources.lib.database.skinManager import SkinManager from resources.lib.modules import mock_modules _mock_information = tools.get_item_information({ "trakt_id": 3401782, "trakt_show_id": 1390, "mediatype": "episode", "trakt_season_id": 184210, }) mock_source = { "type": "torrent", "info": ["HDTV", "AAC"], "quality": "1080p", "hash": "hash", "size": 140000, "provider": "Test Provider", "release_title": "Test.Source.HDTV.AAC.1080p", "debrid_provider": "Premiumize", "seeds": 123, } def mock_playing_next(): from resources.lib.gui.windows.playing_next import PlayingNext
def dispatch(params): url = params.get("url") action = params.get("action") action_args = params.get("action_args") pack_select = params.get("packSelect") source_select = params.get("source_select") == "true" overwrite_cache = params.get("seren_reload") == "true" resume = params.get("resume") force_resume_check = params.get("forceresumecheck") == "true" force_resume_off = params.get("forceresumeoff") == "true" force_resume_on = params.get("forceresumeon") == "true" smart_url_arg = params.get("smartPlay") == "true" mediatype = params.get("mediatype") endpoint = params.get("endpoint") g.log("Seren, Running Path - {}".format(g.REQUEST_PARAMS)) if action is None: from resources.lib.gui import homeMenu homeMenu.Menus().home() if action == "genericEndpoint": if mediatype == "movies": from resources.lib.gui.movieMenus import Menus else: from resources.lib.gui.tvshowMenus import Menus Menus().generic_endpoint(endpoint) elif action == "forceResumeShow": from resources.lib.modules import smartPlay from resources.lib.common import tools smartPlay.SmartPlay( tools.get_item_information(action_args)).resume_show() elif action == "moviesHome": from resources.lib.gui import movieMenus movieMenus.Menus().discover_movies() elif action == "moviesUpdated": from resources.lib.gui import movieMenus movieMenus.Menus().movies_updated() elif action == "moviesRecommended": from resources.lib.gui import movieMenus movieMenus.Menus().movies_recommended() elif action == "moviesSearch": from resources.lib.gui import movieMenus movieMenus.Menus().movies_search(action_args) elif action == "moviesSearchResults": from resources.lib.gui import movieMenus movieMenus.Menus().movies_search_results(action_args) elif action == "moviesSearchHistory": from resources.lib.gui import movieMenus movieMenus.Menus().movies_search_history() elif action == "myMovies": from resources.lib.gui import movieMenus movieMenus.Menus().my_movies() elif action == "moviesMyCollection": from resources.lib.gui import movieMenus movieMenus.Menus().my_movie_collection() elif action == "moviesMyWatchlist": from resources.lib.gui import movieMenus movieMenus.Menus().my_movie_watchlist() elif action == "moviesRelated": from resources.lib.gui import movieMenus movieMenus.Menus().movies_related(action_args) elif action == "colorPicker": g.color_picker() elif action == "authTrakt": from resources.lib.indexers import trakt trakt.TraktAPI().auth() elif action == "revokeTrakt": from resources.lib.indexers import trakt trakt.TraktAPI().revoke_auth() elif action == "getSources" or action == "smartPlay": from resources.lib.modules.smartPlay import SmartPlay from resources.lib.common import tools from resources.lib.modules import helpers item_information = tools.get_item_information(action_args) smart_play = SmartPlay(item_information) background = None resolver_window = None try: # Check to confirm user has a debrid provider authenticated and enabled if not g.premium_check(): xbmcgui.Dialog().ok( g.ADDON_NAME, tools.create_multiline_message( line1=g.get_language_string(30208), line2=g.get_language_string(30209), ), ) return None # workaround for widgets not generating a playlist on playback request play_list = smart_play.playlist_present_check(smart_url_arg) if play_list: g.log("Cancelling non playlist playback", "warning") xbmc.Player().play(g.PLAYLIST) return resume_time = smart_play.handle_resume_prompt( resume, force_resume_off, force_resume_on, force_resume_check) background = helpers.show_persistent_window_if_required( item_information) sources = helpers.SourcesHelper().get_sources( action_args, overwrite_cache=overwrite_cache) if sources is None: return if item_information["info"]["mediatype"] == "episode": source_select_style = "Episodes" else: source_select_style = "Movie" if (g.get_int_setting( "general.playstyle{}".format(source_select_style)) == 1 or source_select): if background: background.set_text(g.get_language_string(30198)) from resources.lib.modules import sourceSelect stream_link = sourceSelect.source_select( sources[0], sources[1], item_information) else: if background: background.set_text(g.get_language_string(30032)) stream_link = helpers.Resolverhelper( ).resolve_silent_or_visible(sources[1], sources[2], pack_select) if stream_link is None: g.close_busy_dialog() g.notification(g.ADDON_NAME, g.get_language_string(30033), time=5000) g.show_busy_dialog() if background: background.close() del background if not stream_link: raise NoPlayableSourcesException from resources.lib.modules import player player.SerenPlayer().play_source(stream_link, item_information, resume_time=resume_time) except NoPlayableSourcesException: try: background.close() del background except (UnboundLocalError, AttributeError): pass try: resolver_window.close() del resolver_window except (UnboundLocalError, AttributeError): pass g.cancel_playback() elif action == "preScrape": from resources.lib.database.skinManager import SkinManager from resources.lib.modules import helpers try: from resources.lib.common import tools item_information = tools.get_item_information(action_args) if item_information["info"]["mediatype"] == "episode": source_select_style = "Episodes" else: source_select_style = "Movie" sources = helpers.SourcesHelper().get_sources(action_args) if (g.get_int_setting( "general.playstyle{}".format(source_select_style)) == 0 and sources): from resources.lib.modules import resolver helpers.Resolverhelper().resolve_silent_or_visible( sources[1], sources[2], pack_select) finally: g.set_setting("general.tempSilent", "false") g.log("Pre-scraping completed") elif action == "authRealDebrid": from resources.lib.debrid import real_debrid real_debrid.RealDebrid().auth() elif action == "showsHome": from resources.lib.gui import tvshowMenus tvshowMenus.Menus().discover_shows() elif action == "myShows": from resources.lib.gui import tvshowMenus tvshowMenus.Menus().my_shows() elif action == "showsMyCollection": from resources.lib.gui import tvshowMenus tvshowMenus.Menus().my_shows_collection() elif action == "showsMyWatchlist": from resources.lib.gui import tvshowMenus tvshowMenus.Menus().my_shows_watchlist() elif action == "showsMyProgress": from resources.lib.gui import tvshowMenus tvshowMenus.Menus().my_show_progress() elif action == "showsMyRecentEpisodes": from resources.lib.gui import tvshowMenus tvshowMenus.Menus().my_recent_episodes() elif action == "showsRecommended": from resources.lib.gui import tvshowMenus tvshowMenus.Menus().shows_recommended() elif action == "showsUpdated": from resources.lib.gui import tvshowMenus tvshowMenus.Menus().shows_updated() elif action == "showsSearch": from resources.lib.gui import tvshowMenus tvshowMenus.Menus().shows_search(action_args) elif action == "showsSearchResults": from resources.lib.gui import tvshowMenus tvshowMenus.Menus().shows_search_results(action_args) elif action == "showsSearchHistory": from resources.lib.gui import tvshowMenus tvshowMenus.Menus().shows_search_history() elif action == "showSeasons": from resources.lib.gui import tvshowMenus tvshowMenus.Menus().show_seasons(action_args) elif action == "seasonEpisodes": from resources.lib.gui import tvshowMenus tvshowMenus.Menus().season_episodes(action_args) elif action == "showsRelated": from resources.lib.gui import tvshowMenus tvshowMenus.Menus().shows_related(action_args) elif action == "showYears": from resources.lib.gui import tvshowMenus tvshowMenus.Menus().shows_years(action_args) elif action == "searchMenu": from resources.lib.gui import homeMenu homeMenu.Menus().search_menu() elif action == "toolsMenu": from resources.lib.gui import homeMenu homeMenu.Menus().tools_menu() elif action == "clearCache": from resources.lib.common import tools g.clear_cache() elif action == "traktManager": from resources.lib.indexers import trakt from resources.lib.common import tools trakt.TraktManager(tools.get_item_information(action_args)) elif action == "onDeckShows": from resources.lib.gui import tvshowMenus tvshowMenus.Menus().on_deck_shows() elif action == "onDeckMovies": from resources.lib.gui.movieMenus import Menus Menus().on_deck_movies() elif action == "cacheAssist": from resources.lib.modules.cacheAssist import CacheAssistHelper CacheAssistHelper().auto_cache(action_args) elif action == "tvGenres": from resources.lib.gui import tvshowMenus tvshowMenus.Menus().shows_genres() elif action == "showGenresGet": from resources.lib.gui import tvshowMenus tvshowMenus.Menus().shows_genre_list(action_args) elif action == "movieGenres": from resources.lib.gui import movieMenus movieMenus.Menus().movies_genres() elif action == "movieGenresGet": from resources.lib.gui import movieMenus movieMenus.Menus().movies_genre_list(action_args) elif action == "shufflePlay": from resources.lib.modules import smartPlay smartPlay.SmartPlay(action_args).shuffle_play() elif action == "resetSilent": g.set_setting("general.tempSilent", "false") g.notification( "{}: {}".format(g.ADDON_NAME, g.get_language_string(30329)), g.get_language_string(30034), time=5000, ) elif action == "clearTorrentCache": from resources.lib.database.torrentCache import TorrentCache TorrentCache().clear_all() elif action == "openSettings": xbmc.executebuiltin("Addon.OpenSettings({})".format(g.ADDON_ID)) elif action == "myTraktLists": from resources.lib.modules.listsHelper import ListsHelper ListsHelper().my_trakt_lists(mediatype) elif action == "myLikedLists": from resources.lib.modules.listsHelper import ListsHelper ListsHelper().my_liked_lists(mediatype) elif action == "TrendingLists": from resources.lib.modules.listsHelper import ListsHelper ListsHelper().trending_lists(mediatype) elif action == "PopularLists": from resources.lib.modules.listsHelper import ListsHelper ListsHelper().popular_lists(mediatype) elif action == "traktList": from resources.lib.modules.listsHelper import ListsHelper ListsHelper().get_list_items() elif action == "nonActiveAssistClear": from resources.lib.gui import debridServices debridServices.Menus().assist_non_active_clear() elif action == "debridServices": from resources.lib.gui import debridServices debridServices.Menus().home() elif action == "cacheAssistStatus": from resources.lib.gui import debridServices debridServices.Menus().get_assist_torrents() elif action == "premiumize_transfers": from resources.lib.gui import debridServices debridServices.Menus().list_premiumize_transfers() elif action == "showsNextUp": from resources.lib.gui import tvshowMenus tvshowMenus.Menus().my_next_up() elif action == "runMaintenance": from resources.lib.common import maintenance maintenance.run_maintenance() elif action == "providerTools": from resources.lib.gui import homeMenu homeMenu.Menus().provider_menu() elif action == "installProviders": from resources.lib.modules.providers.install_manager import ( ProviderInstallManager, ) ProviderInstallManager().install_package(action_args) elif action == "uninstallProviders": from resources.lib.modules.providers.install_manager import ( ProviderInstallManager, ) ProviderInstallManager().uninstall_package() elif action == "showsNew": from resources.lib.gui import tvshowMenus tvshowMenus.Menus().shows_new() elif action == "realdebridTransfers": from resources.lib.gui import debridServices debridServices.Menus().list_rd_transfers() elif action == "cleanInstall": from resources.lib.common import maintenance maintenance.wipe_install() elif action == "premiumizeCleanup": from resources.lib.common import maintenance maintenance.premiumize_transfer_cleanup() elif action == "manualProviderUpdate": from resources.lib.modules.providers.install_manager import ( ProviderInstallManager, ) ProviderInstallManager().manual_update() elif action == "clearSearchHistory": from resources.lib.database.searchHistory import SearchHistory SearchHistory().clear_search_history(mediatype) elif action == "externalProviderInstall": from resources.lib.modules.providers.install_manager import ( ProviderInstallManager, ) confirmation = xbmcgui.Dialog().yesno(g.ADDON_NAME, g.get_language_string(30182)) if confirmation == 0: return ProviderInstallManager().install_package(1, url=url) elif action == "externalProviderUninstall": from resources.lib.modules.providers.install_manager import ( ProviderInstallManager, ) confirmation = xbmcgui.Dialog().yesno( g.ADDON_NAME, g.get_language_string(30184).format(url)) if confirmation == 0: return ProviderInstallManager().uninstall_package(package=url, silent=False) elif action == "showsNetworks": from resources.lib.gui import tvshowMenus tvshowMenus.Menus().shows_networks() elif action == "showsNetworkShows": from resources.lib.gui import tvshowMenus tvshowMenus.Menus().shows_networks_results(action_args) elif action == "movieYears": from resources.lib.gui import movieMenus movieMenus.Menus().movies_years() elif action == "movieYearsMovies": from resources.lib.gui import movieMenus movieMenus.Menus().movie_years_results(action_args) elif action == "syncTraktActivities": from resources.lib.database.trakt_sync.activities import TraktSyncDatabase TraktSyncDatabase().sync_activities() elif action == "traktSyncTools": from resources.lib.gui import homeMenu homeMenu.Menus().trakt_sync_tools() elif action == "flushTraktActivities": from resources.lib.database import trakt_sync trakt_sync.TraktSyncDatabase().flush_activities() elif action == "flushTraktDBMeta": from resources.lib.database import trakt_sync trakt_sync.TraktSyncDatabase().clear_all_meta() elif action == "myFiles": from resources.lib.gui import myFiles myFiles.Menus().home() elif action == "myFilesFolder": from resources.lib.gui import myFiles myFiles.Menus().my_files_folder(action_args) elif action == "myFilesPlay": from resources.lib.gui import myFiles myFiles.Menus().my_files_play(action_args) elif action == "forceTraktSync": from resources.lib.database.trakt_sync.activities import TraktSyncDatabase trakt_db = TraktSyncDatabase() trakt_db.flush_activities() trakt_db.sync_activities() elif action == "rebuildTraktDatabase": from resources.lib.database.trakt_sync import TraktSyncDatabase TraktSyncDatabase().re_build_database() elif action == "myUpcomingEpisodes": from resources.lib.gui import tvshowMenus tvshowMenus.Menus().my_upcoming_episodes() elif action == "myWatchedEpisodes": from resources.lib.gui import tvshowMenus tvshowMenus.Menus().my_watched_episode() elif action == "myWatchedMovies": from resources.lib.gui import movieMenus movieMenus.Menus().my_watched_movies() elif action == "showsByActor": from resources.lib.gui import tvshowMenus tvshowMenus.Menus().shows_by_actor(action_args) elif action == "movieByActor": from resources.lib.gui import movieMenus movieMenus.Menus().movies_by_actor(action_args) elif action == "playFromRandomPoint": from resources.lib.modules import smartPlay smartPlay.SmartPlay(action_args).play_from_random_point() elif action == "refreshProviders": from resources.lib.modules.providers import CustomProviders providers = CustomProviders() providers.update_known_providers() providers.poll_database() elif action == "installSkin": from resources.lib.database.skinManager import SkinManager SkinManager().install_skin() elif action == "uninstallSkin": from resources.lib.database.skinManager import SkinManager SkinManager().uninstall_skin() elif action == "switchSkin": from resources.lib.database.skinManager import SkinManager SkinManager().switch_skin() elif action == "manageProviders": g.show_busy_dialog() from resources.lib.gui.windows.provider_packages import ProviderPackages from resources.lib.database.skinManager import SkinManager window = ProviderPackages( *SkinManager().confirm_skin_path("provider_packages.xml")) window.doModal() del window elif action == "flatEpisodes": from resources.lib.gui.tvshowMenus import Menus Menus().flat_episode_list(action_args) elif action == "runPlayerDialogs": from resources.lib.modules.player import PlayerDialogs PlayerDialogs().display_dialog() elif action == "authAllDebrid": from resources.lib.debrid.all_debrid import AllDebrid AllDebrid().auth() elif action == "checkSkinUpdates": from resources.lib.database.skinManager import SkinManager SkinManager().check_for_updates() elif action == "authPremiumize": from resources.lib.debrid.premiumize import Premiumize Premiumize().auth() elif action == "testWindows": from resources.lib.gui.homeMenu import Menus Menus().test_windows() elif action == "testPlayingNext": from resources.lib.gui import mock_windows mock_windows.mock_playing_next() elif action == "testStillWatching": from resources.lib.gui import mock_windows mock_windows.mock_still_watching() elif action == "testResolverWindow": from resources.lib.gui import mock_windows mock_windows.mock_resolver() elif action == "testSourceSelectWindow": from resources.lib.gui import mock_windows mock_windows.mock_source_select() elif action == "testManualCacheWindow": from resources.lib.gui import mock_windows mock_windows.mock_cache_assist() elif action == "showsPopularRecent": from resources.lib.gui.tvshowMenus import Menus Menus().shows_popular_recent() elif action == "showsTrendingRecent": from resources.lib.gui.tvshowMenus import Menus Menus().shows_trending_recent() elif action == "moviePopularRecent": from resources.lib.gui.movieMenus import Menus Menus().movie_popular_recent() elif action == "movieTrendingRecent": from resources.lib.gui.movieMenus import Menus Menus().movie_trending_recent() elif action == "setDownloadLocation": from resources.lib.modules.download_manager import set_download_location set_download_location() elif action == "downloadManagerView": from resources.lib.gui.windows.download_manager import DownloadManager from resources.lib.database.skinManager import SkinManager window = DownloadManager( *SkinManager().confirm_skin_path("download_manager.xml")) window.doModal() del window elif action == "longLifeServiceManager": from resources.lib.modules.providers.service_manager import ( ProvidersServiceManager, ) ProvidersServiceManager().run_long_life_manager() elif action == "showsRecentlyWatched": from resources.lib.gui.tvshowMenus import Menus Menus().shows_recently_watched() elif action == "toggleLanguageInvoker": from resources.lib.common.maintenance import toggle_reuselanguageinvoker toggle_reuselanguageinvoker()
def traktManager(self, actionArgs): trakt_object = tools.get_item_information(actionArgs)['trakt_object'] actionArgs = json.loads(tools.unquote(actionArgs)) type = actionArgs['item_type'].title() hide_type = actionArgs['item_type'].title() if trakt_object == None: tools.showDialog.notification( tools.addonName, 'There may be an issue with the Trakt service, please clear cache and wait' ) dialog_list = [ 'Add to Collection', 'Remove from Collection', 'Add to Watchlist', 'Remove from Watchlist', 'Mark as Watched', 'Mark as Unwatched', 'Add to List', 'Remove From List', 'Hide %s' % hide_type, 'Refresh %s Metadata' % type, 'Remove %s Progress' % type ] if type in ['Show', 'Season']: dialog_list.pop(10) selection = tools.showDialog.select( tools.addonName + ': Trakt Manager', dialog_list) thread = None if selection == 0: thread = threading.Thread(target=self.addToCollection, args=(trakt_object, )) elif selection == 1: thread = threading.Thread(target=self.removeFromCollection, args=(trakt_object, )) elif selection == 2: thread = threading.Thread(target=self.addToWatchList, args=(trakt_object, )) elif selection == 3: thread = threading.Thread(target=self.removeFromWatchlist, args=(trakt_object, )) elif selection == 4: thread = threading.Thread(target=self.markWatched, args=(trakt_object, actionArgs)) elif selection == 5: thread = threading.Thread(target=self.markUnwatched, args=(trakt_object, actionArgs)) elif selection == 6: self.addToList(trakt_object) elif selection == 7: self.removeFromList(trakt_object) elif selection == 8: self.hideItem(actionArgs) elif selection == 9: self.refresh_meta_information(trakt_object) elif selection == 10: self.removePlaybackHistory(trakt_object) else: return if thread is not None: thread.start() return
def traktManager(self, actionArgs): item_information = tools.get_item_information(actionArgs) trakt_object = item_information['trakt_object'] trakt_id = item_information['ids']['trakt'] actionArgs = json.loads(tools.unquote(actionArgs)) type = actionArgs['item_type'].lower() display_type = self._get_display_name(type) if trakt_object is None: tools.showDialog.notification(tools.addonName, tools.lang(40264)) dialog_list = [] if item_information['info']['playcount'] > 0: dialog_list.append(tools.lang(40270)) else: dialog_list.append(tools.lang(40269)) if 'movies' in trakt_object: from resources.lib.modules.trakt_sync.movies import TraktSyncDatabase collection = [ i['trakt_id'] for i in TraktSyncDatabase().get_collected_movies() ] if trakt_id in collection: dialog_list.append(tools.lang(40266) % display_type) else: dialog_list.append(tools.lang(40265) % display_type) else: from resources.lib.modules.trakt_sync.shows import TraktSyncDatabase collection = TraktSyncDatabase().get_collected_episodes() collection = [i for i in collection if i is not None] collection = list(set([i['show_id'] for i in collection])) trakt_id = trakt_object['show_id'] = actionArgs['trakt_id'] if trakt_id in collection: dialog_list.append(tools.lang(40266) % display_type) else: dialog_list.append(tools.lang(40265) % display_type) pass standard_list = [ tools.lang(40267), tools.lang(40268), tools.lang(40271), tools.lang(40272), tools.lang(40273) % display_type, tools.lang(40274) ] for i in standard_list: dialog_list.append(i) if not type in ['show', 'season']: dialog_list.append(tools.lang(40275)) selection = tools.showDialog.select( '{}: {}'.format(tools.addonName, tools.lang(40280)), dialog_list) if selection == -1: return thread = None if dialog_list[selection] == tools.lang(40265) % display_type: thread = threading.Thread(target=self.addToCollection, args=(trakt_object, )) elif dialog_list[selection] == tools.lang(40266) % display_type: thread = threading.Thread(target=self.removeFromCollection, args=(trakt_object, )) elif dialog_list[selection] == tools.lang(40267): thread = threading.Thread(target=self.addToWatchList, args=(trakt_object, )) elif dialog_list[selection] == tools.lang(40268): thread = threading.Thread(target=self.removeFromWatchlist, args=(trakt_object, )) elif dialog_list[selection] == tools.lang(40269): thread = threading.Thread(target=self.markWatched, args=(trakt_object, actionArgs)) elif dialog_list[selection] == tools.lang(40270): thread = threading.Thread(target=self.markUnwatched, args=(trakt_object, actionArgs)) elif dialog_list[selection] == tools.lang(40271): self.addToList(trakt_object) elif dialog_list[selection] == tools.lang(40272): self.removeFromList(trakt_object) elif dialog_list[selection] == tools.lang(40273) % display_type: self.hideItem(actionArgs) elif dialog_list[selection] == tools.lang(40274): self.refresh_meta_information(trakt_object) elif dialog_list[selection] == tools.lang(40275): self.removePlaybackHistory(trakt_object) else: return if thread is not None: thread.start() return
def api(params): from resources.lib.common import tools from resources.lib.modules import database tools.SETTINGS_CACHE = {} try: url = params.get('url') action = params.get('action') page = params.get('page') actionArgs = params.get('actionArgs') pack_select = params.get('packSelect') source_select = params.get('source_select') seren_reload = params.get('seren_reload') if seren_reload == 'true': seren_reload = True except: print('Welcome to console mode') print('Command Help:') print(' - Menu Number: opens the relevant menu page') print(' - shell: opens a interactive python shell within Seren') print(' - action xxx: run a custom Seren URL argument') url = '' action = None page = '' actionArgs = '' pack_select = '' source_select = '' seren_reload = '' unit_tests = params.get('unit_tests', False) if unit_tests: tools.enable_unit_tests() tools.log('Seren, Running Path - Action: %s, actionArgs: %s' % (action, actionArgs)) if action == None: from resources.lib.gui import homeMenu homeMenu.Menus().home() if action == 'smartPlay': from resources.lib.modules import smartPlay smartPlay.SmartPlay(actionArgs).fill_playlist() if action == 'playbackResume': from resources.lib.modules import smartPlay smart = smartPlay.SmartPlay(actionArgs) smart.workaround() if action == 'moviesHome': from resources.lib.gui import movieMenus movieMenus.Menus().discoverMovies() if action == 'moviesPopular': from resources.lib.gui import movieMenus movieMenus.Menus().moviesPopular(page) if action == 'moviesTrending': from resources.lib.gui import movieMenus movieMenus.Menus().moviesTrending(page) if action == 'moviesPlayed': from resources.lib.gui import movieMenus movieMenus.Menus().moviesPlayed(page) if action == 'moviesWatched': from resources.lib.gui import movieMenus movieMenus.Menus().moviesWatched(page) if action == 'moviesCollected': from resources.lib.gui import movieMenus movieMenus.Menus().moviesCollected(page) if action == 'moviesAnticipated': from resources.lib.gui import movieMenus movieMenus.Menus().moviesAnticipated(page) if action == 'moviesBoxOffice': from resources.lib.gui import movieMenus movieMenus.Menus().moviesBoxOffice() if action == 'moviesUpdated': from resources.lib.gui import movieMenus movieMenus.Menus().moviesUpdated(page) if action == 'moviesRecommended': from resources.lib.gui import movieMenus movieMenus.Menus().moviesRecommended() if action == 'moviesSearch': from resources.lib.gui import movieMenus movieMenus.Menus().moviesSearch(actionArgs) if action == 'moviesSearchResults': from resources.lib.gui import movieMenus movieMenus.Menus().moviesSearchResults(actionArgs) if action == 'moviesSearchHistory': from resources.lib.gui import movieMenus movieMenus.Menus().moviesSearchHistory() if action == 'myMovies': from resources.lib.gui import movieMenus movieMenus.Menus().myMovies() if action == 'moviesMyCollection': from resources.lib.gui import movieMenus movieMenus.Menus().myMovieCollection() if action == 'moviesMyWatchlist': from resources.lib.gui import movieMenus movieMenus.Menus().myMovieWatchlist() if action == 'moviesRelated': from resources.lib.gui import movieMenus movieMenus.Menus().moviesRelated(actionArgs) if action == 'colorPicker': tools.colorPicker() if action == 'authTrakt': from resources.lib.indexers import trakt trakt.TraktAPI().auth() if action == 'revokeTrakt': from resources.lib.indexers import trakt trakt.TraktAPI().revokeAuth() if action == 'getSources': try: from resources.lib.gui.windows.persistent_background import PersistentBackground item_information = tools.get_item_information(actionArgs) # Assume if we couldn't get information using the normal method, that it's the legacy method if item_information is None: item_information = actionArgs if not tools.premium_check(): tools.showDialog.ok(tools.addonName, tools.lang(40146), tools.lang(40147)) return None if tools.playList.getposition() == 0 and tools.getSetting( 'general.scrapedisplay') == '0': display_background = True else: display_background = False if tools.getSetting('general.scrapedisplay') == '1': tools.closeBusyDialog() if display_background: background = PersistentBackground('persistent_background.xml', tools.addonDir, actionArgs=actionArgs) background.setText(tools.lang(32045)) background.show() from resources.lib.modules import getSources uncached_sources, source_results, args = database.get( getSources.getSourcesHelper, 1, actionArgs, seren_reload=seren_reload, seren_sources=True) if len(source_results) <= 0: tools.showDialog.notification(tools.addonName, tools.lang(32047), time=5000) return if 'showInfo' in item_information: source_select_style = 'Episodes' else: source_select_style = 'Movie' if tools.getSetting( 'general.playstyle%s' % source_select_style) == '1' or source_select == 'true': try: background.setText(tools.lang(40135)) except: pass from resources.lib.modules import sourceSelect stream_link = sourceSelect.sourceSelect( uncached_sources, source_results, actionArgs) if stream_link is None: tools.showDialog.notification(tools.addonName, tools.lang(32047), time=5000) raise Exception else: try: background.setText(tools.lang(32046)) except: pass from resources.lib.modules import resolver resolver_window = resolver.Resolver('resolver.xml', tools.addonDir, actionArgs=actionArgs) stream_link = database.get(resolver_window.doModal, 1, source_results, args, pack_select, seren_reload=seren_reload) del resolver_window if stream_link is None: tools.closeBusyDialog() tools.showDialog.notification(tools.addonName, tools.lang(32047), time=5000) raise Exception try: background.close() except: pass try: del background except: pass from resources.lib.modules import player player.serenPlayer().play_source(stream_link, actionArgs) except: # Perform cleanup and make sure all open windows close and playlist is cleared try: tools.closeBusyDialog() except: pass try: background.close() except: pass try: del background except: pass try: sources_window.close() except: pass try: del sources_window except: pass try: resolver_window.close() except: pass try: del resolver_window except: pass try: tools.playList.clear() except: pass try: tools.closeOkDialog() except: pass try: tools.cancelPlayback() except: pass if action == 'preScrape': try: item_information = tools.get_item_information(actionArgs) if 'showInfo' in item_information: source_select_style = 'Episodes' else: source_select_style = 'Movie' from resources.lib.modules import getSources uncached_sources, source_results, args = database.get( getSources.getSourcesHelper, 1, actionArgs, seren_reload=seren_reload, seren_sources=True) if tools.getSetting('general.playstyle%s' % source_select_style) == '0': from resources.lib.modules import resolver from resources.lib.modules import resolver resolver_window = resolver.Resolver('resolver.xml', tools.addonDir, actionArgs=actionArgs) database.get(resolver_window.doModal, 1, source_results, args, pack_select, seren_reload=seren_reload) tools.setSetting(id='general.tempSilent', value='false') except: tools.setSetting(id='general.tempSilent', value='false') import traceback traceback.print_exc() pass tools.log('Pre-scraping completed') if action == 'authRealDebrid': from resources.lib.debrid import real_debrid real_debrid.RealDebrid().auth() if action == 'showsHome': from resources.lib.gui import tvshowMenus tvshowMenus.Menus().discoverShows() if action == 'myShows': from resources.lib.gui import tvshowMenus tvshowMenus.Menus().myShows() if action == 'showsMyCollection': from resources.lib.gui import tvshowMenus tvshowMenus.Menus().myShowCollection() if action == 'showsMyWatchlist': from resources.lib.gui import tvshowMenus tvshowMenus.Menus().myShowWatchlist() if action == 'showsMyProgress': from resources.lib.gui import tvshowMenus tvshowMenus.Menus().myProgress() if action == 'showsMyRecentEpisodes': from resources.lib.gui import tvshowMenus tvshowMenus.Menus().myRecentEpisodes() if action == 'showsPopular': from resources.lib.gui import tvshowMenus tvshowMenus.Menus().showsPopular(page) if action == 'showsRecommended': from resources.lib.gui import tvshowMenus tvshowMenus.Menus().showsRecommended() if action == 'showsTrending': from resources.lib.gui import tvshowMenus tvshowMenus.Menus().showsTrending(page) if action == 'showsPlayed': from resources.lib.gui import tvshowMenus tvshowMenus.Menus().showsPlayed(page) if action == 'showsWatched': from resources.lib.gui import tvshowMenus tvshowMenus.Menus().showsWatched(page) if action == 'showsCollected': from resources.lib.gui import tvshowMenus tvshowMenus.Menus().showsCollected(page) if action == 'showsAnticipated': from resources.lib.gui import tvshowMenus tvshowMenus.Menus().showsAnticipated(page) if action == 'showsUpdated': from resources.lib.gui import tvshowMenus tvshowMenus.Menus().showsUpdated(page) if action == 'showsSearch': from resources.lib.gui import tvshowMenus tvshowMenus.Menus().showsSearch(actionArgs) if action == 'showsSearchResults': from resources.lib.gui import tvshowMenus tvshowMenus.Menus().showsSearchResults(actionArgs) if action == 'showsSearchHistory': from resources.lib.gui import tvshowMenus tvshowMenus.Menus().showSearchHistory() if action == 'showSeasons': from resources.lib.gui import tvshowMenus tvshowMenus.Menus().showSeasons(actionArgs) if action == 'seasonEpisodes': from resources.lib.gui import tvshowMenus tvshowMenus.Menus().seasonEpisodes(actionArgs) if action == 'showsRelated': from resources.lib.gui import tvshowMenus tvshowMenus.Menus().showsRelated(actionArgs) if action == 'showYears': from resources.lib.gui import tvshowMenus tvshowMenus.Menus().showYears(actionArgs, page) if action == 'searchMenu': from resources.lib.gui import homeMenu homeMenu.Menus().searchMenu() if action == 'toolsMenu': from resources.lib.gui import homeMenu homeMenu.Menus().toolsMenu() if action == 'clearCache': from resources.lib.common import tools tools.clearCache() if action == 'traktManager': from resources.lib.indexers import trakt trakt.TraktAPI().traktManager(actionArgs) if action == 'onDeckShows': from resources.lib.gui import tvshowMenus tvshowMenus.Menus().onDeckShows() if action == 'onDeckMovies': from resources.lib.gui.movieMenus import Menus Menus().onDeckMovies() if action == 'cacheAssist': from resources.lib.modules import cacheAssist cacheAssist.CacheAssit(actionArgs) if action == 'tvGenres': from resources.lib.gui import tvshowMenus tvshowMenus.Menus().showGenres() if action == 'showGenresGet': from resources.lib.gui import tvshowMenus tvshowMenus.Menus().showGenreList(actionArgs, page) if action == 'movieGenres': from resources.lib.gui import movieMenus movieMenus.Menus().movieGenres() if action == 'movieGenresGet': from resources.lib.gui import movieMenus movieMenus.Menus().movieGenresList(actionArgs, page) if action == 'filePicker': from resources.lib.modules import smartPlay smartPlay.SmartPlay(actionArgs).torrent_file_picker() if action == 'shufflePlay': from resources.lib.modules import smartPlay try: smart = smartPlay.SmartPlay(actionArgs).shufflePlay() except: import traceback traceback.print_exc() pass if action == 'resetSilent': tools.setSetting('general.tempSilent', 'false') tools.showDialog.notification(tools.addonName + ": Silent scrape", tools.lang(32048), time=5000) if action == 'clearTorrentCache': from resources.lib.modules import database database.torrent_cache_clear() if action == 'openSettings': tools.execute('Addon.OpenSettings(%s)' % tools.addonInfo('id')) if action == 'myTraktLists': from resources.lib.indexers import trakt trakt.TraktAPI().myTraktLists(actionArgs) if action == 'traktList': from resources.lib.indexers import trakt trakt.TraktAPI().getListItems(actionArgs, page) if action == 'nonActiveAssistClear': from resources.lib.gui import debridServices debridServices.Menus().assist_non_active_clear() if action == 'debridServices': from resources.lib.gui import debridServices debridServices.Menus().home() if action == 'cacheAssistStatus': from resources.lib.gui import debridServices debridServices.Menus().get_assist_torrents() if action == 'premiumizeTransfers': from resources.lib.gui import debridServices debridServices.Menus().list_premiumize_transfers() if action == 'showsNextUp': from resources.lib.gui import tvshowMenus tvshowMenus.Menus().myNextUp() if action == 'runMaintenance': from resources.lib.common import maintenance maintenance.run_maintenance() if action == 'providerTools': from resources.lib.gui import homeMenu homeMenu.Menus().providerMenu() if action == 'adjustProviders': from resources.lib.modules import customProviders customProviders.providers().adjust_providers(actionArgs) if action == 'adjustPackage': from resources.lib.modules import customProviders customProviders.providers().adjust_providers(actionArgs, package_disable=True) if action == 'installProviders': from resources.lib.modules import customProviders customProviders.providers().install_package(actionArgs) if action == 'uninstallProviders': from resources.lib.modules import customProviders customProviders.providers().uninstall_package() if action == 'showsNew': from resources.lib.gui import tvshowMenus tvshowMenus.Menus().newShows() if action == 'realdebridTransfers': from resources.lib.gui import debridServices debridServices.Menus().list_RD_transfers() if action == 'cleanInstall': from resources.lib.common import maintenance maintenance.wipe_install() if action == 'buildPlaylistWorkaround': from resources.lib.modules import smartPlay smartPlay.SmartPlay(actionArgs).resume_playback() if action == 'premiumizeCleanup': from resources.lib.common import maintenance maintenance.premiumize_transfer_cleanup() if action == 'test2': tools.log('Nope') if action == 'manualProviderUpdate': from resources.lib.modules import customProviders customProviders.providers().manual_update() if action == 'clearSearchHistory': from resources.lib.modules import database database.clearSearchHistory() tools.showDialog.ok(tools.addonName, 'Search History has been cleared') if action == 'externalProviderInstall': from resources.lib.modules import customProviders confirmation = tools.showDialog.yesno(tools.addonName, tools.lang(40117)) if confirmation == 0: sys.exit() customProviders.providers().install_package(1, url=url) if action == 'externalProviderUninstall': from resources.lib.modules import customProviders confirmation = tools.showDialog.yesno(tools.addonName, tools.lang(40119) % url) if confirmation == 0: sys.exit() customProviders.providers().uninstall_package(package=url, silent=False) if action == 'showsNetworks': from resources.lib.gui import tvshowMenus tvshowMenus.Menus().showsNetworks() if action == 'showsNetworkShows': from resources.lib.gui import tvshowMenus tvshowMenus.Menus().showsNetworkShows(actionArgs, page) if action == 'movieYears': from resources.lib.gui import movieMenus movieMenus.Menus().movieYears() if action == 'movieYearsMovies': from resources.lib.gui import movieMenus movieMenus.Menus().movieYearsMovies(actionArgs, page) if action == 'syncTraktActivities': from resources.lib.modules.trakt_sync.activities import TraktSyncDatabase TraktSyncDatabase().sync_activities() if action == 'traktSyncTools': from resources.lib.gui import homeMenu homeMenu.Menus().traktSyncTools() if action == 'flushTraktActivities': from resources.lib.modules import trakt_sync trakt_sync.TraktSyncDatabase().flush_activities() if action == 'flushTraktDBMeta': from resources.lib.modules import trakt_sync trakt_sync.TraktSyncDatabase().clear_all_meta() if action == 'myFiles': from resources.lib.gui import myFiles myFiles.Menus().home() if action == 'myFilesFolder': from resources.lib.gui import myFiles myFiles.Menus().myFilesFolder(actionArgs) if action == 'myFilesPlay': from resources.lib.gui import myFiles myFiles.Menus().myFilesPlay(actionArgs) if action == 'forceTraktSync': from resources.lib.modules import trakt_sync from resources.lib.modules.trakt_sync.activities import TraktSyncDatabase trakt_sync.TraktSyncDatabase().flush_activities() TraktSyncDatabase().sync_activities() if action == 'rebuildTraktDatabase': from resources.lib.modules.trakt_sync import TraktSyncDatabase TraktSyncDatabase().re_build_database() if action == 'myUpcomingEpisodes': from resources.lib.gui import tvshowMenus tvshowMenus.Menus().myUpcomingEpisodes() if action == 'showsByActor': from resources.lib.gui import tvshowMenus tvshowMenus.Menus().showsByActor(actionArgs) if action == 'movieByActor': from resources.lib.gui import movieMenus movieMenus.Menus().moviesByActor(actionArgs) if action == 'playFromRandomPoint': from resources.lib.modules import smartPlay smartPlay.SmartPlay(actionArgs).play_from_random_point() if action == 'refreshProviders': from resources.lib.modules.customProviders import providers providers().update_known_providers() if unit_tests: items = tools.xbmcplugin.DIRECTORY.items tools.xbmcplugin.DIRECTORY.items = [] return items
def dispatch(params): from resources.lib.common import tools from resources.lib.modules import database tools.SETTINGS_CACHE = {} try: url = params.get('url') action = params.get('action') page = params.get('page') actionArgs = params.get('actionArgs') pack_select = params.get('packSelect') source_select = params.get('source_select') seren_reload = True if params.get('seren_reload') == 'true' else False resume = params.get('resume') forceresumeoff = True if params.get( 'forceresumeoff') == 'true' else False forceresumeon = True if params.get( 'forceresumeon') == 'true' else False smartPlay = True if params.get('smartPlay') == 'true' else False except: print('Welcome to console mode') print('Command Help:') print(' - Menu Number: opens the relevant menu page') print(' - shell: opens a interactive python shell within Seren') print(' - action xxx: run a custom Seren URL argument') url = '' action = None page = '' actionArgs = '' pack_select = '' source_select = '' seren_reload = '' resume = None forceresumeoff = True if params.get( 'forceresumeoff') == 'true' else False forceresumeon = True if params.get( 'forceresumeon') == 'true' else False smartPlay = True if params.get('smartPlay') == 'true' else False tools.log('Seren, Running Path - Action: %s, actionArgs: %s' % (action, actionArgs)) if action is None: from resources.lib.gui import homeMenu homeMenu.Menus().home() if action == 'smartPlay': from resources.lib.modules import smartPlay # if 'resume' not in actionArgs: # actionArgs = json.loads(actionArgs) # actionArgs['resume'] = sys.argv[3].split(':')[-1] # actionArgs = tools.quote(json.dumps(actionArgs, sort_keys=True)) smartPlay.SmartPlay(actionArgs).fill_playlist() if action == 'playbackResume': from resources.lib.modules import smartPlay smart = smartPlay.SmartPlay(actionArgs) smart.workaround() if action == 'moviesHome': from resources.lib.gui import movieMenus movieMenus.Menus().discoverMovies() if action == 'moviesPopular': from resources.lib.gui import movieMenus movieMenus.Menus().moviesPopular(page) if action == 'moviesTrending': from resources.lib.gui import movieMenus movieMenus.Menus().moviesTrending(page) if action == 'moviesPlayed': from resources.lib.gui import movieMenus movieMenus.Menus().moviesPlayed(page) if action == 'moviesWatched': from resources.lib.gui import movieMenus movieMenus.Menus().moviesWatched(page) if action == 'moviesCollected': from resources.lib.gui import movieMenus movieMenus.Menus().moviesCollected(page) if action == 'moviesAnticipated': from resources.lib.gui import movieMenus movieMenus.Menus().moviesAnticipated(page) if action == 'moviesBoxOffice': from resources.lib.gui import movieMenus movieMenus.Menus().moviesBoxOffice() if action == 'moviesUpdated': from resources.lib.gui import movieMenus movieMenus.Menus().moviesUpdated(page) if action == 'moviesRecommended': from resources.lib.gui import movieMenus movieMenus.Menus().moviesRecommended() if action == 'moviesSearch': from resources.lib.gui import movieMenus movieMenus.Menus().moviesSearch(actionArgs) if action == 'moviesSearchResults': from resources.lib.gui import movieMenus movieMenus.Menus().moviesSearchResults(actionArgs) if action == 'moviesSearchHistory': from resources.lib.gui import movieMenus movieMenus.Menus().moviesSearchHistory() if action == 'myMovies': from resources.lib.gui import movieMenus movieMenus.Menus().myMovies() if action == 'moviesMyCollection': from resources.lib.gui import movieMenus movieMenus.Menus().myMovieCollection() if action == 'moviesMyWatchlist': from resources.lib.gui import movieMenus movieMenus.Menus().myMovieWatchlist() if action == 'moviesRelated': from resources.lib.gui import movieMenus movieMenus.Menus().moviesRelated(actionArgs) if action == 'colorPicker': tools.colorPicker() if action == 'authTrakt': from resources.lib.indexers import trakt trakt.TraktAPI().auth() if action == 'revokeTrakt': from resources.lib.indexers import trakt trakt.TraktAPI().revokeAuth() if action == 'getSources': try: item_information = tools.get_item_information(actionArgs) # # This tomfoolery here is the new workaround for Seren to skip the building playlist window if tools.getSetting( 'smartplay.playlistcreate') == 'true' or smartPlay: if tools.playList.size() > 0: playlist_uris = [ tools.playList[i].getPath() for i in range(tools.playList.size()) ] else: playlist_uris = [] if ('showInfo' in item_information and tools.playList.size() == 0) \ or not any(sys.argv[2] in i for i in playlist_uris): try: name = item_information['info']['title'] item = tools.addDirectoryItem( name, 'getSources', item_information['info'], item_information['art'], item_information['cast'], isFolder=False, isPlayable=True, actionArgs=actionArgs, bulk_add=True, set_ids=item_information['ids']) tools.cancelPlayback() tools.playList.add(url=sys.argv[0] + sys.argv[2], listitem=item[1]) tools.player().play(tools.playList) return except: import traceback traceback.print_exc() return bookmark_style = tools.getSetting('general.bookmarkstyle') if tools.playList.size( ) == 1 and resume is not None and bookmark_style != '2' and not forceresumeoff: if bookmark_style == '0' and not forceresumeon: import datetime selection = tools.showDialog.contextmenu([ '{} {}'.format( tools.lang(32092), datetime.timedelta(seconds=int(resume))), tools.lang(40350) ]) if selection == -1: tools.cancelPlayback() sys.exit() elif selection != 0: resume = None else: resume = None # Assume if we couldn't get information using the normal method, that it's the legacy method if item_information is None: item_information = actionArgs if not tools.premium_check(): tools.showDialog.ok(tools.addonName, tools.lang(40146), tools.lang(40147)) return None if tools.playList.getposition() == 0 and tools.getSetting( 'general.scrapedisplay') == '0': display_background = True else: display_background = False from resources.lib.modules.skin_manager import SkinManager if display_background: from resources.lib.gui.windows.persistent_background import PersistentBackground background = PersistentBackground( *SkinManager().confirm_skin_path( 'persistent_background.xml'), actionArgs=actionArgs) background.setText(tools.lang(32045)) background.show() from resources.lib.modules import getSources uncached_sources, source_results, args = database.get( getSources.getSourcesHelper, 1, actionArgs, seren_reload=seren_reload, seren_sources=True) if len(source_results) <= 0: tools.showDialog.notification(tools.addonName, tools.lang(32047), time=5000) return if 'showInfo' in item_information: source_select_style = 'Episodes' else: source_select_style = 'Movie' if tools.getSetting( 'general.playstyle%s' % source_select_style) == '1' or source_select == 'true': try: background.setText(tools.lang(40135)) except: pass from resources.lib.modules import sourceSelect stream_link = sourceSelect.sourceSelect( uncached_sources, source_results, actionArgs) if stream_link is None: tools.showDialog.notification(tools.addonName, tools.lang(32047), time=5000) raise Exception if not stream_link: # user has backed out of source select, don't show no playable sources notification raise Exception else: try: background.setText(tools.lang(32046)) except: pass from resources.lib.modules import resolver resolver_window = resolver.Resolver( *SkinManager().confirm_skin_path('resolver.xml'), actionArgs=actionArgs) stream_link = database.get(resolver_window.doModal, 1, source_results, args, pack_select, seren_reload=seren_reload) del resolver_window if stream_link is None: tools.closeBusyDialog() tools.showDialog.notification(tools.addonName, tools.lang(32047), time=5000) raise Exception tools.showBusyDialog() try: background.close() except: pass try: del background except: pass from resources.lib.modules import player # if 'resume' not in actionArgs: # actionArgs = json.loads(actionArgs) # actionArgs['resume'] = sys.argv[3].split(':')[-1] # actionArgs = json.dumps(actionArgs, sort_keys=True) player.serenPlayer().play_source(stream_link, actionArgs, resume_time=resume, params=params) except: import traceback traceback.print_exc() # Perform cleanup and make sure all open windows close and playlist is cleared try: tools.closeBusyDialog() except: pass try: background.close() except: pass try: del background except: pass try: resolver_window.close() except: pass try: del resolver_window except: pass try: tools.playList.clear() except: pass try: tools.closeOkDialog() except: pass try: tools.cancelPlayback() except: pass if action == 'preScrape': from resources.lib.modules.skin_manager import SkinManager try: item_information = tools.get_item_information(actionArgs) if 'showInfo' in item_information: source_select_style = 'Episodes' else: source_select_style = 'Movie' from resources.lib.modules import getSources uncached_sources, source_results, args = database.get( getSources.getSourcesHelper, 1, actionArgs, seren_reload=seren_reload, seren_sources=True) if tools.getSetting('general.playstyle%s' % source_select_style) == '0': from resources.lib.modules import resolver resolver_window = resolver.Resolver( *SkinManager().confirm_skin_path('resolver.xml'), actionArgs=actionArgs) database.get(resolver_window.doModal, 1, source_results, args, pack_select, seren_reload=seren_reload) tools.setSetting(id='general.tempSilent', value='false') except: tools.setSetting(id='general.tempSilent', value='false') import traceback traceback.print_exc() pass tools.log('Pre-scraping completed') if action == 'authRealDebrid': from resources.lib.debrid import real_debrid real_debrid.RealDebrid().auth() if action == 'showsHome': from resources.lib.gui import tvshowMenus tvshowMenus.Menus().discoverShows() if action == 'myShows': from resources.lib.gui import tvshowMenus tvshowMenus.Menus().myShows() if action == 'showsMyCollection': from resources.lib.gui import tvshowMenus tvshowMenus.Menus().myShowCollection() if action == 'showsMyWatchlist': from resources.lib.gui import tvshowMenus tvshowMenus.Menus().myShowWatchlist() if action == 'showsMyProgress': from resources.lib.gui import tvshowMenus tvshowMenus.Menus().myProgress() if action == 'showsMyRecentEpisodes': from resources.lib.gui import tvshowMenus tvshowMenus.Menus().myRecentEpisodes() if action == 'showsPopular': from resources.lib.gui import tvshowMenus tvshowMenus.Menus().showsPopular(page) if action == 'showsRecommended': from resources.lib.gui import tvshowMenus tvshowMenus.Menus().showsRecommended() if action == 'showsTrending': from resources.lib.gui import tvshowMenus tvshowMenus.Menus().showsTrending(page) if action == 'showsPlayed': from resources.lib.gui import tvshowMenus tvshowMenus.Menus().showsPlayed(page) if action == 'showsWatched': from resources.lib.gui import tvshowMenus tvshowMenus.Menus().showsWatched(page) if action == 'showsCollected': from resources.lib.gui import tvshowMenus tvshowMenus.Menus().showsCollected(page) if action == 'showsAnticipated': from resources.lib.gui import tvshowMenus tvshowMenus.Menus().showsAnticipated(page) if action == 'showsUpdated': from resources.lib.gui import tvshowMenus tvshowMenus.Menus().showsUpdated(page) if action == 'showsSearch': from resources.lib.gui import tvshowMenus tvshowMenus.Menus().showsSearch(actionArgs) if action == 'showsSearchResults': from resources.lib.gui import tvshowMenus tvshowMenus.Menus().showsSearchResults(actionArgs) if action == 'showsSearchHistory': from resources.lib.gui import tvshowMenus tvshowMenus.Menus().showSearchHistory() if action == 'showSeasons': from resources.lib.gui import tvshowMenus tvshowMenus.Menus().showSeasons(actionArgs) if action == 'seasonEpisodes': from resources.lib.gui import tvshowMenus tvshowMenus.Menus().seasonEpisodes(actionArgs) if action == 'showsRelated': from resources.lib.gui import tvshowMenus tvshowMenus.Menus().showsRelated(actionArgs) if action == 'showYears': from resources.lib.gui import tvshowMenus tvshowMenus.Menus().showYears(actionArgs, page) if action == 'searchMenu': from resources.lib.gui import homeMenu homeMenu.Menus().searchMenu() if action == 'toolsMenu': from resources.lib.gui import homeMenu homeMenu.Menus().toolsMenu() if action == 'clearCache': from resources.lib.common import tools tools.clearCache() if action == 'traktManager': from resources.lib.indexers import trakt trakt.TraktAPI().traktManager(actionArgs) if action == 'onDeckShows': from resources.lib.gui import tvshowMenus tvshowMenus.Menus().onDeckShows() if action == 'onDeckMovies': from resources.lib.gui.movieMenus import Menus Menus().onDeckMovies() if action == 'cacheAssist': from resources.lib.modules import cacheAssist cacheAssist.CacheAssit(actionArgs) if action == 'tvGenres': from resources.lib.gui import tvshowMenus tvshowMenus.Menus().showGenres() if action == 'showGenresGet': from resources.lib.gui import tvshowMenus tvshowMenus.Menus().showGenreList(actionArgs, page) if action == 'movieGenres': from resources.lib.gui import movieMenus movieMenus.Menus().movieGenres() if action == 'movieGenresGet': from resources.lib.gui import movieMenus movieMenus.Menus().movieGenresList(actionArgs, page) if action == 'filePicker': from resources.lib.modules import smartPlay smartPlay.SmartPlay(actionArgs).torrent_file_picker() if action == 'shufflePlay': from resources.lib.modules import smartPlay try: smart = smartPlay.SmartPlay(actionArgs).shufflePlay() except: import traceback traceback.print_exc() pass if action == 'resetSilent': tools.setSetting('general.tempSilent', 'false') tools.showDialog.notification('{}: {}'.format(tools.addonName, tools.lang(40296)), tools.lang(32048), time=5000) if action == 'clearTorrentCache': from resources.lib.modules import database database.torrent_cache_clear() if action == 'openSettings': tools.execute('Addon.OpenSettings(%s)' % tools.addonInfo('id')) if action == 'myTraktLists': from resources.lib.indexers import trakt trakt.TraktAPI().myTraktLists(actionArgs) if action == 'traktList': from resources.lib.indexers import trakt trakt.TraktAPI().getListItems(actionArgs, page) if action == 'nonActiveAssistClear': from resources.lib.gui import debridServices debridServices.Menus().assist_non_active_clear() if action == 'debridServices': from resources.lib.gui import debridServices debridServices.Menus().home() if action == 'cacheAssistStatus': from resources.lib.gui import debridServices debridServices.Menus().get_assist_torrents() if action == 'premiumizeTransfers': from resources.lib.gui import debridServices debridServices.Menus().list_premiumize_transfers() if action == 'showsNextUp': from resources.lib.gui import tvshowMenus tvshowMenus.Menus().myNextUp() if action == 'runMaintenance': from resources.lib.common import maintenance maintenance.run_maintenance() if action == 'providerTools': from resources.lib.gui import homeMenu homeMenu.Menus().providerMenu() if action == 'adjustProviders': tools.log('adjustProviders endpoint has been deprecated') return # from resources.lib.modules import customProviders # # customProviders.providers().adjust_providers(actionArgs) if action == 'adjustPackage': tools.log('adjustPackage endpoint has been deprecated') return # DEPRECATED # from resources.lib.modules import customProviders # # customProviders.providers().adjust_providers(actionArgs, package_disable=True) if action == 'installProviders': from resources.lib.modules import customProviders customProviders.providers().install_package(actionArgs) if action == 'uninstallProviders': from resources.lib.modules import customProviders customProviders.providers().uninstall_package() if action == 'showsNew': from resources.lib.gui import tvshowMenus tvshowMenus.Menus().newShows() if action == 'realdebridTransfers': from resources.lib.gui import debridServices debridServices.Menus().list_RD_transfers() if action == 'cleanInstall': from resources.lib.common import maintenance maintenance.wipe_install() if action == 'buildPlaylistWorkaround': from resources.lib.modules import smartPlay smartPlay.SmartPlay(actionArgs).resume_playback() if action == 'premiumizeCleanup': from resources.lib.common import maintenance maintenance.premiumize_transfer_cleanup() if action == 'test2': pass if action == 'manualProviderUpdate': from resources.lib.modules import customProviders customProviders.providers().manual_update() if action == 'clearSearchHistory': from resources.lib.modules import database database.clearSearchHistory() if action == 'externalProviderInstall': from resources.lib.modules import customProviders confirmation = tools.showDialog.yesno(tools.addonName, tools.lang(40117)) if confirmation == 0: sys.exit() customProviders.providers().install_package(1, url=url) if action == 'externalProviderUninstall': from resources.lib.modules import customProviders confirmation = tools.showDialog.yesno(tools.addonName, tools.lang(40119) % url) if confirmation == 0: sys.exit() customProviders.providers().uninstall_package(package=url, silent=False) if action == 'showsNetworks': from resources.lib.gui import tvshowMenus tvshowMenus.Menus().showsNetworks() if action == 'showsNetworkShows': from resources.lib.gui import tvshowMenus tvshowMenus.Menus().showsNetworkShows(actionArgs, page) if action == 'movieYears': from resources.lib.gui import movieMenus movieMenus.Menus().movieYears() if action == 'movieYearsMovies': from resources.lib.gui import movieMenus movieMenus.Menus().movieYearsMovies(actionArgs, page) if action == 'syncTraktActivities': from resources.lib.modules.trakt_sync.activities import TraktSyncDatabase TraktSyncDatabase().sync_activities() if action == 'traktSyncTools': from resources.lib.gui import homeMenu homeMenu.Menus().traktSyncTools() if action == 'flushTraktActivities': from resources.lib.modules import trakt_sync trakt_sync.TraktSyncDatabase().flush_activities() if action == 'flushTraktDBMeta': from resources.lib.modules import trakt_sync trakt_sync.TraktSyncDatabase().clear_all_meta() if action == 'myFiles': from resources.lib.gui import myFiles myFiles.Menus().home() if action == 'myFilesFolder': from resources.lib.gui import myFiles myFiles.Menus().myFilesFolder(actionArgs) if action == 'myFilesPlay': from resources.lib.gui import myFiles myFiles.Menus().myFilesPlay(actionArgs) if action == 'forceTraktSync': from resources.lib.modules import trakt_sync from resources.lib.modules.trakt_sync.activities import TraktSyncDatabase trakt_sync.TraktSyncDatabase().flush_activities() TraktSyncDatabase().sync_activities() if action == 'rebuildTraktDatabase': from resources.lib.modules.trakt_sync import TraktSyncDatabase TraktSyncDatabase().re_build_database() if action == 'myUpcomingEpisodes': from resources.lib.gui import tvshowMenus tvshowMenus.Menus().myUpcomingEpisodes() if action == 'myWatchedEpisodes': from resources.lib.gui import tvshowMenus tvshowMenus.Menus().myWatchedEpisodes(page) if action == 'myWatchedMovies': from resources.lib.gui import movieMenus movieMenus.Menus().myWatchedMovies(page) if action == 'showsByActor': from resources.lib.gui import tvshowMenus tvshowMenus.Menus().showsByActor(actionArgs) if action == 'movieByActor': from resources.lib.gui import movieMenus movieMenus.Menus().moviesByActor(actionArgs) if action == 'playFromRandomPoint': from resources.lib.modules import smartPlay smartPlay.SmartPlay(actionArgs).play_from_random_point() if action == 'refreshProviders': from resources.lib.modules.customProviders import providers providers().update_known_providers() if action == 'installSkin': from resources.lib.modules.skin_manager import SkinManager SkinManager().install_skin() if action == 'uninstallSkin': from resources.lib.modules.skin_manager import SkinManager SkinManager().uninstall_skin() if action == 'switchSkin': from resources.lib.modules.skin_manager import SkinManager SkinManager().switch_skin() if action == 'manageProviders': tools.showBusyDialog() from resources.lib.gui.windows.custom_providers import CustomProviders from resources.lib.modules.skin_manager import SkinManager CustomProviders(*SkinManager().confirm_skin_path( 'custom_providers.xml')).doModal() if action == 'flatEpisodes': from resources.lib.gui.tvshowMenus import Menus Menus().flat_episode_list(actionArgs) if action == 'runPlayerDialogs': from resources.lib.modules.player import PlayerDialogs try: PlayerDialogs().display_dialog() except: import traceback traceback.print_exc() if action == 'authAllDebrid': from resources.lib.debrid.all_debrid import AllDebrid AllDebrid().auth() if action == 'checkSkinUpdates': from resources.lib.modules.skin_manager import SkinManager SkinManager().check_for_updates() if action == 'authPremiumize': from resources.lib.debrid.premiumize import Premiumize Premiumize().auth()
def test_resolver(): resolver = mock_modules.Resolver(*SkinManager().confirm_skin_path('resolver.xml'), actionArgs=_mock_args) resolver.doModal([mock_source], tools.get_item_information(_mock_args), False)
def __init__(self, xml_file, location, actionArgs=None): try: super(BaseWindow, self).__init__(xml_file, location) except: tools.xmlWindow().__init__() tools.closeBusyDialog() self.canceled = False self.setProperty('texture.white', os.path.join(tools.IMAGES_PATH, 'white.png')) self.setProperty('seren.logo', tools.SEREN_LOGO_PATH) self.setProperty('seren.fanart', tools.SEREN_FANART_PATH) self.setProperty('settings.color', tools.get_user_text_color()) self.setProperty('test_pattern', os.path.join(tools.IMAGES_PATH, 'test_pattern.png')) self.setProperty('skin.dir', SkinManager().confirm_skin_path(xml_file)[1]) if actionArgs is None: return self.item_information = tools.get_item_information(actionArgs) for id, value in self.item_information['ids'].items(): self.setProperty('item.ids.%s_id' % id, str(value)) for i in self.item_information['art'].keys(): self.setProperty('item.art.%s' % i, str(self.item_information['art'][i])) self.item_information['info'] = tools.clean_air_dates( self.item_information['info']) year, month, day = self.item_information['info'].get( 'aired', '0000-00-00').split('-') self.setProperty('item.info.aired.year', year) self.setProperty('item.info.aired.month', month) self.setProperty('item.info.aired.day', day) try: if 'aired' in self.item_information['info']: aired_date = self.item_information['info']['aired'] aired_date = tools.datetime_workaround(aired_date) aired_date = aired_date.strftime(tools.get_region('dateshort')) self.item_information['info']['aired'] = aired_date if 'premiered' in self.item_information['info']: premiered = self.item_information['info']['premiered'] premiered = tools.datetime_workaround(premiered) premiered = premiered.strftime(tools.get_region('dateshort')) self.item_information['info']['premiered'] = premiered except: pass for i in self.item_information['info'].keys(): value = self.item_information['info'][i] if i == 'aired' or i == 'premiered': try: value = value[:10] except: value = 'TBA' if i == 'duration': try: hours = int(value) % 60 self.setProperty('item.info.%s.minutes' % i, str(int(value) - (hours * 60))) self.setProperty('item.info.%s.hours' % i, str(hours)) except: pass try: self.setProperty('item.info.%s' % i, str(value)) except UnicodeEncodeError: self.setProperty('item.info.%s' % i, value)