예제 #1
0
    def _handle_collected_options(self, item_information, trakt_id,
                                  display_type):
        if item_information["info"]["mediatype"] == "movie":
            from resources.lib.database.trakt_sync.movies import TraktSyncDatabase

            collection = [
                i["trakt_id"]
                for i in TraktSyncDatabase().get_all_collected_movies()
            ]
            if trakt_id in collection:
                self.dialog_list.append(
                    g.get_language_string(30275).format(display_type))
            else:
                self.dialog_list.append(
                    g.get_language_string(30274).format(display_type))
        else:
            from resources.lib.database.trakt_sync.shows import TraktSyncDatabase

            collection = TraktSyncDatabase().get_collected_shows(
                force_all=True)
            collection = set(i["trakt_id"] for i in collection
                             if i is not None)
            trakt_id = self._get_show_id(item_information["info"])
            if trakt_id in collection:
                self.dialog_list.append(
                    g.get_language_string(30275).format(display_type))
            else:
                self.dialog_list.append(
                    g.get_language_string(30274).format(display_type))
 def on_deck_movies(self):
     hidden_movies = HiddenDatabase().get_hidden_items("progress_watched", "movies")
     bookmark_sync = BookmarkDatabase()
     bookmarked_items = [
         i
         for i in bookmark_sync.get_all_bookmark_items("movie")
         if i["trakt_id"] not in hidden_movies
     ][self.page_start:self.page_end]
     self.list_builder.movie_menu_builder(bookmarked_items)
예제 #3
0
    def _remove_playback_history(self, item_information):
        media_type = "movie"

        if item_information["mediatype"] != "movie":
            media_type = "episode"

        progress = self.trakt_api.get_json(
            "sync/playback/{}".format(media_type + "s"))
        if len(progress) == 0:
            return
        if media_type == "movie":
            progress_ids = [
                i["playback_id"] for i in progress
                if i["trakt_id"] == item_information["trakt_id"]
            ]
        else:
            progress_ids = [
                i["playback_id"] for i in progress
                if i["episode"]["trakt_id"] == item_information["trakt_id"]
            ]

        for i in progress_ids:
            self.trakt_api.delete_request("sync/playback/{}".format(i))

        from resources.lib.database.trakt_sync.bookmark import TraktSyncDatabase

        TraktSyncDatabase().remove_bookmark(item_information["trakt_id"])

        g.container_refresh()
        g.notification(g.ADDON_NAME, g.get_language_string(30301))
        g.trigger_widget_refresh()
예제 #4
0
    def _mark_unwatched(self, item_information):
        response = self.trakt_api.post_json(
            "sync/history/remove",
            self._info_to_trakt_object(item_information))

        if item_information["mediatype"] == "movie":
            from resources.lib.database.trakt_sync.movies import TraktSyncDatabase

            if not self._confirm_marked_unwatched(response, "movies"):
                return
            TraktSyncDatabase().mark_movie_unwatched(
                item_information["trakt_id"])

        else:
            from resources.lib.database.trakt_sync.shows import TraktSyncDatabase

            if not self._confirm_marked_unwatched(response, "episodes"):
                return
            if item_information["mediatype"] == "episode":
                TraktSyncDatabase().mark_episode_unwatched(
                    item_information["trakt_show_id"],
                    item_information["season"],
                    item_information["episode"],
                )
            elif item_information["mediatype"] == "season":
                show_id = item_information["trakt_show_id"]
                season_no = item_information["season"]
                TraktSyncDatabase().mark_season_watched(show_id, season_no, 0)
            elif item_information["mediatype"] == "tvshow":
                TraktSyncDatabase().mark_show_watched(
                    item_information["trakt_id"], 0)

        from resources.lib.database.trakt_sync.bookmark import TraktSyncDatabase

        TraktSyncDatabase().remove_bookmark(item_information["trakt_id"])

        g.notification(
            "{}: {}".format(g.ADDON_NAME, g.get_language_string(30286)),
            g.get_language_string(30289),
        )
        g.container_refresh()
        g.trigger_widget_refresh()
예제 #5
0
    def _add_to_collection(self, item_information):
        self.trakt_api.post("sync/collection",
                            self._info_to_trakt_object(item_information, True))

        if item_information["mediatype"] == "movie":
            from resources.lib.database.trakt_sync.movies import TraktSyncDatabase

            TraktSyncDatabase().mark_movie_collected(
                item_information["trakt_id"])
        else:
            from resources.lib.database.trakt_sync.shows import TraktSyncDatabase

            trakt_id = self._get_show_id(item_information)
            TraktSyncDatabase().mark_show_collected(trakt_id, 1)

        g.notification(
            "{}: {}".format(g.ADDON_NAME, g.get_language_string(30286)),
            g.get_language_string(30290),
        )
        g.trigger_widget_refresh()
예제 #6
0
    def _hide_item(self, item_information):
        from resources.lib.database.trakt_sync.hidden import TraktSyncDatabase

        if item_information['mediatype'] == "movie":
            section = "calendar"
            sections_display = [g.get_language_string(30298)]
            selection = 0
        else:
            sections = ["progress_watched", "calendar"]
            sections_display = [
                g.get_language_string(30297),
                g.get_language_string(30298)
            ]
            selection = xbmcgui.Dialog().select(
                "{}: {}".format(g.ADDON_NAME, g.get_language_string(30299)),
                sections_display,
            )
            if selection == -1:
                return
            section = sections[selection]

        self.trakt_api.post_json(
            "users/hidden/{}".format(section),
            self._info_to_trakt_object(item_information, True),
        )

        if item_information['mediatype'] == "movie":
            TraktSyncDatabase().add_hidden_item(item_information['trakt_id'],
                                                "movie", section)
        else:
            TraktSyncDatabase().add_hidden_item(
                item_information.get("trakt_show_id",
                                     item_information['trakt_id']), "tvshow",
                section)

        g.container_refresh()
        g.notification(
            g.ADDON_NAME,
            g.get_language_string(30300).format(sections_display[selection]),
        )
        g.trigger_widget_refresh()
예제 #7
0
    def _handle_progress_option(self, item_type, trakt_id):
        from resources.lib.database.trakt_sync.bookmark import TraktSyncDatabase

        if item_type not in ["show", "season"
                             ] and TraktSyncDatabase().get_bookmark(trakt_id):
            self.dialog_list.append(g.get_language_string(30284))