def __init__(self): self.apiKey = g.get_setting("tvdb.apikey", "43VPI0R8323FB7TI") self.jwToken = g.get_setting("tvdb.jw") self.tokenExpires = g.get_float_setting("tvdb.expiry") self.lang_code = g.get_language_code(False) self.languages = ([None, self.lang_code] if self.lang_code != "en" and any(self.lang_code == i["abbreviation"] for i in self.supported_languages) else [None]) if not self.jwToken: self.init_token() else: self.try_refresh_token() self.preferred_artwork_size = g.get_int_setting( "artwork.preferredsize") self.meta_hash = tools.md5_hash(( self.lang_code, self.art_map, self.baseUrl, self.imageBaseUrl, self.preferred_artwork_size, ))
def home(): g.add_directory_item(g.get_language_string(30000), action='moviesHome', description=g.get_language_string(30397)) g.add_directory_item(g.get_language_string(30002), action='showsHome', description=g.get_language_string(30398)) if g.get_setting('trakt.auth'): g.add_directory_item(g.get_language_string(30001), action='myMovies', description=g.get_language_string(30399)) if g.get_setting('trakt.auth'): g.add_directory_item(g.get_language_string(30003), action='myShows', description=g.get_language_string(30400)) if g.debrid_available(): g.add_directory_item(g.get_language_string(30190), action='myFiles', description=g.get_language_string(30401)) g.add_directory_item(g.get_language_string(30013), action='searchMenu', description=g.get_language_string(30402)) g.add_directory_item(g.get_language_string(30028), action='toolsMenu', description=g.get_language_string(30403)) g.close_directory(g.CONTENT_FOLDER)
def home(): g.add_directory_item(g.get_language_string(30000), action='moviesHome', description=g.get_language_string(30364)) g.add_directory_item(g.get_language_string(30002), action='showsHome', description=g.get_language_string(30365)) if g.get_setting('trakt.auth'): g.add_directory_item(g.get_language_string(30001), action='myMovies', description=g.get_language_string(30366)) if g.get_setting('trakt.auth'): g.add_directory_item(g.get_language_string(30003), action='myShows', description=g.get_language_string(30367)) if g.debrid_available(): g.add_directory_item(g.get_language_string(30173), action='myFiles', description=g.get_language_string(30368)) g.add_directory_item(g.get_language_string(30013), action='searchMenu', description=g.get_language_string(30369)) g.add_directory_item(g.get_language_string(30027), action='toolsMenu', description=g.get_language_string(30370)) g.close_directory(g.CONTENT_MENU)
def __init__(self): self.date_delay = g.get_bool_setting("general.datedelay") self.title_appends_mixed = g.get_setting("general.appendtitles") self.title_appends_general = g.get_setting( "general.appendepisodegeneral") self.flatten_episodes = g.get_bool_setting("general.flatten.episodes") self.page_limit = g.get_int_setting("item.limit") self.hide_unaired = g.get_bool_setting("general.hideUnAired") self.list_title_appends = g.get_setting("general.appendListTitles")
def _load_settings(self): self.client_id = g.get_setting( "trakt.clientid", "0c9a30819e4af6ffaf3b954cbeae9b54499088513863c03c02911de00ac2de79", ) self.client_secret = g.get_setting( "trakt.secret", "bf02417f27b514cee6a8d135f2ddc261a15eecfb6ed6289c36239826dcdd1842", ) self.access_token = g.get_setting("trakt.auth") self.refresh_token = g.get_setting("trakt.refresh") self.token_expires = g.get_float_setting("trakt.expires") self.default_limit = g.get_int_setting("item.limit") self.username = g.get_setting(self.username_setting_key)
def sync_activities(self, silent=False): with GlobalLock("trakt.sync"): trakt_auth = g.get_setting("trakt.auth") update_time = str(datetime.utcnow().strftime(g.DATE_TIME_FORMAT)) if not trakt_auth: g.log("TraktSync: No Trakt auth present, no sync will occur", "warning") return self.refresh_activities() remote_activities = self.fetch_remote_activities(silent) if remote_activities is None: g.log( "Activities Sync Failure: Unable to connect to Trakt or activities called to often", "error") return True if self.requires_update(remote_activities["all"], self.activities["all_activities"]): self._check_for_first_run(silent, trakt_auth) self._do_sync_acitivites(remote_activities) self._finalize_process(update_time) self._update_all_shows_statisics() self._update_all_season_statistics() return self.sync_errors
def sync_activities(self, silent=False): with GlobalLock("trakt.sync"): trakt_auth = g.get_setting("trakt.auth") update_time = str(datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%S")) if trakt_auth is None: g.log("TraktSync: No Trakt auth present, no sync will occur", "warning") return self.refresh_activities() remote_activites = self.trakt_api.get_json("sync/last_activities") if remote_activites is None: g.log("Activities Sync Failure: Unable to connect to Trakt", "error") return True if not self.requires_update(remote_activites["all"], self.activities["all_activities"]): return self._check_for_first_run(silent, trakt_auth) self._do_sync_acitivites(remote_activites) # Begin iterating sync items self._finalize_process(update_time) return self.sync_errors
def set_base_activities(self): self.execute_sql( "INSERT OR REPLACE INTO activities(sync_id, seren_version, trakt_username) VALUES(1, ?, ?)", (self.last_meta_update, g.get_setting("trakt.username")), ) self.activities = self.execute_sql( "SELECT * FROM activities WHERE sync_id=1").fetchone()
def __init__(self): self.apiKey = g.get_setting("tmdb.apikey", "9f3ca569aa46b6fb13931ec96ab8ae7e") self.lang_code = g.get_language_code() self.lang_full_code = g.get_language_code(True) self.lang_region_code = self.lang_full_code.split("-")[1] if self.lang_region_code == "": self.lang_full_code = self.lang_full_code.strip("-") self.include_languages = [ self.lang_code, "en", "null" ] if not self.lang_code == "en" else ["en", "null"] self.preferred_artwork_size = g.get_int_setting( "artwork.preferredsize") self.artwork_size = {} self._set_artwork() self.art_normalization = [ ("backdrops", "fanart", None), ( "posters", "poster", lambda x: x["iso_639_1"] != "xx" and x["iso_639_1"] is not None, ), ( "posters", "keyart", lambda x: x["iso_639_1"] == "xx" or x["iso_639_1"] is None, ), ("stills", "fanart", None), ]
def do_update_news(): if last_update_required == g.get_setting("update.news.version"): return for msg in [g.get_language_string(30571)]: xbmcgui.Dialog().ok(g.ADDON_NAME, msg) g.set_setting("update.news.version", last_update_required)
def do_version_change(): if g.get_setting("seren.version") == g.CLEAN_VERSION: return g.log("Clearing cache on Seren version change", "info") g.clear_cache(silent=True) g.set_setting("seren.version", g.CLEAN_VERSION)
def do_update_news(): if last_update_required == g.get_setting("update.news.version"): return for msg in update_messages: xbmcgui.Dialog().ok(g.ADDON_NAME, msg) g.set_setting("update.news.version", last_update_required)
def is_service_enabled(): """ Check to confirm api is enabled in Seren :return: :rtype: """ return (g.get_bool_setting("premiumize.enabled") and g.get_setting(PM_TOKEN_KEY) is not None)
def _get_checksum(class_name, func_name): relative_methods = {"TraktAPI": {"get_json_cached": ("item.limit", )}} settings = relative_methods.get(class_name, {}).get(func_name, []) checksum = "" for setting in settings: checksum += g.get_setting(setting) return checksum
def _get_filters(self): filter_string = g.get_setting("general.filters") current_filters = set() if filter_string is None else set(filter_string.split(",")) # Set HR filters and remove from set before returning due to HYBRID self.disable_dv = "DV" in current_filters self.disable_hdr = "HDR" in current_filters return current_filters.difference({"HDR", "DV"})
def __init__(self): self.headers = { "Authorization": "Bearer {}".format(g.get_setting(PM_TOKEN_KEY)) } self.premiumize_transfers = PremiumizeTransfers() self.progress_dialog = xbmcgui.DialogProgress() self.session = requests.Session() retries = Retry(total=5, backoff_factor=0.1, status_forcelist=[500, 502, 503, 504]) self.session.mount("https://", HTTPAdapter(max_retries=retries))
def __init__(self): self.language = g.get_language_code() self.client_key = g.get_setting('fanart.apikey') self.fanart_support = False if not self.client_key else True self.headers = {'client-key': self.client_key, 'api-key': self.api_key} self.meta_hash = tools.md5_hash([ self.language, self.fanart_support, self.normalization, self.show_normalization, self.meta_objects, self.base_url ])
def __init__(self): self.agent_identifier = g.ADDON_NAME self.apikey = g.get_setting(AD_AUTH_KEY) self.progress_dialog = xbmcgui.DialogProgress() self.session = requests.Session() retries = Retry(total=5, backoff_factor=0.1, status_forcelist=[429, 500, 502, 503, 504]) self.session.mount("https://", HTTPAdapter(max_retries=retries))
def __init__(self): super(SerenPlayer, self).__init__() self._trakt_api = trakt.TraktAPI() self.trakt_id = None self.mediatype = None self.offset = None self.playing_file = None self.scrobbling_enabled = g.get_bool_setting("trakt.scrobbling") self.item_information = None self.smart_playlists = g.get_bool_setting("smartplay.playlistcreate") self.default_action = g.get_int_setting("smartplay.defaultaction") self.smart_module = None self.current_time = 0 self.total_time = 0 self.watched_percentage = 0 self.ignoreSecondsAtStart = g.get_int_setting( "trakt.ignoreSecondsAtStart") self.min_time_before_scrape = max(self.total_time * 0.2, 600) self.playCountMinimumPercent = g.get_int_setting( "trakt.playCountMinimumPercent") self.intro_dialog_enabled = g.get_bool_setting("skip.intro.dialog") self.intro_dialog_delay = g.get_int_setting("skip.intro.dialog.delay") self.playing_next_dialog_enabled = g.get_bool_setting( "smartplay.playingnextdialog") self.still_watching_dialog_enabled = g.get_bool_setting( "smartplay.stillwatching") self.intro_dialog_open_time = g.get_int_setting("skip.intro.open.time") self.pre_scrape_enabled = g.get_bool_setting("smartPlay.preScrape") self.playing_next_time = g.get_int_setting("playingnext.time") self.skip_intro = g.get_bool_setting("skip.intro") self.skip_intro_from = g.get_int_setting("skip.intro.from") self.skip_intro_to = g.get_int_setting("skip.intro.to") self.force_skip = g.get_bool_setting("skip.intro.force") self.bookmark_sync = bookmark.TraktSyncDatabase() self.trakt_enabled = True if g.get_setting("trakt.auth", "") else False self._running_path = None # Flags self.default_pause = False self.default_exit = False self.resumed = False self.playback_started = False self.playback_error = False self.playback_ended = False self.playback_stopped = False self.scrobbled = False self.scrobble_started = False self._force_marked_watched = False self.intro_dialog_triggered = False self.playing_next_dialog_triggered = False self.still_watching_dialog_triggered = False self.pre_scrape_initiated = False self.playback_timestamp = 0 self.intro_skipped = False
def __init__(self): self.client_id = g.get_setting("rd.client_id") if not self.client_id: self.client_id = "GPA2MB33HLS3I" self.oauth_url = "https://api.real-debrid.com/oauth/v2/" self.device_code_url = "device/code?{}" self.device_credentials_url = "device/credentials?{}" self.token_url = "token" self.token = g.get_setting(RD_AUTH_KEY) self.session.headers.update( {"Authorization": "Bearer {}".format(self.token)}) self.refresh = g.get_setting(RD_REFRESH_KEY) self.expiry = g.get_float_setting(RD_EXPIRY_KEY) self.device_code = "" self.client_secret = g.get_setting(RD_SECRET_KEY) self.oauth_timeout = 0 self.oauth_time_step = 0 self.base_url = "https://api.real-debrid.com/rest/1.0/" self.cache_check_results = {} self.progress_dialog = xbmcgui.DialogProgress()
def __init__(self, xml_file, xml_location): super(FilterSelect, self).__init__(xml_file, xml_location) self.videocodec_list = None self.hdrcodec_list = None self.audiocodec_list = None self.audiochannels_list = None self.misc_list = None filter_string = g.get_setting("general.filters") self.current_filters = (set() if filter_string is None else set( filter_string.split(",")))
def __init__(self): self.language = g.get_language_code() self.client_key = g.get_setting('fanart.apikey') self.fanart_support = False if not self.client_key else True self.headers = {'client-key': self.client_key, 'api-key': self.api_key} self.meta_hash = tools.md5_hash( [self.language, self.fanart_support, self.normalization, self.show_normalization, self.meta_objects, self.base_url]) self.session = requests.Session() retries = Retry(total=5, backoff_factor=0.1, status_forcelist=[500, 502, 503, 504]) self.session.mount('https://', HTTPAdapter(max_retries=retries))
def __init__(self): self.apiKey = g.get_setting("tmdb.apikey", "9f3ca569aa46b6fb13931ec96ab8ae7e") self.lang_code = g.get_language_code() self.lang_full_code = g.get_language_code(True) self.lang_region_code = self.lang_full_code.split("-")[1] if self.lang_region_code == "": self.lang_full_code = self.lang_full_code.strip("-") self.include_languages = OrderedDict.fromkeys( [self.lang_code, "en", "null"]) self.preferred_artwork_size = g.get_int_setting( "artwork.preferredsize") self.artwork_size = {} self._set_artwork() self.art_normalization = [ ("backdrops", "fanart", None), ( "posters", "poster", lambda x: x["iso_639_1"] != "xx" and x["iso_639_1"] is not None, ), ( "posters", "keyart", lambda x: x["iso_639_1"] == "xx" or x["iso_639_1"] is None, ), ("stills", "fanart", None), ] self.meta_hash = tools.md5_hash(( self.lang_code, self.lang_full_code, self.lang_region_code, self.include_languages, self.preferred_artwork_size, self.append_to_response, self.baseUrl, self.imageBaseUrl, )) self.session = requests.Session() retries = Retry(total=5, backoff_factor=0.1, status_forcelist=[500, 502, 503, 504]) self.session.mount("https://", HTTPAdapter(max_retries=retries, pool_maxsize=100))
def choose_timezone(): current = g.get_setting("general.localtimezone") time_zones = [ i for i in pytz.common_timezones if len(i.split('/')) >= 2 and not i.split('/')[0] == 'US' ] # Note we deliberately don't include the US timezones as they have too many assumptions for historic dates try: preselect = time_zones.index(current) except ValueError: preselect = -1 tz_index = xbmcgui.Dialog().select(g.get_language_string(30548), time_zones, preselect=preselect) if not tz_index == -1: g.set_setting("general.localtimezone", time_zones[tz_index])
def do_version_change(): if g.get_setting("seren.version") == g.CLEAN_VERSION: return g.log("Clearing cache on Seren version change", "info") g.clear_cache(silent=True) g.set_setting("seren.version", g.CLEAN_VERSION) # Reuselanguageinvoker update. This should be last to execute as it can do a profile reload. # Disable the restoration of reuselanguageinvoker addon.xml based on settings value on upgrade. # It can still be toggled in settings, although initially it will be the release default value. # This is due to the fact that we still don't recommend having this enabled due to Kodi hard crashes. # maintenance.toggle_reuselanguageinvoker( # True if g.get_setting("reuselanguageinvoker") == "Enabled" else False) g.set_setting( "reuselanguageinvoker.status", "Disabled" ) # This ensures setting is reflected as disabled on version change
def do_update_news(): last_update_news_version = g.get_setting("update.news.version") max_update_news_version = max(update_news_versions) if not last_update_news_version: g.set_setting("update.news.version", max_update_news_version) return if max_update_news_version == last_update_news_version: return for msg in [ g.get_language_string(update_news_versions[v]) for v in sorted(update_news_versions) if v > last_update_news_version ]: xbmcgui.Dialog().ok( "{} - {}".format(g.ADDON_NAME, g.get_language_string(30567)), msg) g.set_setting("update.news.version", max_update_news_version)
def __init__(self): self.apiKey = g.get_setting("tmdb.apikey", "9f3ca569aa46b6fb13931ec96ab8ae7e") self.lang_code = g.get_language_code() self.lang_full_code = g.get_language_code(True) self.lang_region_code = self.lang_full_code.split("-")[1] if self.lang_region_code == "": self.lang_full_code = self.lang_full_code.strip("-") self.include_languages = OrderedDict.fromkeys( [self.lang_code, "en", "null"]) self.preferred_artwork_size = g.get_int_setting( "artwork.preferredsize") self.artwork_size = {} self._set_artwork() self.art_normalization = [ ("backdrops", "fanart", None), ( "posters", "poster", lambda x: x["iso_639_1"] != "xx" and x["iso_639_1"] is not None, ), ( "posters", "keyart", lambda x: x["iso_639_1"] == "xx" or x["iso_639_1"] is None, ), ("stills", "fanart", None), ] self.meta_hash = tools.md5_hash(( self.lang_code, self.lang_full_code, self.lang_region_code, self.include_languages, self.preferred_artwork_size, self.append_to_response, self.baseUrl, self.imageBaseUrl, ))
def discover_shows(): g.add_directory_item( g.get_language_string(30004), action="genericEndpoint", mediatype="shows", endpoint="popular", description=g.get_language_string(30416), ) g.add_directory_item( g.get_language_string(30345), action="showsPopularRecent", description=g.get_language_string(30417), ) if g.get_setting("trakt.auth"): g.add_directory_item( g.get_language_string(30005), action="showsRecommended", description=g.get_language_string(30418), ) g.add_directory_item( g.get_language_string(30006), action="genericEndpoint", mediatype="shows", endpoint="trending", description=g.get_language_string(30419), ) g.add_directory_item( g.get_language_string(30346), action="showsTrendingRecent", description=g.get_language_string(30420), ) g.add_directory_item( g.get_language_string(30046), action="showsNew", description=g.get_language_string(30421), ) g.add_directory_item( g.get_language_string(30007), action="genericEndpoint", mediatype="shows", endpoint="played", description=g.get_language_string(30422), ) g.add_directory_item( g.get_language_string(30008), action="genericEndpoint", mediatype="shows", endpoint="watched", description=g.get_language_string(30423), ) g.add_directory_item( g.get_language_string(30009), action="genericEndpoint", mediatype="shows", endpoint="collected", description=g.get_language_string(30424), ) g.add_directory_item( g.get_language_string(30352), action="TrendingLists", mediatype="shows", description=g.get_language_string(30425), ) g.add_directory_item( g.get_language_string(30354), action="PopularLists", mediatype="shows", description=g.get_language_string(30426), ) if not g.get_bool_setting("general.hideUnAired"): g.add_directory_item( g.get_language_string(30010), action="genericEndpoint", mediatype="shows", endpoint="anticipated", description=g.get_language_string(30427), ) g.add_directory_item( g.get_language_string(30011), action="showsUpdated", description=g.get_language_string(30428), ) g.add_directory_item( g.get_language_string(30169), action="showsNetworks", description=g.get_language_string(30429), ) g.add_directory_item( g.get_language_string(30171), action="showYears", description=g.get_language_string(30430), ) g.add_directory_item( g.get_language_string(30042), action="tvGenres", description=g.get_language_string(30431), ) g.add_directory_item( g.get_language_string(30190), action="showsByActor", description=g.get_language_string(30432), ) if not g.get_bool_setting("searchHistory"): g.add_directory_item( g.get_language_string(30013), action="showsSearch", description=g.get_language_string(30372), ) else: g.add_directory_item( g.get_language_string(30013), action="showsSearchHistory", description=g.get_language_string(30374), ) g.close_directory(g.CONTENT_MENU)
def discover_shows(): g.add_directory_item( g.get_language_string(30004), action="genericEndpoint", mediatype="shows", endpoint="popular", description=g.get_language_string(30438), ) g.add_directory_item( g.get_language_string(30367), action="showsPopularRecent", description=g.get_language_string(30439), ) if g.get_setting("trakt.auth"): g.add_directory_item( g.get_language_string(30005), action="showsRecommended", description=g.get_language_string(30440), ) g.add_directory_item( g.get_language_string(30006), action="genericEndpoint", mediatype="shows", endpoint="trending", description=g.get_language_string(30441), ) g.add_directory_item( g.get_language_string(30368), action="showsTrendingRecent", description=g.get_language_string(30442), ) g.add_directory_item( g.get_language_string(30046), action="showsNew", description=g.get_language_string(30443), ) g.add_directory_item( g.get_language_string(30007), action="genericEndpoint", mediatype="shows", endpoint="played", description=g.get_language_string(30444), ) g.add_directory_item( g.get_language_string(30008), action="genericEndpoint", mediatype="shows", endpoint="watched", description=g.get_language_string(30445), ) g.add_directory_item( g.get_language_string(30009), action="genericEndpoint", mediatype="shows", endpoint="collected", description=g.get_language_string(30446), ) g.add_directory_item( g.get_language_string(30374), action="TrendingLists", mediatype="shows", description=g.get_language_string(30447), ) g.add_directory_item( g.get_language_string(30376), action="PopularLists", mediatype="shows", description=g.get_language_string(30448), ) if not g.get_bool_setting("general.hideUnAired"): g.add_directory_item( g.get_language_string(30010), action="genericEndpoint", mediatype="shows", endpoint="anticipated", description=g.get_language_string(30449), ) g.add_directory_item( g.get_language_string(30011), action="showsUpdated", description=g.get_language_string(30450), ) g.add_directory_item( g.get_language_string(30182), action="showsNetworks", description=g.get_language_string(30451), ) g.add_directory_item( g.get_language_string(30184), action="showYears", description=g.get_language_string(30452), ) g.add_directory_item( g.get_language_string(30042), action="tvGenres", description=g.get_language_string(30453), ) g.add_directory_item( g.get_language_string(30203), action="showsByActor", description=g.get_language_string(30454), ) if not g.get_bool_setting("searchHistory"): g.add_directory_item( g.get_language_string(30013), action="showsSearch", description=g.get_language_string(30394), ) else: g.add_directory_item( g.get_language_string(30013), action="showsSearchHistory", description=g.get_language_string(30396), ) g.close_directory(g.CONTENT_MENU)
def discover_shows(): g.add_directory_item( g.get_language_string(30004), action="genericEndpoint", mediatype="shows", endpoint="popular", description=g.get_language_string(30450), ) g.add_directory_item( g.get_language_string(30378), action="showsPopularRecent", description=g.get_language_string(30451), ) if g.get_setting("trakt.auth"): g.add_directory_item( g.get_language_string(30005), action="showsRecommended", description=g.get_language_string(30452), ) g.add_directory_item( g.get_language_string(30006), action="genericEndpoint", mediatype="shows", endpoint="trending", description=g.get_language_string(30453), ) g.add_directory_item( g.get_language_string(30379), action="showsTrendingRecent", description=g.get_language_string(30454), ) g.add_directory_item( g.get_language_string(30047), action="showsNew", description=g.get_language_string(30455), ) g.add_directory_item( g.get_language_string(30007), action="genericEndpoint", mediatype="shows", endpoint="played", description=g.get_language_string(30456), ) g.add_directory_item( g.get_language_string(30008), action="genericEndpoint", mediatype="shows", endpoint="watched", description=g.get_language_string(30457), ) g.add_directory_item( g.get_language_string(30009), action="genericEndpoint", mediatype="shows", endpoint="collected", description=g.get_language_string(30458), ) g.add_directory_item( g.get_language_string(30385), action="TrendingLists", mediatype="shows", description=g.get_language_string(30459), ) g.add_directory_item( g.get_language_string(30387), action="PopularLists", mediatype="shows", description=g.get_language_string(30460), ) if not g.get_bool_setting("general.hideUnAired"): g.add_directory_item( g.get_language_string(30010), action="genericEndpoint", mediatype="shows", endpoint="anticipated", description=g.get_language_string(30461), ) g.add_directory_item( g.get_language_string(30011), action="showsUpdated", description=g.get_language_string(30462), ) g.add_directory_item( g.get_language_string(30186), action="showsNetworks", description=g.get_language_string(30463), ) g.add_directory_item( g.get_language_string(30188), action="showYears", description=g.get_language_string(30464), ) g.add_directory_item( g.get_language_string(30043), action="tvGenres", description=g.get_language_string(30465), ) g.add_directory_item( g.get_language_string(30212), action="showsByActor", description=g.get_language_string(30466), ) if not g.get_bool_setting("searchHistory"): g.add_directory_item( g.get_language_string(30013), action="showsSearch", description=g.get_language_string(30405), ) else: g.add_directory_item( g.get_language_string(30013), action="showsSearchHistory", description=g.get_language_string(30407), ) g.close_directory(g.CONTENT_FOLDER)