Supporto Torrent
This commit is contained in:
@@ -329,6 +329,7 @@ def update_libtorrent():
|
||||
config.get_setting("libtorrent_path", server="torrent", default="") :
|
||||
return
|
||||
|
||||
|
||||
try:
|
||||
from lib.python_libtorrent.python_libtorrent import get_libtorrent
|
||||
except Exception as e:
|
||||
|
||||
@@ -93,7 +93,7 @@ def play(url, xlistitem={}, is_view=None, subtitle="", password="", item=None):
|
||||
url = decode_adfly(data)
|
||||
except:
|
||||
ddd = xbmcgui.Dialog()
|
||||
ddd.ok( msg_header + ": Sin soporte adf.ly", "El script no tiene soporte para el acortador de urls adf.ly.", "", "url: " + url )
|
||||
ddd.ok( msg_header + ": No adf.ly support "," The script has no support for the adf.ly url shortener.", "", "url: " + url )
|
||||
return
|
||||
|
||||
"""
|
||||
@@ -153,8 +153,7 @@ def play(url, xlistitem={}, is_view=None, subtitle="", password="", item=None):
|
||||
except Exception as e:
|
||||
do = xbmcgui.Dialog()
|
||||
e = e1 or e2
|
||||
do.ok('ERROR en el cliente MCT Libtorrent', 'Módulo no encontrado o imcompatible con el dispositivo.',
|
||||
'Reporte el fallo adjuntando un "log".', str(e))
|
||||
do.ok(config.get_localized_string(30035) + 'MCT Libtorrent', config.get_localized_string(30036), config.get_localized_string(60015), str(e))
|
||||
return
|
||||
|
||||
log("XXX libtorrent version: %s" % lt.version)
|
||||
@@ -257,7 +256,7 @@ def play(url, xlistitem={}, is_view=None, subtitle="", password="", item=None):
|
||||
# -- Prioritarizar/Seleccionar archivo-----------------------
|
||||
_index, video_file, video_size, len_files = get_video_files_sizes( info )
|
||||
if len_files == 0:
|
||||
dp = xbmcgui.Dialog().ok("No se puede reproducir", "El torrent no contiene ningún archivo de vídeo")
|
||||
dp = xbmcgui.Dialog().ok(config.get_localized_string(20000), config.get_localized_string(60339))
|
||||
|
||||
if _index < 0:
|
||||
log("##### parts = %s #########" % str(video_file))
|
||||
@@ -574,8 +573,7 @@ def play(url, xlistitem={}, is_view=None, subtitle="", password="", item=None):
|
||||
if h.status().num_pieces < tot_piece_set:
|
||||
# -- Diálogo continuar o terminar ---------------
|
||||
# Preguntamos si el usuario quiere pasar a backgroung
|
||||
ok = xbmcgui.Dialog().yesno(msg_header, "¿Borramos los archivo descargados? (incompletos)",
|
||||
"Selecciona NO para seguir descargando en segundo plano")
|
||||
ok = xbmcgui.Dialog().yesno(msg_header, config.get_localized_string(30031), config.get_localized_string(30032))
|
||||
else: ok = True
|
||||
# -- NO ---------------------------------------------
|
||||
if not ok:
|
||||
@@ -618,8 +616,7 @@ def play(url, xlistitem={}, is_view=None, subtitle="", password="", item=None):
|
||||
if not bkg_user and dp_cerrado and dp.iscanceled():
|
||||
dp.close()
|
||||
# Preguntamos si el usuario quiere pasar a backgroung
|
||||
dialog = xbmcgui.Dialog().yesno(msg_header, "¿Borramos los archivo descargados? (incompletos)",
|
||||
"Seleccione NO para seguir descargando en segundo plano")
|
||||
dialog = xbmcgui.Dialog().yesno(msg_header, config.get_localized_string(30031), config.get_localized_string(30032))
|
||||
if not dialog:
|
||||
bkg_user = True
|
||||
dp_cerrado = False
|
||||
@@ -791,7 +788,7 @@ def get_video_files_sizes( info ):
|
||||
return index, rar_parts, rar_size, len(opciones)
|
||||
else:
|
||||
d = xbmcgui.Dialog()
|
||||
seleccion = d.select(msg_header + ": Selecciona el vídeo, o 'Cancelar' para todos", list(opciones.values()))
|
||||
seleccion = d.select(msg_header + config.get_localized_string(30034), list(opciones.values()))
|
||||
else: seleccion = 0
|
||||
|
||||
index = list(opciones.keys())[seleccion]
|
||||
@@ -829,7 +826,7 @@ def remove_files( download, torrent_file, video_file, ses, h, ren_video_file=""
|
||||
if dialog_view and ren_video_file:
|
||||
if h.status().num_pieces >= tot_piece_set:
|
||||
d = xbmcgui.Dialog()
|
||||
ok = d.yesno(msg_header, '¿Borrarmos los archivos descargados? (completos)', video_file)
|
||||
ok = d.yesno(msg_header, config.get_localized_string(30031), video_file)
|
||||
else:
|
||||
ok = True
|
||||
|
||||
|
||||
@@ -1235,8 +1235,8 @@ def play_torrent(item, xlistitem, mediaurl):
|
||||
|
||||
# Opciones disponibles para Reproducir torrents
|
||||
torrent_options = list()
|
||||
torrent_options.append(["Cliente interno (necesario libtorrent)"])
|
||||
torrent_options.append(["Cliente interno MCT (necesario libtorrent)"])
|
||||
torrent_options.append([config.get_localized_string(30033)])
|
||||
torrent_options.append([config.get_localized_string(30033) + ' MCT'])
|
||||
|
||||
torrent_options.extend(torrent_client_installed(show_tuple=True))
|
||||
|
||||
@@ -1329,17 +1329,14 @@ def play_torrent(item, xlistitem, mediaurl):
|
||||
password = item.password
|
||||
|
||||
videolibrary_path = config.get_videolibrary_path() # Calculamos el path absoluto a partir de la Videoteca
|
||||
if scrapertools.find_single_match(videolibrary_path,
|
||||
'(^\w+:\/\/)'): # Si es una conexión REMOTA, usamos userdata local
|
||||
if scrapertools.find_single_match(videolibrary_path, '(^\w+:\/\/)'): # Si es una conexión REMOTA, usamos userdata local
|
||||
videolibrary_path = config.get_data_path() # Calculamos el path absoluto a partir de Userdata
|
||||
if not filetools.exists(videolibrary_path): # Si no existe el path, pasamos al modo clásico
|
||||
videolibrary_path = False
|
||||
else:
|
||||
torrents_path = filetools.join(videolibrary_path, 'temp_torrents_Alfa', \
|
||||
'cliente_torrent_Alfa.torrent') # path descarga temporal
|
||||
if not videolibrary_path or not filetools.exists(filetools.join(videolibrary_path, \
|
||||
'temp_torrents_Alfa')): # Si no existe la carpeta temporal, la creamos
|
||||
filetools.mkdir(filetools.join(videolibrary_path, 'temp_torrents_Alfa'))
|
||||
torrents_path = filetools.join(videolibrary_path, 'temp_torrents', 'client_torrent.torrent') # path descarga temporal
|
||||
if not videolibrary_path or not filetools.exists(filetools.join(videolibrary_path, 'temp_torrents')): # Si no existe la carpeta temporal, la creamos
|
||||
filetools.mkdir(filetools.join(videolibrary_path, 'temp_torrents'))
|
||||
|
||||
# Si hay headers, se pasar a la petición de descarga del .torrent
|
||||
headers = {}
|
||||
@@ -1355,10 +1352,7 @@ def play_torrent(item, xlistitem, mediaurl):
|
||||
if item.referer: referer = item.referer
|
||||
if item.post: post = item.post
|
||||
# Descargamos el .torrent
|
||||
size, url, torrent_f, rar_files = generictools.get_torrent_size(item.url, referer, post, \
|
||||
torrents_path=torrents_path,
|
||||
timeout=timeout, lookup=False,
|
||||
headers=headers, short_pad=True)
|
||||
size, url, torrent_f, rar_files = generictools.get_torrent_size(item.url, referer, post, torrents_path=torrents_path, timeout=timeout, lookup=False, headers=headers, short_pad=True)
|
||||
if url:
|
||||
url_stat = True
|
||||
item.url = url
|
||||
@@ -1393,7 +1387,17 @@ def play_torrent(item, xlistitem, mediaurl):
|
||||
mediaurl = item.url
|
||||
|
||||
if seleccion >= 0:
|
||||
|
||||
|
||||
# Si tiene .torrent válido o magnet, lo registramos
|
||||
if size or item.url.startswith('magnet'):
|
||||
try:
|
||||
import threading
|
||||
if not PY3: from lib import alfaresolver
|
||||
else: from lib import alfaresolver_py3 as alfaresolver
|
||||
threading.Thread(target=alfaresolver.frequency_count, args=(item, )).start()
|
||||
except:
|
||||
logger.error(traceback.format_exc(1))
|
||||
|
||||
# Reproductor propio BT (libtorrent)
|
||||
if seleccion == 0:
|
||||
torrent.bt_client(mediaurl, xlistitem, rar_files, subtitle=item.subtitle, password=password, item=item)
|
||||
@@ -1425,7 +1429,7 @@ def play_torrent(item, xlistitem, mediaurl):
|
||||
rar_file, save_path_videos, folder_torr = torrent.wait_for_download(rar_files,
|
||||
torr_client) # Esperamos mientras se descarga el RAR
|
||||
if rar_file and save_path_videos: # Si se ha descargado el RAR...
|
||||
dp = dialog_progress_bg('Alfa %s' % torr_client)
|
||||
dp = dialog_progress_bg('KoD %s' % torr_client)
|
||||
video_file, rar, video_path, erase_file_path = torrent.extract_files(rar_file, \
|
||||
save_path_videos, password, dp,
|
||||
item,
|
||||
@@ -1452,7 +1456,7 @@ def play_torrent(item, xlistitem, mediaurl):
|
||||
while is_playing() and rar and not xbmc.abortRequested:
|
||||
time.sleep(3) # Repetimos cada intervalo
|
||||
if rar and not xbmc.abortRequested:
|
||||
if dialog_yesno('Alfa %s' % torr_client, '¿Borrar las descargas del RAR y Vídeo?'):
|
||||
if dialog_yesno('KoD %s' % torr_client, config.get_localized_string(30031)):
|
||||
log("##### erase_file_path: %s" % erase_file_path)
|
||||
try:
|
||||
torr_data, deamon_url, index = torrent.get_tclient_data(folder_torr, torr_client)
|
||||
|
||||
Reference in New Issue
Block a user