Prima implementazione del Download Torrent:

- Solo Film
 - Non Supporta Resume automatico
 - Solo con Elementum
This commit is contained in:
Alhaziel01
2020-05-01 22:19:26 +02:00
parent e8486ba140
commit 5d24f6ca19
4 changed files with 104 additions and 15 deletions

View File

@@ -1505,18 +1505,8 @@ def play_torrent(item, xlistitem, mediaurl):
mediaurl += "&library=&tmdb=%s&type=movie" % (item.infoLabels['tmdb_id'])
if torr_client in ['quasar', 'elementum'] and item.downloadFilename:
# if torr_client == 'elementum':
# config.set_setting('elementumtype', torr_setting.getSetting('download_storage'))
# config.set_setting('elementumdl', torr_setting.getSetting('download_path'))
# torr_setting.setSetting('download_storage', '0')
# torr_setting.setSetting('download_path', config.get_setting('downloadpath'))
# xbmc.sleep(1000)
torrent.call_torrent_via_web(urllib.quote_plus(item.url), torr_client)
torrent.elementum_monitor(item, torr_client)
else:
# if torr_client == 'elementum':
# if config.get_setting('elementumtype'): torr_setting.setSetting('download_storage', config.get_setting('elementumtype'))
# if config.get_setting('elementumdl'): torr_setting.setSetting('download_path', config.get_setting('elementumdl'))
# xbmc.sleep(1000)
xbmc.executebuiltin("PlayMedia(" + torrent_options[selection][1] % mediaurl + ")")
# Si es un archivo RAR, monitorizamos el cliente Torrent hasta que haya descargado el archivo,
@@ -1568,5 +1558,4 @@ def play_torrent(item, xlistitem, mediaurl):
def log(texto):
xbmc.log(texto, xbmc.LOGNOTICE)
xbmc.log(texto, xbmc.LOGNOTICE)

View File

@@ -96,14 +96,19 @@
<setting id="downloadenabled" type="bool" label="70689" default="false"/>
<setting id="downloadpath" type="folder" label="30017" visible="eq(-1,true)" default="special://profile/addon_data/plugin.video.kod/downloads/" option="writeable"/>
<setting id="settings_kod1" type="action" label="70789" action="" visible="eq(-2,true)"/>
<setting id="downloadlistpath" type="folder" label="30018" visible="eq(-3,true)" default="special://profile/addon_data/plugin.video.kod/downloads/list/" option="writeable"/>
<!-- <setting id="library_add" type="bool" label="70230" default="false"/>
<setting id="library_move" type="bool" label="70231" default="false" visible="eq(-1,true)" subsetting="true"/> -->
<setting id="downloadlistpath" type="folder" label="30018" visible="eq(-3,true)" default="special://profile/addon_data/plugin.video.kod/downloads/list/" option="writeable"/>
<setting id="library_move" type="bool" label="70231" visible="eq(-4,true)" default="true"/>
<setting id="browser" type="bool" label="70232" visible="eq(-5,true)" default="true"/>
<setting id="server_speed" type="bool" label="70242" visible="eq(-6,true)" default="true"/>
<setting id="quality" type="select" label="70240" lvalues="70241|70763|70764|70765" visible="eq(-7,true)" default="0"/>
<setting id="download_adv" type="action" label="30030" visible="eq(-8,true)" action="RunPlugin(plugin://plugin.video.kod/?ew0KCSJhY3Rpb24iOiJjaGFubmVsX2NvbmZpZyIsDQoJImNvbmZpZyI6ImRvd25sb2FkcyIsDQogICAgImNoYW5uZWwiOiJzZXR0aW5nIg0KfQ==)"/>
<setting id="elementumtype" type="text" label="Elementum Download Type" visible="false"/>
<setting id="quasartype" type="text" label="Quasar Download Type" visible="false"/>
<setting id="elementumdl" type="folder" label="Elementum Download Backup" visible="false"/>
<setting id="quasardl" type="folder" label="Quasar Download Backup" visible="false"/>
</category>
<!-- News -->

View File

@@ -1349,6 +1349,97 @@ def import_libtorrent(LIBTORRENT_PATH):
return lt, e, e1, e2
########################## ELEMENTUM MONITOR TEST ##########################
def elementum_monitor(item, torr_client):
host = 'http://127.0.0.1:65220/torrents/'
torr_setting = xbmcaddon.Addon(id="plugin.video.elementum")
# from core.support import dbg;dbg()
data = httptools.downloadpage(host, alfa_s=True).data
items = jsontools.load(data)['items']
if not items:
set_elementum()
call_torrent_via_web(urllib.quote_plus(item.url), torr_client)
result = 0
while result < 100:
data = httptools.downloadpage(host, alfa_s=True).data
items = jsontools.load(data)['items']
partials = []
files = []
titles = []
for it in items:
p = scrapertools.find_single_match(it['label'], r'(\d+\.\d+)%')
f = scrapertools.find_single_match(it['path'], r'resume=([^&]+)')
t = it['info']['title']
partials.append(p)
files.append(f)
titles.append(t)
partial = 0
for i, p in enumerate(partials):
partial += float(p)
update_download_info(files[i], p, titles[i])
result = partial / len(items)
xbmc.sleep(5000)
log('All Torrent downloaded.')
xbmc.sleep(1000)
unset_elementum()
def update_download_info(file, partial, title):
extensions_list = ['aaf', '3gp', 'asf', 'avi', 'flv', 'mpeg', 'm1v', 'm2v', 'm4v', 'mkv', 'mov', 'mpg', 'mpe', 'mp4', 'ogg', 'wmv']
path = xbmc.translatePath(config.get_setting('downloadlistpath'))
dlpath = filetools.join(config.get_setting('downloadpath'), title)
log('DL PATH: ' + dlpath)
sep = '/' if dlpath.startswith('smb') else os.sep
if filetools.isdir(dlpath) and partial > 0:
dlfiles = filetools.listdir(dlpath)
for f in dlfiles:
log('FILE TYPE: ' + f.split('.')[-1])
if f.split('.')[-1] in extensions_list:
dlpath = filetools.join(dlpath.split(sep)[-1], f)
else:
dlpath = dlpath.split(sep)[-1]
files = filetools.listdir(path)
for f in files:
json = jsontools.load(filetools.read(filetools.join(path, f)))
if 'downloadServer' in json and file in json['downloadServer']['url'] or \
'url' in json and file in json['url']:
jsontools.update_node(dlpath, f, "downloadFilename", path)
jsontools.update_node(float(partial), f, "downloadProgress", path)
if float(partial) == 100:
jsontools.update_node(2, f, "downloadStatus", path)
def set_elementum():
log('SET Elementum')
torr_setting = xbmcaddon.Addon(id="plugin.video.elementum")
config.set_setting('elementumtype', torr_setting.getSetting('download_storage'))
config.set_setting('elementumdl', torr_setting.getSetting('download_path'))
torr_setting.setSetting('download_storage', '0')
torr_setting.setSetting('download_path', config.get_setting('downloadpath'))
xbmc.sleep(3000)
def unset_elementum():
log('UNSET Elementum')
torr_setting = xbmcaddon.Addon(id="plugin.video.elementum")
Sleep = False
if config.get_setting('elementumtype'):
torr_setting.setSetting('download_storage', str(config.get_setting('elementumtype')))
Sleep = True
if config.get_setting('elementumdl'):
torr_setting.setSetting('download_path', config.get_setting('elementumdl'))
Sleep = True
if Sleep:
xbmc.sleep(3000)
########################## ELEMENTUM MONITOR TEST ##########################
def log(texto):
try:
xbmc.log(texto, xbmc.LOGNOTICE)

View File

@@ -152,7 +152,11 @@ def browser(item):
if filetools.isdir(filetools.join(item.url, file)):
itemlist.append(Item(channel=item.channel, title=file, action=item.action, url=filetools.join(item.url, file), context=[{ 'title': config.get_localized_string(30037), 'channel': 'downloads', 'action': "del_dir"}]))
else:
itemlist.append(Item(channel=item.channel, title=file, action="play", url=filetools.join(item.url, file), context=[{ 'title': config.get_localized_string(30039), 'channel': 'downloads', 'action': "del_file"}]))
if not item.infoLabels:
infoLabels = {"mediatype":"video"}
else:
infoLabels = item.infoLabels
itemlist.append(Item(channel=item.channel, title=file, action="play", infoLabels=infoLabels, url=filetools.join(item.url, file), context=[{ 'title': config.get_localized_string(30039), 'channel': 'downloads', 'action': "del_file"}]))
return itemlist