Esempio n. 1
0
def get_item_information(action_args):
    """
    Ease of use tool to retrieve items meta from TraktSyncDatabase based on action arguments
    :param action_args: action arguments received in call to newf
    :type action_args: dict
    :return: Metadata for item
    :rtype: dict
    """
    if action_args is None:
        return None
    item_information = {"action_args": action_args}
    if action_args["mediatype"] == "tvshow":
        from resources.lib.database.trakt_sync import shows

        item_information.update(shows.TraktSyncDatabase().get_show(
            action_args["trakt_id"]))
        return item_information
    elif action_args["mediatype"] == "season":
        from resources.lib.database.trakt_sync import shows

        item_information.update(shows.TraktSyncDatabase().get_season(
            action_args["trakt_id"], action_args["trakt_show_id"]))
        return item_information
    elif action_args["mediatype"] == "episode":
        from resources.lib.database.trakt_sync import shows

        item_information.update(shows.TraktSyncDatabase().get_episode(
            action_args["trakt_id"], action_args["trakt_show_id"]))
        return item_information
    elif action_args["mediatype"] == "movie":
        from resources.lib.database.trakt_sync import movies

        item_information.update(movies.TraktSyncDatabase().get_movie(
            action_args["trakt_id"]))
        return item_information
Esempio n. 2
0
    def legacy_action_args_converter(action_args):
        if "item_type" not in action_args:
            return action_args

        if "season" in action_args["item_type"]:
            from resources.lib.database.trakt_sync import shows

            action_args.update(
                shows.TraktSyncDatabase().get_season_action_args(
                    action_args["trakt_id"], action_args["season"]
                )
            )

        if "episode" in action_args["item_type"]:
            from resources.lib.database.trakt_sync import shows

            action_args.update(
                shows.TraktSyncDatabase().get_episode_action_args(
                    action_args["trakt_id"],
                    action_args["season"],
                    action_args["episode"],
                )
            )

        if "show" in action_args["item_type"]:
            action_args["item_type"] = "shows"

        action_args["mediatype"] = action_args.pop("item_type")
        return action_args
Esempio n. 3
0
 def __init__(self):
     self.trakt = TraktAPI()
     self.language_code = g.get_language_code()
     self.trakt_database = TraktSyncDatabase()
     self.hidden_database = hidden.TraktSyncDatabase()
     self.bookmark_database = bookmark.TraktSyncDatabase()
     self.shows_database = shows.TraktSyncDatabase()
     self.list_builder = ListBuilder()
     self.page_limit = g.get_int_setting("item.limit")
Esempio n. 4
0
 def season_list_builder(self, show_id, **params):
     """
     Builds a menu list of a shows seasons
     :param show_id: Trakt ID of show
     :param params: Parameters to send to common_menu_builder method
     :return: List list_items if smart_play Kwarg is True else None
     """
     return self._common_menu_builder(
         shows.TraktSyncDatabase().get_season_list(show_id, **params),
         g.CONTENT_SEASON, "seasonEpisodes", **params)
Esempio n. 5
0
    def mixed_episode_builder(self, trakt_list, **params):
        """
        Builds a menu list of episodes of mixed shows/seasons
        :param trakt_list: List of episode objects
        :param params: Parameters to send to common_menu_builder method
        :return: List list_items if smart_play Kwarg is True else None
        """
        params["is_folder"] = False
        params["is_playable"] = True
        params["mixed_list"] = True
        action = "getSources"

        return self._common_menu_builder(
            shows.TraktSyncDatabase().get_mixed_episode_list(
                trakt_list, **params), g.CONTENT_EPISODE, action, **params)
Esempio n. 6
0
    def show_list_builder(self, trakt_list, **params):
        """
        Builds a mneu list of shows
        :param trakt_list: List of show objects
        :param params: Parameters to send to common_menu_builder method
        :return: List list_items if smart_play Kwarg is True else None
        """
        action = "flatEpisodes" if self.flatten_episodes else "showSeasons"
        if g.get_bool_setting("smartplay.clickresume"):
            params["is_folder"] = False
            params["is_playable"] = True
            action = "forceResumeShow"

        self._common_menu_builder(
            shows.TraktSyncDatabase().get_show_list(trakt_list, **params),
            g.CONTENT_SHOW, action, **params)
Esempio n. 7
0
    def episode_list_builder(self, trakt_show_id, trakt_season=None, **params):
        """
        Builds a menu list of a episodes for specified show's season
        :param trakt_show_id: Trakt ID of show
        :param trakt_season: season number
        :param params: Parameters to send to common_menu_builder method
        :return: List list_items if smart_play Kwarg is True else None
        """
        params["is_folder"] = False
        params["is_playable"] = True
        action = "getSources"

        return self._common_menu_builder(
            shows.TraktSyncDatabase().get_episode_list(
                trakt_show_id,
                trakt_season,
                minimum_episode=params.pop("minimum_episode", None),
                **params), g.CONTENT_EPISODE, action, **params)