From 547839f0b08304cf3fa983cbb0ede3998135d407 Mon Sep 17 00:00:00 2001 From: Alhaziel01 Date: Sat, 20 Nov 2021 10:22:17 +0100 Subject: [PATCH] Test Fix Torrent 3 --- platformcode/platformtools.py | 27 +++++++++++++++++---------- servers/torrent.py | 15 ++++++++++----- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/platformcode/platformtools.py b/platformcode/platformtools.py index a39e223e..678fad70 100644 --- a/platformcode/platformtools.py +++ b/platformcode/platformtools.py @@ -1504,18 +1504,25 @@ def play_torrent(item, xlistitem, mediaurl): torrent.elementum_download(item) else: + import xbmcaddon + addon = xbmcaddon.Addon(id='plugin.video.elementum') + # from core.support import dbg;dbg() + if addon.getSetting('download_storage') == '0': + addon.setSetting('download_storage', '1') + xbmc.sleep(3000) + xbmc.executebuiltin("PlayMedia(" + torrent_options[selection][1] % mediaurl + ")") # import xbmcaddon # xbmcaddon.Addon(id='plugin.video.elementum').setSetting('download_storage', '1') - if (item.fromLibrary and item.play_from == 'window') or item.window: - xlistitem.setPath(torrent_options[selection][1] % mediaurl) - playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO) - playlist.clear() - playlist.add(torrent_options[selection][1] % mediaurl, xlistitem) - xbmc_player.play(playlist, xlistitem) - else: - if not item.autoplay and item.channel != 'videolibrary': fakeVideo() - if xbmc.getCondVisibility("system.platform.android"): xbmc.sleep(3000) - xbmc.executebuiltin("PlayMedia(" + torrent_options[selection][1] % mediaurl + ")") + # if (item.fromLibrary and item.play_from == 'window') or item.window: + # xlistitem.setPath(torrent_options[selection][1] % mediaurl) + # playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO) + # playlist.clear() + # playlist.add(torrent_options[selection][1] % mediaurl, xlistitem) + # xbmc_player.play(playlist, xlistitem) + # else: + # if not item.autoplay and item.channel != 'videolibrary': fakeVideo() + # if xbmc.getCondVisibility("system.platform.android"): xbmc.sleep(3000) + # xbmc.executebuiltin("PlayMedia(" + torrent_options[selection][1] % mediaurl + ")") # torrent.mark_auto_as_watched(item) diff --git a/servers/torrent.py b/servers/torrent.py index d18d80bb..672b03e5 100755 --- a/servers/torrent.py +++ b/servers/torrent.py @@ -4,9 +4,9 @@ import re, os, sys, time, requests, xbmc, xbmcaddon from core import filetools, httptools, jsontools from core.support import info, match -from platformcode import config, platformtools +from platformcode import config, platformtools, logger from lib.guessit import guessit -from torrentool.api import Torrent +from lib.torrentool.api import Torrent if sys.version_info[0] >= 3: import urllib.parse as urllib @@ -92,13 +92,15 @@ def elementum_download(item): while not filetools.isfile(filetools.join(elementum_setting.getSetting('torrents_path'), TorrentName + '.torrent')): time.sleep(1) - monitor_update(TorrentPath, TorrentName) + monitor_update(TorrentPath, TorrentName) def elementum_monitor(): + # from core.support import dbg;dbg() path = xbmc.translatePath(config.get_setting('downloadlistpath')) elementum_setting, elementum_host, TorrentPath = setting() # active_torrent = filetools.listdir(TorrentPath) + # logger.debug('ELEMENTUM:', elementum_setting, elementum_host, TorrentPath) if elementum_setting: # check if command file exist @@ -117,6 +119,7 @@ def elementum_monitor(): except: data = '' if data: + # from core.support import dbg;dbg() for it in data: progress = round(it['progress'], 2) status = it['status'] @@ -143,6 +146,7 @@ def monitor_update(TorrentPath, value, remove=False): json = jsontools.load(open(monitor, "r").read()) Monitor = json['monitor'] info = Torrent.from_file(filetools.join(TorrentPath, value + '.torrent')) + logger.debug('ELEMENTUM MONITOR', Monitor) path = xbmc.translatePath(config.get_setting('downloadlistpath')) if not value in Monitor: @@ -174,7 +178,7 @@ def set_elementum(SET=False): backup_setting = json['settings'] write = False if SET: - elementum_setting.setSetting('download_storage', '1') + elementum_setting.setSetting('download_storage', '0') if elementum_setting.getSetting('logger_silent') == False or not 'logger_silent' in backup_setting: elementum_setting.setSetting('logger_silent', 'true') backup_setting['logger_silent'] = 'false' @@ -190,7 +194,8 @@ def set_elementum(SET=False): elif backup_setting: elementum_setting.setSetting('logger_silent', backup_setting['logger_silent']) - elementum_setting.setSetting('download_storage', backup_setting['download_storage']) + elementum_setting.setSetting('download_storage', '1') + # elementum_setting.setSetting('download_storage', backup_setting['download_storage']) elementum_setting.setSetting('download_path', backup_setting['download_path']) json['settings'] = {} write = True