From e70c18efa3570fecc392291d355229e145b35469 Mon Sep 17 00:00:00 2001 From: Alhaziel01 Date: Fri, 29 Oct 2021 16:25:53 +0200 Subject: [PATCH] Probabile Fix Autoplay Torrent --- core/autoplay.py | 2 +- platformcode/elementum_download.py | 3 +++ platformcode/platformtools.py | 22 +++++++++++----------- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/core/autoplay.py b/core/autoplay.py index 1a8f3376..327c74b6 100644 --- a/core/autoplay.py +++ b/core/autoplay.py @@ -103,7 +103,7 @@ def start(itemlist, item): pass # sleep(3) try: - if platformtools.is_playing(): + if platformtools.is_playing() or autoplay_elem.server == 'torrent': PLAYED = True break except: diff --git a/platformcode/elementum_download.py b/platformcode/elementum_download.py index 4c33967f..b74a7f20 100644 --- a/platformcode/elementum_download.py +++ b/platformcode/elementum_download.py @@ -36,6 +36,9 @@ def download(item=None): support.info('URL:', url) if url: dl = downloadtools.downloadfile(host + url, filename) + if dl == -3: + filetools.remove(filename) + dl = downloadtools.downloadfile(host + url, filename) if dl == None: extract() xbmc.sleep(1000) diff --git a/platformcode/platformtools.py b/platformcode/platformtools.py index 5e0d666c..5f6eade1 100644 --- a/platformcode/platformtools.py +++ b/platformcode/platformtools.py @@ -1478,6 +1478,7 @@ def play_torrent(item, xlistitem, mediaurl): from servers import torrent torrent_options = torrent_client_installed(show_tuple=True) + # from core.support import dbg;dbg() if len(torrent_options) == 0: from platformcode import elementum_download install = elementum_download.download() @@ -1491,7 +1492,9 @@ def play_torrent(item, xlistitem, mediaurl): selection = 0 if selection >= 0: - prevent_busy(item) + xbmc.Player().play(os.path.join(config.get_runtime_path(), "resources", "kod.mp4")) + xbmc.sleep(200) + xbmc.Player().stop() mediaurl = urllib.quote_plus(item.url) torr_client = torrent_options[selection][0] @@ -1505,14 +1508,15 @@ def play_torrent(item, xlistitem, mediaurl): if torr_client in ['elementum'] and item.downloadFilename: torrent.elementum_download(item) else: - time.sleep(3) + # time.sleep(3) + # xbmc.Player().play(torrent_options[selection][1] % mediaurl) xbmc.executebuiltin("PlayMedia(" + torrent_options[selection][1] % mediaurl + ")") - torrent.mark_auto_as_watched(item) + # torrent.mark_auto_as_watched(item) - if not item.globalsearch: - while is_playing() and not xbmc.Monitor().abortRequested(): - time.sleep(3) + # if not item.globalsearch: + # while is_playing() and not xbmc.Monitor().abortRequested(): + # time.sleep(3) def resume_playback(played_time): @@ -1822,8 +1826,4 @@ def prevent_busy(item): if item.globalsearch: 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() - # xbmc.executebuiltin('Action(Stop)') - # xbmc.sleep(500) - # xbmc.Player().stop() - # xbmc.sleep(500) \ No newline at end of file + xbmc.Player().stop() \ No newline at end of file