def shows_search_history(self):
     history = self.search_history.get_search_history("tvshow")
     g.add_directory_item(
         g.get_language_string(30182),
         action="showsSearch",
         description=g.get_language_string(30372),
     )
     g.add_directory_item(
         g.get_language_string(30180),
         action="clearSearchHistory",
         mediatype="tvshow",
         is_folder=False,
         description=g.get_language_string(30180),
     )
     for i in history:
         remove_path = g.create_url(
             g.BASE_URL,
             {
                 "action": "removeSearchHistory",
                 "mediatype": "tvshow",
                 "endpoint": i
             },
         )
         g.add_directory_item(
             i,
             action="showsSearchResults",
             action_args=tools.construct_action_args(i),
             cm=[(g.get_language_string(30565),
                  "RunPlugin({})".format(remove_path))],
         )
     g.close_directory(g.CONTENT_MENU)
 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:
     """
     self._win.setProperty("sdm.{}".format(url_hash),
                           tools.construct_action_args(download_dict))
示例#3
0
 def create_single_item_playlist_from_info(self):
     g.cancel_playback()
     name = self.item_information["info"]["title"]
     item = g.add_directory_item(
         name,
         action="getSources",
         menu_item=self.item_information,
         action_args=tools.construct_action_args(self.item_information),
         bulk_add=True,
         is_playable=True,
         )
     g.PLAYLIST.add(url=g.BASE_URL + "/?" + g.PARAM_STRING, listitem=item[1])
     return g.PLAYLIST
示例#4
0
 def shows_search_history():
     history = SearchHistory().get_search_history("tvshow")
     g.add_directory_item(
         g.get_language_string(30195),
         action="showsSearch",
         description=g.get_language_string(30394),
     )
     g.add_directory_item(
         g.get_language_string(30193),
         action="clearSearchHistory",
         mediatype="tvshow",
         is_folder=False,
         description=g.get_language_string(30193),
     )
     for i in history:
         g.add_directory_item(
             i,
             action="showsSearchResults",
             action_args=tools.construct_action_args(i),
         )
     g.close_directory(g.CONTENT_MENU)
示例#5
0
    def playlist_present_check(self, ignore_setting=False):
        """
        Confirms if a playlist is currently present. If not or playlist is for a different item, clear current list
        and build a new one
        :param ignore_setting: Force playlist building if setting is disabled
        :type ignore_setting: bool
        :return: Playlist if playlist is present else False
        :rtype: any
        """
        if g.get_bool_setting("smartplay.playlistcreate") or ignore_setting:

            if not self.item_information["info"]["mediatype"] == "episode":
                g.log("Movie playback requested, clearing playlist")
                g.PLAYLIST.clear()
                return False

            playlist_uris = [
                g.PLAYLIST[i].getPath()  # pylint: disable=unsubscriptable-object
                for i in range(g.PLAYLIST.size())
            ]

            # Check to see if we are just starting playback and kodi has created a playlist
            if len(playlist_uris) == 1 and playlist_uris[0].split(
                    '/')[-1] == sys.argv[2]:
                return False

            if [i for i in playlist_uris if g.ADDON_NAME.lower() not in i]:
                g.log("Cleaning up other addon items from playlsit", "debug")
                playlist_uris = []

            action_args = [
                dict(tools.parse_qsl(i.split("?")[-1])).get("action_args")
                for i in playlist_uris
            ]
            action_args = [i for i in action_args if i is not None]

            if not action_args:
                playlist_uris = []

            show_ids = set(
                tools.deconstruct_action_args(i).get('trakt_show_id')
                for i in action_args)

            if len(show_ids) > 1 and self.show_trakt_id not in show_ids:
                g.log("Cleaning up items from other shows", "debug")
                playlist_uris = []

            if len(playlist_uris) == 0 or (len(playlist_uris) > 1 and
                                           not any(sys.argv[2] in i
                                                   for i in playlist_uris)):
                g.cancel_playback()
                name = self.item_information["info"]["title"]
                item = g.add_directory_item(
                    name,
                    action="getSources",
                    menu_item=self.item_information,
                    action_args=tools.construct_action_args(
                        self.item_information),
                    bulk_add=True,
                    is_playable=True,
                )
                g.PLAYLIST.add(url=sys.argv[0] + sys.argv[2], listitem=item[1])
                return g.PLAYLIST
        return False