示例#1
0
    def get_list_items(self):
        arguments = g.REQUEST_PARAMS['action_args']
        media_type = g.REQUEST_PARAMS.get('media_type', arguments.get('type'))
        ignore_cache = True
        if g.REQUEST_PARAMS.get('from_widget') and g.REQUEST_PARAMS.get(
                'from_widget').lower() == "true":
            widget_loaded_setting = "widget_loaded.{}.{}".format(
                media_type, arguments)
            if not g.get_bool_runtime_setting(widget_loaded_setting):
                ignore_cache = False
                g.set_runtime_setting(widget_loaded_setting, True)
        list_items = self.lists_database.get_list_content(
            arguments['username'],
            arguments['trakt_id'],
            self._backwards_compatibility(media_type),
            ignore_cache=ignore_cache,
            page=g.PAGE,
            no_paging=self.no_paging)

        if not list_items:
            g.log(
                'Failed to pull list {} from Trakt/Database'.format(
                    arguments['trakt_id']), 'error')
            g.cancel_directory()
            return

        if media_type in ['tvshow', 'shows']:
            self.builder.show_list_builder(list_items,
                                           no_paging=self.no_paging)
        elif media_type in ['movie', 'movies']:
            self.builder.movie_menu_builder(list_items,
                                            no_paging=self.no_paging)
 def remove_from_index(self, url_hash):
     """
     Removes requested task id from the global index
     :param url_hash:
     :return:
     """
     self.download_ids.remove(url_hash)
     g.set_runtime_setting("SDMIndex", ",".join(self.download_ids))
 def update_task_info(self, url_hash, download_dict):
     """
     Updates download information stored in window property for download task
     :param url_hash: String
     :param download_dict: dict
     :return:
     """
     g.set_runtime_setting("sdm.{}".format(url_hash),
                           tools.construct_action_args(download_dict))
示例#4
0
 def do_cleanup(self):
     if self._exit or g.abort_requested():
         return
     if g.get_bool_runtime_setting(self._create_key("db.clean.busy")):
         return
     g.set_runtime_setting(self._create_key("db.clean.busy"), True)
     query = "DELETE FROM {} where expires < ?".format(self.cache_table_name)
     self.execute_sql(query, (self._get_timestamp(),))
     g.clear_runtime_setting(self._create_key("db.clean.busy"))
示例#5
0
    def do_cleanup(self):
        busy_key = "torrentcache.db.clean.busy"
        if g.get_bool_runtime_setting(busy_key):
            return
        g.set_runtime_setting(busy_key, True)

        self.execute_sql([
            "DELETE FROM {} where expires < ?".format(MOVIE_CACHE_TYPE),
            "DELETE FROM {} where expires < ?".format(TV_CACHE_TYPE)
        ], (time.time(), ))
        g.clear_runtime_setting(busy_key)
示例#6
0
    def do_cleanup(self):
        if self._exit or g.abort_requested():
            return
        if g.get_bool_runtime_setting(self._create_key("clean.busy")):
            return
        g.set_runtime_setting(self._create_key("clean.busy"), True)

        self._db_cache.do_cleanup()
        self._mem_cache.do_cleanup()

        g.set_runtime_setting(self._create_key("clean.lastexecuted"), CacheBase._get_timestamp())
        g.clear_runtime_setting(self._create_key("clean.busy"))
示例#7
0
    def set(self, cache_id, data, checksum=None, expiration=None):
        if expiration is None:
            expiration = datetime.timedelta(hours=24)

        expires = self._get_timestamp(expiration)
        cached = (expires, data, checksum)
        g.set_runtime_setting(
            cache_id,
            base64.standard_b64encode(pickle.dumps(cached)).decode(),
            )
        self._get_index()
        self._index.add((cache_id, expires))
        self._save_index()
示例#8
0
 def do_cleanup(self):
     if self._exit or g.abort_requested():
         return
     cur_time = datetime.datetime.utcnow()
     if g.get_runtime_setting(self._create_key("cache.db.clean.busy")):
         return
     g.set_runtime_setting(self._create_key("cache.db.clean.busy"), "busy")
     query = "DELETE FROM {} where expires < ?".format(
         self.cache_table_name)
     self.execute_sql(query, (self._get_timestamp(), ))
     g.set_runtime_setting(self._create_key("cache.mem.clean.busy"),
                           repr(cur_time))
     g.clear_runtime_setting(self._create_key("cache.mem.clean.busy"))
示例#9
0
 def check_cleanup(self):
     """
     Check if a cleanup should be run according to auto_clean_interval and process if required
     :return:
     :rtype:
     """
     cur_time = datetime.datetime.utcnow()
     lastexecuted = g.get_runtime_setting(
         self._create_key("clean.lastexecuted"))
     if not lastexecuted:
         g.set_runtime_setting(self._create_key("clean.lastexecuted"),
                               repr(cur_time))
     elif self._cleanup_required_check(lastexecuted, cur_time):
         self.do_cleanup()
示例#10
0
    def do_cleanup(self):
        if self._exit or g.abort_requested():
            return
        cur_timestamp = self._get_timestamp()
        if g.get_bool_runtime_setting(self._create_key("mem.clean.busy")):
            return
        g.set_runtime_setting(self._create_key("mem.clean.busy"), True)

        self._get_index()
        for cache_id, expires in self._index:
            if expires < cur_timestamp:
                g.clear_runtime_setting(cache_id)

        g.clear_runtime_setting(self._create_key("mem.clean.busy"))
示例#11
0
 def set(self,
         cache_id,
         data,
         checksum=None,
         expiration=datetime.timedelta(hours=24)):
     expires = self._get_timestamp(expiration)
     cached = (expires, data, checksum)
     g.set_runtime_setting(
         cache_id,
         codecs.encode(pickle.dumps(cached), "base64").decode(),
     )
     self._get_index()
     self._index.add((cache_id, expires))
     self._save_index()
示例#12
0
    def _mark_watched_dialog(self):
        if g.get_runtime_setting("marked_watched_dialog_open"):
            return

        if (self.getPlayingFile() and self._running_path
                and self._running_path != self.getPlayingFile()
                and self.watched_percentage < self.playCountMinimumPercent
                and (time.time() - self.playback_timestamp) > 600):
            xbmc.sleep(10000)
            g.set_runtime_setting("marked_watched_dialog_open", True)
            if xbmcgui.Dialog().yesno(g.ADDON_NAME,
                                      g.get_language_string(30526)):
                self._force_marked_watched = True
            g.set_runtime_setting("marked_watched_dialog_open", False)
示例#13
0
    def do_cleanup(self):
        if self._exit or g.abort_requested():
            return
        if g.get_runtime_setting(self._create_key("clean.busy")):
            return
        g.set_runtime_setting(self._create_key("clean.busy"), "busy")

        cur_time = datetime.datetime.utcnow()

        self._db_cache.do_cleanup()
        self._mem_cache.do_cleanup()

        g.set_runtime_setting(self._create_key("clean.lastexecuted"),
                              repr(cur_time))
        g.clear_runtime_setting(self._create_key("clean.busy"))
def update_provider_packages():
    """
    Perform checks for provider package updates
    :return: None
    :rtype: None
    """
    provider_check_stamp = g.get_float_runtime_setting(
        "provider.updateCheckTimeStamp", 0)
    automatic = g.get_bool_setting("providers.autoupdates")
    if time.time() > (provider_check_stamp + (24 * (60 * 60))):
        available_updates = ProviderInstallManager().check_for_updates(
            silent=True, automatic=automatic)
        if not automatic and len(available_updates) > 0:
            g.notification(g.ADDON_NAME, g.get_language_string(30268))
        g.set_runtime_setting("provider.updateCheckTimeStamp",
                              g.UNICODE(time.time()))
示例#15
0
 def onSettingsChanged(self):
     callback_time = int(time.time())
     if g.get_int_runtime_setting(
             "onSettingsChangedLastCalled") == callback_time:
         g.log("Debouncing onSettingsChange call", "debug")
         # This check is to debounce multiple onSettingsChange calls to the nearest second as the callbacks
         # can come a bit late after setting multiple settings programmatically and cause
         # the settings persisted flag to be cleared
         return
     g.set_runtime_setting("onSettingsChangedLastCalled", callback_time)
     g.log("SETTINGS UPDATED", "info")
     if g.SETTINGS_CACHE.get_settings_persisted_flag():
         return
     g.log("FLUSHING SETTINGS CACHE", "info")
     g.SETTINGS_CACHE.clear_cache()
     g.trigger_widget_refresh(if_playing=False)
示例#16
0
    def do_cleanup(self):
        if self._exit or g.abort_requested():
            return
        cur_time = datetime.datetime.utcnow()
        cur_timestamp = self._get_timestamp()
        if g.get_runtime_setting(self._create_key("cache.mem.clean.busy")):
            return
        g.set_runtime_setting(self._create_key("cache.mem.clean.busy"), "busy")

        self._get_index()
        for cache_id, expires in self._index:
            if expires < cur_timestamp:
                g.clear_runtime_setting(cache_id)

        g.set_runtime_setting(self._create_key("cache.mem.clean.busy"),
                              repr(cur_time))
        g.clear_runtime_setting(self._create_key("cache.mem.clean.busy"))
示例#17
0
    def pre_scrape():
        """
        Checks whether a item exists in the current playlist after current item and then pre-fetches results
        :return:
        :rtype:
        """
        next_position = g.PLAYLIST.getposition() + 1
        if next_position >= g.PLAYLIST.size():
            return

        url = g.PLAYLIST[  # pylint: disable=unsubscriptable-object
            next_position].getPath()

        if not url:
            return

        url = url.replace("getSources", "preScrape")
        g.set_runtime_setting("tempSilent", True)
        g.log("Running Pre-Scrape: {}".format(url))
        xbmc.executebuiltin('RunPlugin("{}")'.format(url))
示例#18
0
    def resolve_silent_or_visible(self,
                                  sources,
                                  item_information,
                                  pack_select=False,
                                  from_source_select=False,
                                  overwrite_cache=False):
        """
        Method to handle automatic background or foreground resolving
        :param sources: list of sources to handle
        :param item_information: information on item to play
        :param pack_select: True if you want to perform a manual file selection
        :param from_source_select: True if we were called from SS screen
        :param overwrite_cache: Set to true if you wish to overwrite the current cached return value
        :return: None if unsuccessful otherwise a playable object
        """
        stream_link = ""
        release_title = ""

        if g.get_bool_runtime_setting('tempSilent'):
            stream_link, release_title = Resolver(
            ).resolve_multiple_until_valid_link(sources, item_information,
                                                pack_select, True)
        else:
            try:
                window = ResolverWindow(
                    *SkinManager().confirm_skin_path('resolver.xml'),
                    item_information=item_information)
                stream_link, release_title = window.doModal(
                    sources,
                    pack_select,
                    from_source_select=from_source_select,
                )
            finally:
                del window

        if item_information['info'][
                'mediatype'] == g.MEDIA_EPISODE and release_title:
            g.set_runtime_setting(
                "last_resolved_release_title.{}".format(
                    item_information['info']['trakt_show_id']), release_title)
        return stream_link
示例#19
0
 def _save_index(self):
     cached_string = list(self._index)
     g.set_runtime_setting(self._index_key, cached_string)
示例#20
0
 def _run_id(self, i):
     g.set_runtime_setting(self._create_key(i), True)
     return i
示例#21
0
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":
        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

            seren_player = player.SerenPlayer()
            seren_player.play_source(stream_link,
                                     item_information,
                                     resume_time=resume_time)
            del seren_player

        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_runtime_setting("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_runtime_setting("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 == "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

        player_dialogs = PlayerDialogs()
        player_dialogs.display_dialog()
        del player_dialogs

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

    elif action == "chooseTimeZone":
        from resources.lib.modules.manual_timezone import choose_timezone
        choose_timezone()
 def _insert_into_index(self):
     """
     Inserts new ID into window index
     :return:
     """
     g.set_runtime_setting("SDMIndex", ",".join(self.download_ids))
示例#23
0
def check_for_addon_update():
    """
    Perform checks for addon updates and notify user of any available updates
    :return: None
    :rtype: None
    """
    if not g.get_bool_setting("general.checkAddonUpdates"):
        return

    if "-" in g.VERSION:
        g.set_runtime_setting("addon.updateCheckTimeStamp",
                              g.UNICODE(time.time()))
        return

    update_timestamp = g.get_float_runtime_setting(
        "addon.updateCheckTimeStamp")

    if time.time() > (update_timestamp + (24 * (60 * 60))):
        repo_xml = requests.get(
            "https://github.com/nixgates/nixgates/raw/master/repo/zips/addons.xml"
        )
        if not repo_xml.status_code == 200:
            g.log(
                "Could not connect to repo XML, status: {}".format(
                    repo_xml.status_code),
                "error",
            )
            return
        try:
            xml = tools.ElementTree.fromstring(repo_xml.text)

            for dir_tag in xml.iterfind(
                    "./addon[@id='repository.nixgates']/extension/dir"):
                minversion = dir_tag.get('minversion')
                maxversion = dir_tag.get('maxversion')
                if ((minversion is None and maxversion is None) or
                    (minversion and maxversion
                     and tools.compare_version_numbers(
                         minversion, g.KODI_FULL_VERSION, include_same=True)
                     and tools.compare_version_numbers(
                         g.KODI_FULL_VERSION, maxversion, include_same=True))
                        or
                    (maxversion is None and minversion
                     and tools.compare_version_numbers(
                         minversion, g.KODI_FULL_VERSION, include_same=True))
                        or
                    (minversion is None and maxversion
                     and tools.compare_version_numbers(
                         g.KODI_FULL_VERSION, maxversion, include_same=True))):
                    repo_version = _get_latest_repo_version(
                        dir_tag.find('info').text)
                    if tools.compare_version_numbers(g.CLEAN_VERSION,
                                                     repo_version):
                        xbmcgui.Dialog().ok(
                            g.ADDON_NAME,
                            g.get_language_string(30199).format(repo_version))
        except tools.ElementTree.ParseError as pe:
            g.log("Could not parse repo XML", "error")
        finally:
            g.set_runtime_setting("addon.updateCheckTimeStamp",
                                  g.UNICODE(time.time()))
示例#24
0
 def __exit__(self, exc_type, exc_val, exc_tb):
     if self._run_once:
         g.set_runtime_setting(self._create_key("RunOnce"), True)
         g.set_runtime_setting(self._create_key("CheckSum"), self._check_sum)
     g.clear_runtime_setting(self._create_key("Running"))
示例#25
0
 def _run(self):
     while not g.abort_requested() and self._running():
         if g.wait_for_abort(.100):
             break
     g.set_runtime_setting(self._create_key("Running"), True)
     self._check_ran_once_already()