From ebbf37222e9659f79820f2c3d62d487119b6b83d Mon Sep 17 00:00:00 2001 From: mac12m99 <10120390+mac12m99@users.noreply.github.com> Date: Tue, 2 Nov 2021 19:58:01 +0100 Subject: [PATCH] Miglioria del precedente commit --- core/autoplay.py | 2 +- core/item.py | 3 +++ platformcode/launcher.py | 2 +- platformcode/platformtools.py | 19 +++++++++---------- platformcode/xbmc_videolibrary.py | 7 ++++++- specials/globalsearch.py | 2 +- specials/videolibrary.py | 8 ++++---- 7 files changed, 25 insertions(+), 18 deletions(-) diff --git a/core/autoplay.py b/core/autoplay.py index e03d28a0..dd5ea8f6 100644 --- a/core/autoplay.py +++ b/core/autoplay.py @@ -41,7 +41,7 @@ def start(itemlist, item): import xbmc control_item = Item().fromurl(xbmc.getInfoLabel('Container.FolderPath')) - if control_item.url == item.url: + if control_item == item: return itemlist if config.get_setting('autoplay') or item.autoplay: diff --git a/core/item.py b/core/item.py index 0bda66c9..ec8716d8 100644 --- a/core/item.py +++ b/core/item.py @@ -283,6 +283,9 @@ class Item(object): def __str__(self): return '\r\t' + self.tostring('\r\t') + def __eq__(self, other): + return self.__dict__ == other.__dict__ + def set_parent_content(self, parentContent): """ Fill the contentDetails fields with the information of the item "parent" diff --git a/platformcode/launcher.py b/platformcode/launcher.py index 637bc619..7b3af613 100644 --- a/platformcode/launcher.py +++ b/platformcode/launcher.py @@ -459,7 +459,7 @@ def play_from_library(item): from time import sleep # logger.debug("item: \n" + item.tostring('\n')) - platformtools.prevent_busy(item) + platformtools.prevent_busy() itemlist=[] item.fromLibrary = True diff --git a/platformcode/platformtools.py b/platformcode/platformtools.py index b654d307..9b2a809f 100644 --- a/platformcode/platformtools.py +++ b/platformcode/platformtools.py @@ -1387,7 +1387,7 @@ def set_player(item, xlistitem, mediaurl, view, strm): logger.info("mediaurl=" + mediaurl) if player_mode in [0,1]: - prevent_busy(item) + prevent_busy() if player_mode in [1]: item.played_time = resume_playback(get_played_time(item)) @@ -1491,11 +1491,7 @@ def play_torrent(item, xlistitem, mediaurl): selection = 0 if selection >= 0: - # if item.autoplay: xbmc.Player().play(os.path.join(config.get_runtime_path(), "resources", "kod.mp4")) - # else: xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, xbmcgui.ListItem(path=os.path.join(config.get_runtime_path(), "resources", "kod.mp4"))) - # xbmc.sleep(200) - # xbmc.Player().stop() - prevent_busy(item) + prevent_busy() mediaurl = urllib.quote_plus(item.url) torr_client = torrent_options[selection][0] @@ -1509,8 +1505,12 @@ def play_torrent(item, xlistitem, mediaurl): if torr_client in ['elementum'] and item.downloadFilename: torrent.elementum_download(item) else: - time.sleep(3) - xbmc.executebuiltin("PlayMedia(" + torrent_options[selection][1] % mediaurl + ")") + # time.sleep(3) + if item.fromLibrary: + xlistitem.setPath(torrent_options[selection][1] % mediaurl) + xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, xlistitem) + else: + xbmc.executebuiltin("PlayMedia(" + torrent_options[selection][1] % mediaurl + ")") # torrent.mark_auto_as_watched(item) @@ -1819,6 +1819,5 @@ def set_played_time(item): del db['viewed'][ID] - -def prevent_busy(item): +def prevent_busy(): xbmc.executebuiltin('Dialog.Close(all,true)') diff --git a/platformcode/xbmc_videolibrary.py b/platformcode/xbmc_videolibrary.py index 1f827cf5..95888db4 100644 --- a/platformcode/xbmc_videolibrary.py +++ b/platformcode/xbmc_videolibrary.py @@ -377,7 +377,12 @@ def set_watched_on_kod(data): path = filetools.join(path, filename) head_nfo, item = videolibrarytools.read_nfo(path) - item.library_playcounts.update({title: playcount}) + from core.support import dbg + dbg() + if item.library_playcounts: + item.library_playcounts.update({title: playcount}) + else: + item.library_playcounts = {title: playcount} filetools.write(path, head_nfo + item.tojson()) if item.infoLabels['mediatype'] == "tvshow": diff --git a/specials/globalsearch.py b/specials/globalsearch.py index 35b1c9d4..d5eb8e97 100644 --- a/specials/globalsearch.py +++ b/specials/globalsearch.py @@ -812,7 +812,7 @@ class SearchWindow(xbmcgui.WindowXML): def play(self, server=None): - platformtools.prevent_busy(server) + platformtools.prevent_busy() server.window = True server.globalsearch = True return run(server) diff --git a/specials/videolibrary.py b/specials/videolibrary.py index 75332b9d..982c161c 100644 --- a/specials/videolibrary.py +++ b/specials/videolibrary.py @@ -365,12 +365,12 @@ def findvideos(item): else: content_title = item.contentTitle.strip().lower() if item.contentType == 'movie': - item.strm_path = filetools.join(videolibrarytools.MOVIES_PATH, item.strm_path) - path_dir = filetools.dirname(item.strm_path) + strm_path = filetools.join(videolibrarytools.MOVIES_PATH, item.strm_path) + path_dir = filetools.dirname(strm_path) item.nfo = filetools.join(path_dir, filetools.basename(path_dir) + ".nfo") else: - item.strm_path = filetools.join(videolibrarytools.TVSHOWS_PATH, item.strm_path) - path_dir = filetools.dirname(item.strm_path) + strm_path = filetools.join(videolibrarytools.TVSHOWS_PATH, item.strm_path) + path_dir = filetools.dirname(strm_path) item.nfo = filetools.join(path_dir, 'tvshow.nfo') for fd in filetools.listdir(path_dir):