riscritto logger
This commit is contained in:
@@ -15,7 +15,7 @@ default_file = dict()
|
||||
remote_path = 'https://raw.githubusercontent.com/kodiondemand/media/master/'
|
||||
|
||||
def is_enabled(channel_name):
|
||||
logger.log("channel_name=" + channel_name)
|
||||
logger.info("channel_name=" + channel_name)
|
||||
return get_channel_parameters(channel_name)["active"] and get_channel_setting("enabled", channel=channel_name,
|
||||
default=True)
|
||||
|
||||
@@ -87,7 +87,7 @@ def get_channel_parameters(channel_name):
|
||||
|
||||
|
||||
def get_channel_json(channel_name):
|
||||
# logger.log("channel_name=" + channel_name)
|
||||
# logger.info("channel_name=" + channel_name)
|
||||
from core import filetools
|
||||
channel_json = None
|
||||
try:
|
||||
@@ -101,9 +101,9 @@ def get_channel_json(channel_name):
|
||||
channel_name + ".json")
|
||||
|
||||
if filetools.isfile(channel_path):
|
||||
# logger.log("channel_data=" + channel_path)
|
||||
# logger.info("channel_data=" + channel_path)
|
||||
channel_json = jsontools.load(filetools.read(channel_path))
|
||||
# logger.log("channel_json= %s" % channel_json)
|
||||
# logger.info("channel_json= %s" % channel_json)
|
||||
|
||||
except Exception as ex:
|
||||
template = "An exception of type %s occured. Arguments:\n%r"
|
||||
@@ -114,7 +114,7 @@ def get_channel_json(channel_name):
|
||||
|
||||
|
||||
def get_channel_controls_settings(channel_name):
|
||||
# logger.log("channel_name=" + channel_name)
|
||||
# logger.info("channel_name=" + channel_name)
|
||||
dict_settings = {}
|
||||
# import web_pdb; web_pdb.set_trace()
|
||||
# list_controls = get_channel_json(channel_name).get('settings', list())
|
||||
@@ -137,7 +137,7 @@ def get_lang(channel_name):
|
||||
if hasattr(channel, 'list_language'):
|
||||
for language in channel.list_language:
|
||||
list_language.append(language)
|
||||
logger.log(list_language)
|
||||
logger.info(list_language)
|
||||
else:
|
||||
sub = False
|
||||
langs = []
|
||||
|
||||
+14
-14
@@ -253,12 +253,12 @@ class Downloader(object):
|
||||
self.file.seek(2 ** 31, 0)
|
||||
except OverflowError:
|
||||
self._seekable = False
|
||||
logger.log("Cannot do seek() or tell() in files larger than 2GB")
|
||||
logger.info("Cannot do seek() or tell() in files larger than 2GB")
|
||||
|
||||
self.__get_download_info__()
|
||||
|
||||
try:
|
||||
logger.log("Download started: Parts: %s | Path: %s | File: %s | Size: %s" % (str(len(self._download_info["parts"])), self._pathencode('utf-8'), self._filenameencode('utf-8'), str(self._download_info["size"])))
|
||||
logger.info("Download started: Parts: %s | Path: %s | File: %s | Size: %s" % (str(len(self._download_info["parts"])), self._pathencode('utf-8'), self._filenameencode('utf-8'), str(self._download_info["size"])))
|
||||
except:
|
||||
pass
|
||||
|
||||
@@ -410,7 +410,7 @@ class Downloader(object):
|
||||
return id == 0 or (len(self.completed_parts) >= id and sorted(self.completed_parts)[id - 1] == id - 1)
|
||||
|
||||
def __save_file__(self):
|
||||
logger.log("Thread started: %s" % threading.current_thread().name)
|
||||
logger.info("Thread started: %s" % threading.current_thread().name)
|
||||
|
||||
while self._state == self.states.downloading:
|
||||
if not self.pending_parts and not self.download_parts and not self.save_parts: # Download finished
|
||||
@@ -449,7 +449,7 @@ class Downloader(object):
|
||||
self._download_info["parts"][s]["status"] = self.states.stopped
|
||||
self._download_info["parts"][s]["current"] = self._download_info["parts"][s]["start"]
|
||||
|
||||
logger.log("Thread stopped: %s" % threading.current_thread().name)
|
||||
logger.info("Thread stopped: %s" % threading.current_thread().name)
|
||||
|
||||
def __get_part_id__(self):
|
||||
self._download_lock.acquire()
|
||||
@@ -464,21 +464,21 @@ class Downloader(object):
|
||||
return None
|
||||
|
||||
def __set_part_connecting__(self, id):
|
||||
logger.log("ID: %s Establishing connection" % id)
|
||||
logger.info("ID: %s Establishing connection" % id)
|
||||
self._download_info["parts"][id]["status"] = self.states.connecting
|
||||
|
||||
def __set_part__error__(self, id):
|
||||
logger.log("ID: %s Download failed" % id)
|
||||
logger.info("ID: %s Download failed" % id)
|
||||
self._download_info["parts"][id]["status"] = self.states.error
|
||||
self.pending_parts.add(id)
|
||||
self.download_parts.remove(id)
|
||||
|
||||
def __set_part__downloading__(self, id):
|
||||
logger.log("ID: %s Downloading data ..." % id)
|
||||
logger.info("ID: %s Downloading data ..." % id)
|
||||
self._download_info["parts"][id]["status"] = self.states.downloading
|
||||
|
||||
def __set_part_completed__(self, id):
|
||||
logger.log("ID: %s Download finished!" % id)
|
||||
logger.info("ID: %s Download finished!" % id)
|
||||
self._download_info["parts"][id]["status"] = self.states.saving
|
||||
self.download_parts.remove(id)
|
||||
self.save_parts.add(id)
|
||||
@@ -501,7 +501,7 @@ class Downloader(object):
|
||||
return file
|
||||
|
||||
def __start_part__(self):
|
||||
logger.log("Thread Started: %s" % threading.current_thread().name)
|
||||
logger.info("Thread Started: %s" % threading.current_thread().name)
|
||||
while self._state == self.states.downloading:
|
||||
id = self.__get_part_id__()
|
||||
if id is None: break
|
||||
@@ -528,7 +528,7 @@ class Downloader(object):
|
||||
buffer = connection.read(self._block_size)
|
||||
speed.append(old_div(len(buffer), ((time.time() - start) or 0.001)))
|
||||
except:
|
||||
logger.log("ID: %s Error downloading data" % id)
|
||||
logger.info("ID: %s Error downloading data" % id)
|
||||
self._download_info["parts"][id]["status"] = self.states.error
|
||||
self.pending_parts.add(id)
|
||||
self.download_parts.remove(id)
|
||||
@@ -546,7 +546,7 @@ class Downloader(object):
|
||||
|
||||
if velocidad_minima > speed[-1] and velocidad_minima > speed[-2] and self._download_info["parts"][id]["current"] < self._download_info["parts"][id]["end"]:
|
||||
if connection.fp: connection.fp._sock.close()
|
||||
logger.log("ID: %s Restarting connection! | Minimum Speed: %.2f %s/s | Speed: %.2f %s/s" % (id, vm[1], vm[2], v[1], v[2]))
|
||||
logger.info("ID: %s Restarting connection! | Minimum Speed: %.2f %s/s | Speed: %.2f %s/s" % (id, vm[1], vm[2], v[1], v[2]))
|
||||
# file.close()
|
||||
break
|
||||
else:
|
||||
@@ -556,7 +556,7 @@ class Downloader(object):
|
||||
break
|
||||
|
||||
self.__set_part_stopped__(id)
|
||||
logger.log("Thread stopped: %s" % threading.current_thread().name)
|
||||
logger.info("Thread stopped: %s" % threading.current_thread().name)
|
||||
|
||||
def __update_json(self, started=True):
|
||||
text = filetools.read(self._json_path)
|
||||
@@ -564,10 +564,10 @@ class Downloader(object):
|
||||
if self._json_text != text:
|
||||
self._json_text = text
|
||||
self._json_item = Item().fromjson(text)
|
||||
logger.log('item loaded')
|
||||
logger.info('item loaded')
|
||||
progress = int(self.progress)
|
||||
if started and self._json_item.downloadStatus == 0: # stopped
|
||||
logger.log('Download paused')
|
||||
logger.info('Download paused')
|
||||
self.stop()
|
||||
elif self._json_item.downloadProgress != progress or not started:
|
||||
params = {"downloadStatus": 4, "downloadComplete": 0, "downloadProgress": progress}
|
||||
|
||||
+69
-69
@@ -97,11 +97,11 @@ def limpia_nombre_excepto_1(s):
|
||||
try:
|
||||
s = unicode(s, "utf-8")
|
||||
except UnicodeError:
|
||||
# logger.log("no es utf-8")
|
||||
# logger.info("no es utf-8")
|
||||
try:
|
||||
s = unicode(s, "iso-8859-1")
|
||||
except UnicodeError:
|
||||
# logger.log("no es iso-8859-1")
|
||||
# logger.info("no es iso-8859-1")
|
||||
pass
|
||||
# Remove accents
|
||||
s = limpia_nombre_sin_acentos(s)
|
||||
@@ -125,29 +125,29 @@ def limpia_nombre_excepto_2(s):
|
||||
|
||||
def getfilefromtitle(url, title):
|
||||
# Print in the log what you will discard
|
||||
logger.log("title=" + title)
|
||||
logger.log("url=" + url)
|
||||
logger.info("title=" + title)
|
||||
logger.info("url=" + url)
|
||||
plataforma = config.get_system_platform()
|
||||
logger.log("platform=" + plataforma)
|
||||
logger.info("platform=" + plataforma)
|
||||
|
||||
# filename = xbmc.makeLegalFilename(title + url[-4:])
|
||||
from core import scrapertools
|
||||
|
||||
nombrefichero = title + scrapertools.get_filename_from_url(url)[-4:]
|
||||
logger.log("filename= %s" % nombrefichero)
|
||||
logger.info("filename= %s" % nombrefichero)
|
||||
if "videobb" in url or "videozer" in url or "putlocker" in url:
|
||||
nombrefichero = title + ".flv"
|
||||
if "videobam" in url:
|
||||
nombrefichero = title + "." + url.rsplit(".", 1)[1][0:3]
|
||||
|
||||
logger.log("filename= %s" % nombrefichero)
|
||||
logger.info("filename= %s" % nombrefichero)
|
||||
|
||||
nombrefichero = limpia_nombre_caracteres_especiales(nombrefichero)
|
||||
|
||||
logger.log("filename= %s" % nombrefichero)
|
||||
logger.info("filename= %s" % nombrefichero)
|
||||
|
||||
fullpath = filetools.join(config.get_setting("downloadpath"), nombrefichero)
|
||||
logger.log("fullpath= %s" % fullpath)
|
||||
logger.info("fullpath= %s" % fullpath)
|
||||
|
||||
if config.is_xbmc() and fullpath.startswith("special://"):
|
||||
import xbmc
|
||||
@@ -162,7 +162,7 @@ def downloadtitle(url, title):
|
||||
|
||||
|
||||
def downloadbest(video_urls, title, continuar=False):
|
||||
logger.log()
|
||||
logger.info()
|
||||
|
||||
# Flip it over, to put the highest quality one first (list () is for you to make a copy of)
|
||||
invertida = list(video_urls)
|
||||
@@ -172,9 +172,9 @@ def downloadbest(video_urls, title, continuar=False):
|
||||
# videotitle = elemento[0]
|
||||
url = elemento[1]
|
||||
if not PY3:
|
||||
logger.log("Downloading option " + title + " " + url.encode('ascii', 'ignore'))
|
||||
logger.info("Downloading option " + title + " " + url.encode('ascii', 'ignore'))
|
||||
else:
|
||||
logger.log("Downloading option " + title + " " + url.encode('ascii', 'ignore').decode('utf-8'))
|
||||
logger.info("Downloading option " + title + " " + url.encode('ascii', 'ignore').decode('utf-8'))
|
||||
|
||||
# Calculate the file where you should record
|
||||
try:
|
||||
@@ -200,25 +200,25 @@ def downloadbest(video_urls, title, continuar=False):
|
||||
else:
|
||||
# EThe file doesn't even exist
|
||||
if not filetools.exists(fullpath):
|
||||
logger.log("-> You have not downloaded anything, testing with the following option if there is")
|
||||
logger.info("-> You have not downloaded anything, testing with the following option if there is")
|
||||
# The file exists
|
||||
else:
|
||||
tamanyo = filetools.getsize(fullpath)
|
||||
|
||||
# It has size 0
|
||||
if tamanyo == 0:
|
||||
logger.log("-> Download a file with size 0, testing with the following option if it exists")
|
||||
logger.info("-> Download a file with size 0, testing with the following option if it exists")
|
||||
os.remove(fullpath)
|
||||
else:
|
||||
logger.log("-> Download a file with size %d, he takes it for good" % tamanyo)
|
||||
logger.info("-> Download a file with size %d, he takes it for good" % tamanyo)
|
||||
return 0
|
||||
|
||||
return -2
|
||||
|
||||
|
||||
def downloadfile(url, nombrefichero, headers=None, silent=False, continuar=False, resumir=True, header=''):
|
||||
logger.log("url= " + url)
|
||||
logger.log("filename= " + nombrefichero)
|
||||
logger.info("url= " + url)
|
||||
logger.info("filename= " + nombrefichero)
|
||||
|
||||
if headers is None:
|
||||
headers = []
|
||||
@@ -242,14 +242,14 @@ def downloadfile(url, nombrefichero, headers=None, silent=False, continuar=False
|
||||
nombrefichero = xbmc.makeLegalFilename(nombrefichero)
|
||||
except:
|
||||
pass
|
||||
logger.log("filename= " + nombrefichero)
|
||||
logger.info("filename= " + nombrefichero)
|
||||
|
||||
# The file exists and you want to continue
|
||||
if filetools.exists(nombrefichero) and continuar:
|
||||
f = filetools.file_open(nombrefichero, 'r+b', vfs=VFS)
|
||||
if resumir:
|
||||
exist_size = filetools.getsize(nombrefichero)
|
||||
logger.log("the file exists, size= %d" % exist_size)
|
||||
logger.info("the file exists, size= %d" % exist_size)
|
||||
grabado = exist_size
|
||||
f.seek(exist_size)
|
||||
else:
|
||||
@@ -258,13 +258,13 @@ def downloadfile(url, nombrefichero, headers=None, silent=False, continuar=False
|
||||
|
||||
# the file already exists and you don't want to continue, it aborts
|
||||
elif filetools.exists(nombrefichero) and not continuar:
|
||||
logger.log("the file exists, it does not download again")
|
||||
logger.info("the file exists, it does not download again")
|
||||
return -3
|
||||
|
||||
# the file does not exist
|
||||
else:
|
||||
exist_size = 0
|
||||
logger.log("the file does not exist")
|
||||
logger.info("the file does not exist")
|
||||
|
||||
f = filetools.file_open(nombrefichero, 'wb', vfs=VFS)
|
||||
grabado = 0
|
||||
@@ -285,13 +285,13 @@ def downloadfile(url, nombrefichero, headers=None, silent=False, continuar=False
|
||||
additional_headers = [additional_headers]
|
||||
|
||||
for additional_header in additional_headers:
|
||||
logger.log("additional_header: " + additional_header)
|
||||
logger.info("additional_header: " + additional_header)
|
||||
name = re.findall("(.*?)=.*?", additional_header)[0]
|
||||
value = urllib.parse.unquote_plus(re.findall(".*?=(.*?)$", additional_header)[0])
|
||||
headers.append([name, value])
|
||||
|
||||
url = url.split("|")[0]
|
||||
logger.log("url=" + url)
|
||||
logger.info("url=" + url)
|
||||
|
||||
# Socket timeout at 60 seconds
|
||||
socket.setdefaulttimeout(60)
|
||||
@@ -299,7 +299,7 @@ def downloadfile(url, nombrefichero, headers=None, silent=False, continuar=False
|
||||
h = urllib.request.HTTPHandler(debuglevel=0)
|
||||
request = urllib.request.Request(url)
|
||||
for header in headers:
|
||||
logger.log("Header= " + header[0] + ": " + header[1])
|
||||
logger.info("Header= " + header[0] + ": " + header[1])
|
||||
request.add_header(header[0], header[1])
|
||||
|
||||
if exist_size > 0:
|
||||
@@ -328,12 +328,12 @@ def downloadfile(url, nombrefichero, headers=None, silent=False, continuar=False
|
||||
if exist_size > 0:
|
||||
totalfichero = totalfichero + exist_size
|
||||
|
||||
logger.log("Content-Length= %s" % totalfichero)
|
||||
logger.info("Content-Length= %s" % totalfichero)
|
||||
|
||||
blocksize = 100 * 1024
|
||||
|
||||
bloqueleido = connexion.read(blocksize)
|
||||
logger.log("Starting downloading the file, blocked= %s" % len(bloqueleido))
|
||||
logger.info("Starting downloading the file, blocked= %s" % len(bloqueleido))
|
||||
|
||||
maxreintentos = 10
|
||||
|
||||
@@ -360,7 +360,7 @@ def downloadfile(url, nombrefichero, headers=None, silent=False, continuar=False
|
||||
tiempofalta = old_div(falta, velocidad)
|
||||
else:
|
||||
tiempofalta = 0
|
||||
# logger.log(sec_to_hms(tiempofalta))
|
||||
# logger.info(sec_to_hms(tiempofalta))
|
||||
if not silent:
|
||||
progreso.update(percent, "%.2fMB/%.2fMB (%d%%) %.2f Kb/s %s" %
|
||||
(descargadosmb, totalmb, percent, old_div(velocidad, 1024),
|
||||
@@ -368,14 +368,14 @@ def downloadfile(url, nombrefichero, headers=None, silent=False, continuar=False
|
||||
break
|
||||
except:
|
||||
reintentos += 1
|
||||
logger.log("ERROR in block download, retry %d" % reintentos)
|
||||
logger.info("ERROR in block download, retry %d" % reintentos)
|
||||
import traceback
|
||||
logger.error(traceback.print_exc())
|
||||
|
||||
# The user cancels the download
|
||||
try:
|
||||
if progreso.iscanceled():
|
||||
logger.log("Download of file canceled")
|
||||
logger.info("Download of file canceled")
|
||||
f.close()
|
||||
progreso.close()
|
||||
return -1
|
||||
@@ -384,7 +384,7 @@ def downloadfile(url, nombrefichero, headers=None, silent=False, continuar=False
|
||||
|
||||
# There was an error in the download
|
||||
if reintentos > maxreintentos:
|
||||
logger.log("ERROR in the file download")
|
||||
logger.info("ERROR in the file download")
|
||||
f.close()
|
||||
if not silent:
|
||||
progreso.close()
|
||||
@@ -430,7 +430,7 @@ def downloadfile(url, nombrefichero, headers=None, silent=False, continuar=False
|
||||
except:
|
||||
pass
|
||||
|
||||
logger.log("End of file download")
|
||||
logger.info("End of file download")
|
||||
|
||||
|
||||
def downloadfileRTMP(url, nombrefichero, silent):
|
||||
@@ -476,7 +476,7 @@ def downloadfileRTMP(url, nombrefichero, silent):
|
||||
try:
|
||||
rtmpdump_args = [rtmpdump_cmd] + rtmpdump_args + ["-o", nombrefichero]
|
||||
from os import spawnv, P_NOWAIT
|
||||
logger.log("Initiating file download: %s" % " ".join(rtmpdump_args))
|
||||
logger.info("Initiating file download: %s" % " ".join(rtmpdump_args))
|
||||
rtmpdump_exit = spawnv(P_NOWAIT, rtmpdump_cmd, rtmpdump_args)
|
||||
if not silent:
|
||||
from platformcode import platformtools
|
||||
@@ -488,18 +488,18 @@ def downloadfileRTMP(url, nombrefichero, silent):
|
||||
|
||||
|
||||
def downloadfileGzipped(url, pathfichero):
|
||||
logger.log("url= " + url)
|
||||
logger.info("url= " + url)
|
||||
nombrefichero = pathfichero
|
||||
logger.log("filename= " + nombrefichero)
|
||||
logger.info("filename= " + nombrefichero)
|
||||
|
||||
import xbmc
|
||||
nombrefichero = xbmc.makeLegalFilename(nombrefichero)
|
||||
logger.log("filename= " + nombrefichero)
|
||||
logger.info("filename= " + nombrefichero)
|
||||
patron = "(http://[^/]+)/.+"
|
||||
matches = re.compile(patron, re.DOTALL).findall(url)
|
||||
|
||||
if len(matches):
|
||||
logger.log("Main URL: " + matches[0])
|
||||
logger.info("Main URL: " + matches[0])
|
||||
url1 = matches[0]
|
||||
else:
|
||||
url1 = url
|
||||
@@ -546,9 +546,9 @@ def downloadfileGzipped(url, pathfichero):
|
||||
|
||||
nombre_fichero_base = filetools.basename(nombrefichero)
|
||||
if len(nombre_fichero_base) == 0:
|
||||
logger.log("Searching for name in the answer Headers")
|
||||
logger.info("Searching for name in the answer Headers")
|
||||
nombre_base = connexion.headers["Content-Disposition"]
|
||||
logger.log(nombre_base)
|
||||
logger.info(nombre_base)
|
||||
patron = 'filename="([^"]+)"'
|
||||
matches = re.compile(patron, re.DOTALL).findall(nombre_base)
|
||||
if len(matches) > 0:
|
||||
@@ -556,7 +556,7 @@ def downloadfileGzipped(url, pathfichero):
|
||||
titulo = GetTitleFromFile(titulo)
|
||||
nombrefichero = filetools.join(pathfichero, titulo)
|
||||
else:
|
||||
logger.log("Name of the file not found, Placing temporary name: no_name.txt")
|
||||
logger.info("Name of the file not found, Placing temporary name: no_name.txt")
|
||||
titulo = "no_name.txt"
|
||||
nombrefichero = filetools.join(pathfichero, titulo)
|
||||
totalfichero = int(connexion.headers["Content-Length"])
|
||||
@@ -564,10 +564,10 @@ def downloadfileGzipped(url, pathfichero):
|
||||
# then
|
||||
f = filetools.file_open(nombrefichero, 'w', vfs=VFS)
|
||||
|
||||
logger.log("new file open")
|
||||
logger.info("new file open")
|
||||
|
||||
grabado = 0
|
||||
logger.log("Content-Length= %s" % totalfichero)
|
||||
logger.info("Content-Length= %s" % totalfichero)
|
||||
|
||||
blocksize = 100 * 1024
|
||||
|
||||
@@ -580,7 +580,7 @@ def downloadfileGzipped(url, pathfichero):
|
||||
gzipper = gzip.GzipFile(fileobj=compressedstream)
|
||||
bloquedata = gzipper.read()
|
||||
gzipper.close()
|
||||
logger.log("Starting downloading the file, blocked= %s" % len(bloqueleido))
|
||||
logger.info("Starting downloading the file, blocked= %s" % len(bloqueleido))
|
||||
except:
|
||||
logger.error("ERROR: The file to be downloaded is not compressed with Gzip")
|
||||
f.close()
|
||||
@@ -619,32 +619,32 @@ def downloadfileGzipped(url, pathfichero):
|
||||
tiempofalta = old_div(falta, velocidad)
|
||||
else:
|
||||
tiempofalta = 0
|
||||
logger.log(sec_to_hms(tiempofalta))
|
||||
logger.info(sec_to_hms(tiempofalta))
|
||||
progreso.update(percent, "%.2fMB/%.2fMB (%d%%) %.2f Kb/s %s left " % (descargadosmb, totalmb, percent, old_div(velocidad, 1024), sec_to_hms(tiempofalta)))
|
||||
break
|
||||
except:
|
||||
reintentos += 1
|
||||
logger.log("ERROR in block download, retry %d" % reintentos)
|
||||
logger.info("ERROR in block download, retry %d" % reintentos)
|
||||
for line in sys.exc_info():
|
||||
logger.error("%s" % line)
|
||||
|
||||
# The user cancels the download
|
||||
if progreso.iscanceled():
|
||||
logger.log("Download of file canceled")
|
||||
logger.info("Download of file canceled")
|
||||
f.close()
|
||||
progreso.close()
|
||||
return -1
|
||||
|
||||
# There was an error in the download
|
||||
if reintentos > maxreintentos:
|
||||
logger.log("ERROR in the file download")
|
||||
logger.info("ERROR in the file download")
|
||||
f.close()
|
||||
progreso.close()
|
||||
|
||||
return -2
|
||||
|
||||
except:
|
||||
logger.log("ERROR in the file download")
|
||||
logger.info("ERROR in the file download")
|
||||
for line in sys.exc_info():
|
||||
logger.error("%s" % line)
|
||||
f.close()
|
||||
@@ -655,15 +655,15 @@ def downloadfileGzipped(url, pathfichero):
|
||||
|
||||
# print data
|
||||
progreso.close()
|
||||
logger.log("End download of the file")
|
||||
logger.info("End download of the file")
|
||||
return nombrefichero
|
||||
|
||||
|
||||
def GetTitleFromFile(title):
|
||||
# Print in the log what you will discard
|
||||
logger.log("title= " + title)
|
||||
logger.info("title= " + title)
|
||||
plataforma = config.get_system_platform()
|
||||
logger.log("plataform= " + plataforma)
|
||||
logger.info("plataform= " + plataforma)
|
||||
|
||||
# nombrefichero = xbmc.makeLegalFilename(title + url[-4:])
|
||||
nombrefichero = title
|
||||
@@ -677,11 +677,11 @@ def sec_to_hms(seconds):
|
||||
|
||||
|
||||
def downloadIfNotModifiedSince(url, timestamp):
|
||||
logger.log("(" + url + "," + time.ctime(timestamp) + ")")
|
||||
logger.info("(" + url + "," + time.ctime(timestamp) + ")")
|
||||
|
||||
# Convert date to GMT
|
||||
fecha_formateada = time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime(timestamp))
|
||||
logger.log("Formatted date= %s" % fecha_formateada)
|
||||
logger.info("Formatted date= %s" % fecha_formateada)
|
||||
|
||||
# Check if it has changed
|
||||
inicio = time.clock()
|
||||
@@ -702,9 +702,9 @@ def downloadIfNotModifiedSince(url, timestamp):
|
||||
except urllib.error.URLError as e:
|
||||
# If it returns 304 it is that it has not changed
|
||||
if hasattr(e, 'code'):
|
||||
logger.log("HTTP response code : %d" % e.code)
|
||||
logger.info("HTTP response code : %d" % e.code)
|
||||
if e.code == 304:
|
||||
logger.log("It has not changed")
|
||||
logger.info("It has not changed")
|
||||
updated = False
|
||||
# Grab errors with response code from requested external server
|
||||
else:
|
||||
@@ -713,13 +713,13 @@ def downloadIfNotModifiedSince(url, timestamp):
|
||||
data = ""
|
||||
|
||||
fin = time.clock()
|
||||
logger.log("Downloaded in %d seconds " % (fin - inicio + 1))
|
||||
logger.info("Downloaded in %d seconds " % (fin - inicio + 1))
|
||||
|
||||
return updated, data
|
||||
|
||||
|
||||
def download_all_episodes(item, channel, first_episode="", preferred_server="vidspot", filter_language=""):
|
||||
logger.log("show= " + item.show)
|
||||
logger.info("show= " + item.show)
|
||||
show_title = item.show
|
||||
|
||||
# Gets the listing from which it was called
|
||||
@@ -749,9 +749,9 @@ def download_all_episodes(item, channel, first_episode="", preferred_server="vid
|
||||
|
||||
for episode_item in episode_itemlist:
|
||||
try:
|
||||
logger.log("episode= " + episode_item.title)
|
||||
logger.info("episode= " + episode_item.title)
|
||||
episode_title = scrapertools.find_single_match(episode_item.title, r"(\d+x\d+)")
|
||||
logger.log("episode= " + episode_title)
|
||||
logger.info("episode= " + episode_title)
|
||||
except:
|
||||
import traceback
|
||||
logger.error(traceback.format_exc())
|
||||
@@ -815,7 +815,7 @@ def download_all_episodes(item, channel, first_episode="", preferred_server="vid
|
||||
new_mirror_itemlist_4 + new_mirror_itemlist_5 + new_mirror_itemlist_6)
|
||||
|
||||
for mirror_item in mirrors_itemlist:
|
||||
logger.log("mirror= " + mirror_item.title)
|
||||
logger.info("mirror= " + mirror_item.title)
|
||||
|
||||
if "(Italiano)" in mirror_item.title:
|
||||
idioma = "(Italiano)"
|
||||
@@ -836,11 +836,11 @@ def download_all_episodes(item, channel, first_episode="", preferred_server="vid
|
||||
idioma = "(Desconocido)"
|
||||
codigo_idioma = "desconocido"
|
||||
|
||||
logger.log("filter_language=#" + filter_language + "#, codigo_idioma=#" + codigo_idioma + "#")
|
||||
logger.info("filter_language=#" + filter_language + "#, codigo_idioma=#" + codigo_idioma + "#")
|
||||
if filter_language == "" or (filter_language != "" and filter_language == codigo_idioma):
|
||||
logger.log("downloading mirror")
|
||||
logger.info("downloading mirror")
|
||||
else:
|
||||
logger.log("language " + codigo_idioma + " filtered, skipping")
|
||||
logger.info("language " + codigo_idioma + " filtered, skipping")
|
||||
continue
|
||||
|
||||
if hasattr(channel, 'play'):
|
||||
@@ -856,14 +856,14 @@ def download_all_episodes(item, channel, first_episode="", preferred_server="vid
|
||||
|
||||
# Adds it to the download list
|
||||
if puedes:
|
||||
logger.log("downloading mirror started...")
|
||||
logger.info("downloading mirror started...")
|
||||
# The highest quality video is the latest
|
||||
# mediaurl = video_urls[len(video_urls) - 1][1]
|
||||
devuelve = downloadbest(video_urls, show_title + " " + episode_title + " " + idioma +
|
||||
" [" + video_item.server + "]", continuar=False)
|
||||
|
||||
if devuelve == 0:
|
||||
logger.log("download ok")
|
||||
logger.info("download ok")
|
||||
descargado = True
|
||||
break
|
||||
elif devuelve == -1:
|
||||
@@ -874,14 +874,14 @@ def download_all_episodes(item, channel, first_episode="", preferred_server="vid
|
||||
pass
|
||||
return
|
||||
else:
|
||||
logger.log("download error, try another mirror")
|
||||
logger.info("download error, try another mirror")
|
||||
continue
|
||||
|
||||
else:
|
||||
logger.log("downloading mirror not available... trying next")
|
||||
logger.info("downloading mirror not available... trying next")
|
||||
|
||||
if not descargado:
|
||||
logger.log("UNDOWNLOADED EPISODE " + episode_title)
|
||||
logger.info("UNDOWNLOADED EPISODE " + episode_title)
|
||||
|
||||
|
||||
def episodio_ya_descargado(show_title, episode_title):
|
||||
@@ -889,9 +889,9 @@ def episodio_ya_descargado(show_title, episode_title):
|
||||
ficheros = filetools.listdir(".")
|
||||
|
||||
for fichero in ficheros:
|
||||
# logger.log("fichero="+fichero)
|
||||
# logger.info("fichero="+fichero)
|
||||
if fichero.lower().startswith(show_title.lower()) and scrapertools.find_single_match(fichero, "(\d+x\d+)") == episode_title:
|
||||
logger.log("found!")
|
||||
logger.info("found!")
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
+2
-2
@@ -814,7 +814,7 @@ def remove_tags(title):
|
||||
@rtype: str
|
||||
@return: string without tags
|
||||
"""
|
||||
logger.log()
|
||||
logger.info()
|
||||
|
||||
title_without_tags = scrapertools.find_single_match(title, r'\[color .+?\](.+)\[\/color\]')
|
||||
|
||||
@@ -832,7 +832,7 @@ def remove_smb_credential(path):
|
||||
@return: chain without credentials
|
||||
@rtype: str
|
||||
"""
|
||||
logger.log()
|
||||
logger.info()
|
||||
|
||||
if not scrapertools.find_single_match(path, r'(^\w+:\/\/)'):
|
||||
return path
|
||||
|
||||
+12
-12
@@ -125,11 +125,11 @@ def set_cookies(dict_cookie, clear=True, alfa_s=False):
|
||||
def load_cookies(alfa_s=False):
|
||||
cookies_lock.acquire()
|
||||
if os.path.isfile(cookies_file):
|
||||
if not alfa_s: logger.log("Reading cookies file")
|
||||
if not alfa_s: logger.info("Reading cookies file")
|
||||
try:
|
||||
cj.load(cookies_file, ignore_discard=True)
|
||||
except:
|
||||
if not alfa_s: logger.log("The cookie file exists but is illegible, it is deleted")
|
||||
if not alfa_s: logger.info("The cookie file exists but is illegible, it is deleted")
|
||||
os.remove(cookies_file)
|
||||
cookies_lock.release()
|
||||
|
||||
@@ -137,7 +137,7 @@ load_cookies()
|
||||
|
||||
def save_cookies(alfa_s=False):
|
||||
cookies_lock.acquire()
|
||||
if not alfa_s: logger.log("Saving cookies...")
|
||||
if not alfa_s: logger.debug("Saving cookies...")
|
||||
cj.save(cookies_file, ignore_discard=True)
|
||||
cookies_lock.release()
|
||||
|
||||
@@ -161,7 +161,7 @@ def random_useragent():
|
||||
|
||||
|
||||
def show_infobox(info_dict):
|
||||
logger.log()
|
||||
logger.debug()
|
||||
from textwrap import wrap
|
||||
|
||||
box_items_kodi = {'r_up_corner': u'\u250c',
|
||||
@@ -193,9 +193,9 @@ def show_infobox(info_dict):
|
||||
else:
|
||||
box = box_items
|
||||
|
||||
logger.log('%s%s%s' % (box['r_up_corner'], box['fill'] * width, box['l_up_corner']))
|
||||
logger.log('%s%s%s' % (box['center'], version.center(width), box['center']))
|
||||
logger.log('%s%s%s' % (box['r_center'], box['fill'] * width, box['l_center']))
|
||||
logger.debug('%s%s%s' % (box['r_up_corner'], box['fill'] * width, box['l_up_corner']))
|
||||
logger.debug('%s%s%s' % (box['center'], version.center(width), box['center']))
|
||||
logger.debug('%s%s%s' % (box['r_center'], box['fill'] * width, box['l_center']))
|
||||
|
||||
count = 0
|
||||
for key, value in info_dict:
|
||||
@@ -210,19 +210,19 @@ def show_infobox(info_dict):
|
||||
for line in text:
|
||||
if len(line) < width:
|
||||
line = line.ljust(width, ' ')
|
||||
logger.log('%s%s%s' % (box['center'], line, box['center']))
|
||||
logger.debug('%s%s%s' % (box['center'], line, box['center']))
|
||||
else:
|
||||
logger.log('%s%s%s' % (box['center'], text, box['center']))
|
||||
logger.debug('%s%s%s' % (box['center'], text, box['center']))
|
||||
if count < len(info_dict):
|
||||
logger.log('%s%s%s' % (box['r_center'], box['fill'] * width, box['l_center']))
|
||||
logger.debug('%s%s%s' % (box['r_center'], box['fill'] * width, box['l_center']))
|
||||
else:
|
||||
logger.log('%s%s%s' % (box['r_dn_corner'], box['fill'] * width, box['l_dn_corner']))
|
||||
logger.debug('%s%s%s' % (box['r_dn_corner'], box['fill'] * width, box['l_dn_corner']))
|
||||
return
|
||||
|
||||
|
||||
|
||||
def downloadpage(url, **opt):
|
||||
# logger.log()
|
||||
# logger.info()
|
||||
"""
|
||||
Open a url and return the data obtained
|
||||
|
||||
|
||||
+1
-1
@@ -298,7 +298,7 @@ class Item(object):
|
||||
def tostring(self, separator=", "):
|
||||
"""
|
||||
Generate a text string with the item's data for the log
|
||||
Use: logger.log(item.tostring())
|
||||
Use: logger.info(item.tostring())
|
||||
@param separator: string to be used as a separator
|
||||
@type separator: str
|
||||
'"""
|
||||
|
||||
+9
-9
@@ -11,24 +11,24 @@ from inspect import stack
|
||||
try:
|
||||
import json
|
||||
except:
|
||||
logger.log("json included in the interpreter **NOT** available")
|
||||
logger.info("json included in the interpreter **NOT** available")
|
||||
|
||||
try:
|
||||
import simplejson as json
|
||||
except:
|
||||
logger.log("simplejson included in the interpreter **NOT** available")
|
||||
logger.info("simplejson included in the interpreter **NOT** available")
|
||||
try:
|
||||
from lib import simplejson as json
|
||||
except:
|
||||
logger.log("simplejson in lib directory **NOT** available")
|
||||
logger.info("simplejson in lib directory **NOT** available")
|
||||
logger.error("A valid JSON parser was not found")
|
||||
json = None
|
||||
else:
|
||||
logger.log("Using simplejson in the lib directory")
|
||||
logger.info("Using simplejson in the lib directory")
|
||||
else:
|
||||
logger.log("Using simplejson included in the interpreter")
|
||||
logger.info("Using simplejson included in the interpreter")
|
||||
# ~ else:
|
||||
# ~ logger.log("Usando json incluido en el interprete")
|
||||
# ~ logger.info("Usando json incluido en el interprete")
|
||||
|
||||
import sys
|
||||
PY3 = False
|
||||
@@ -90,7 +90,7 @@ def get_node_from_file(name_file, node, path=None):
|
||||
@return: dict with the node to return
|
||||
@rtype: dict
|
||||
"""
|
||||
logger.log()
|
||||
logger.debug()
|
||||
from platformcode import config
|
||||
from core import filetools
|
||||
|
||||
@@ -129,7 +129,7 @@ def check_to_backup(data, fname, dict_data):
|
||||
@param dict_data: dictionary name
|
||||
@type dict_data: dict
|
||||
"""
|
||||
logger.log()
|
||||
logger.debug()
|
||||
|
||||
if not dict_data:
|
||||
logger.error("Error loading json from file %s" % fname)
|
||||
@@ -161,7 +161,7 @@ def update_node(dict_node, name_file, node, path=None, silent=False):
|
||||
@return json_data
|
||||
@rtype: dict
|
||||
"""
|
||||
if not silent: logger.log()
|
||||
if not silent: logger.info()
|
||||
|
||||
from platformcode import config
|
||||
from core import filetools
|
||||
|
||||
+6
-6
@@ -61,7 +61,7 @@ def find_and_set_infoLabels(item):
|
||||
# Check if there is a 'code'
|
||||
if scraper_result and item.infoLabels['code']:
|
||||
# correct code
|
||||
logger.log("Identificador encontrado: %s" % item.infoLabels['code'])
|
||||
logger.info("Identificador encontrado: %s" % item.infoLabels['code'])
|
||||
scraper.completar_codigos(item)
|
||||
return True
|
||||
elif scraper_result:
|
||||
@@ -71,7 +71,7 @@ def find_and_set_infoLabels(item):
|
||||
# Content not found
|
||||
msg = config.get_localized_string(60228) % title
|
||||
|
||||
logger.log(msg)
|
||||
logger.info(msg)
|
||||
# Show box with other options:
|
||||
if scrapers_disponibles[scraper_actual] in list_opciones_cuadro:
|
||||
list_opciones_cuadro.remove(scrapers_disponibles[scraper_actual])
|
||||
@@ -95,10 +95,10 @@ def find_and_set_infoLabels(item):
|
||||
|
||||
elif index == 1:
|
||||
# You have to create a dialog box to enter the data
|
||||
logger.log("Complete information")
|
||||
logger.info("Complete information")
|
||||
if cuadro_completar(item):
|
||||
# correct code
|
||||
logger.log("Identifier found: %s" % str(item.infoLabels['code']))
|
||||
logger.info("Identifier found: %s" % str(item.infoLabels['code']))
|
||||
return True
|
||||
# raise
|
||||
|
||||
@@ -121,7 +121,7 @@ def find_and_set_infoLabels(item):
|
||||
|
||||
|
||||
def cuadro_completar(item):
|
||||
logger.log()
|
||||
logger.info()
|
||||
|
||||
global dict_default
|
||||
dict_default = {}
|
||||
@@ -234,7 +234,7 @@ def get_nfo(item):
|
||||
@rtype: str
|
||||
@return:
|
||||
"""
|
||||
logger.log()
|
||||
logger.info()
|
||||
if "infoLabels" in item and "noscrap_id" in item.infoLabels:
|
||||
# Create the xml file with the data obtained from the item since there is no active scraper
|
||||
info_nfo = '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>'
|
||||
|
||||
@@ -34,7 +34,7 @@ from platformcode import logger
|
||||
def printMatches(matches):
|
||||
i = 0
|
||||
for match in matches:
|
||||
logger.log("%d %s" % (i, match))
|
||||
logger.info("%d %s" % (i, match))
|
||||
i = i + 1
|
||||
|
||||
|
||||
@@ -447,7 +447,7 @@ def get_season_and_episode(title):
|
||||
except:
|
||||
pass
|
||||
|
||||
logger.log("'" + title + "' -> '" + filename + "'")
|
||||
logger.info("'" + title + "' -> '" + filename + "'")
|
||||
|
||||
return filename
|
||||
|
||||
|
||||
+31
-31
@@ -47,7 +47,7 @@ def find_video_items(item=None, data=None):
|
||||
@return: returns the itemlist with the results
|
||||
@rtype: list
|
||||
"""
|
||||
logger.log()
|
||||
logger.info()
|
||||
itemlist = []
|
||||
|
||||
# Download the page
|
||||
@@ -97,7 +97,7 @@ def get_servers_itemlist(itemlist, fnc=None, sort=False):
|
||||
|
||||
# Walk the patterns
|
||||
for pattern in server_parameters.get("find_videos", {}).get("patterns", []):
|
||||
logger.log(pattern["pattern"])
|
||||
logger.info(pattern["pattern"])
|
||||
# Scroll through the results
|
||||
for match in re.compile(pattern["pattern"], re.DOTALL).finditer(
|
||||
"\n".join([item.url.split('|')[0] for item in itemlist if not item.server])):
|
||||
@@ -144,7 +144,7 @@ def findvideos(data, skip=False):
|
||||
return some link. It can also be an integer greater than 1, which would represent the maximum number of links to search.
|
||||
:return:
|
||||
"""
|
||||
logger.log()
|
||||
logger.info()
|
||||
devuelve = []
|
||||
skip = int(skip)
|
||||
servers_list = list(get_servers_list().keys())
|
||||
@@ -181,7 +181,7 @@ def findvideosbyserver(data, serverid):
|
||||
value = translate_server_name(server_parameters["name"]) , url, serverid, server_parameters.get("thumbnail", "")
|
||||
if value not in devuelve and url not in server_parameters["find_videos"].get("ignore_urls", []):
|
||||
devuelve.append(value)
|
||||
logger.log(msg)
|
||||
logger.info(msg)
|
||||
|
||||
return devuelve
|
||||
|
||||
@@ -193,7 +193,7 @@ def guess_server_thumbnail(serverid):
|
||||
|
||||
|
||||
def get_server_from_url(url):
|
||||
logger.log()
|
||||
logger.info()
|
||||
servers_list = list(get_servers_list().keys())
|
||||
|
||||
# Run findvideos on each active server
|
||||
@@ -211,7 +211,7 @@ def get_server_from_url(url):
|
||||
for n, pattern in enumerate(server_parameters["find_videos"].get("patterns", [])):
|
||||
msg = "%s\npattern: %s" % (serverid, pattern["pattern"])
|
||||
if not "pattern_compiled" in pattern:
|
||||
# logger.log('compiled ' + serverid)
|
||||
# logger.info('compiled ' + serverid)
|
||||
pattern["pattern_compiled"] = re.compile(pattern["pattern"])
|
||||
dict_servers_parameters[serverid]["find_videos"]["patterns"][n]["pattern_compiled"] = pattern["pattern_compiled"]
|
||||
# Scroll through the results
|
||||
@@ -224,7 +224,7 @@ def get_server_from_url(url):
|
||||
msg += "\nurl encontrada: %s" % url
|
||||
value = translate_server_name(server_parameters["name"]), url, serverid, server_parameters.get("thumbnail", "")
|
||||
if url not in server_parameters["find_videos"].get("ignore_urls", []):
|
||||
logger.log(msg)
|
||||
logger.info(msg)
|
||||
return value
|
||||
|
||||
return None
|
||||
@@ -247,7 +247,7 @@ def resolve_video_urls_for_playing(server, url, video_password="", muestra_dialo
|
||||
@return: returns the url of the video
|
||||
@rtype: list
|
||||
"""
|
||||
logger.log("Server: %s, Url: %s" % (server, url))
|
||||
logger.info("Server: %s, Url: %s" % (server, url))
|
||||
|
||||
server = server.lower()
|
||||
|
||||
@@ -260,7 +260,7 @@ def resolve_video_urls_for_playing(server, url, video_password="", muestra_dialo
|
||||
if server == "directo" or server == "local":
|
||||
if isinstance(video_password, list):
|
||||
return video_password, len(video_password) > 0, "<br/>".join(error_messages)
|
||||
logger.log("Server: %s, url is good" % server)
|
||||
logger.info("Server: %s, url is good" % server)
|
||||
video_urls.append(["%s [%s]" % (urlparse.urlparse(url)[2][-4:], config.get_localized_string(30137)), url])
|
||||
|
||||
# Find out the video URL
|
||||
@@ -291,7 +291,7 @@ def resolve_video_urls_for_playing(server, url, video_password="", muestra_dialo
|
||||
priority = int(config.get_setting("resolve_priority"))
|
||||
opciones = sorted(opciones, key=lambda x: orden[priority].index(x))
|
||||
|
||||
logger.log("Available options: %s | %s" % (len(opciones), opciones))
|
||||
logger.info("Available options: %s | %s" % (len(opciones), opciones))
|
||||
else:
|
||||
logger.error("There is no connector for the server %s" % server)
|
||||
error_messages.append(config.get_localized_string(60004) % server)
|
||||
@@ -300,7 +300,7 @@ def resolve_video_urls_for_playing(server, url, video_password="", muestra_dialo
|
||||
# Import the server
|
||||
try:
|
||||
server_module = __import__('servers.%s' % server, None, None, ["servers.%s" % server])
|
||||
logger.log("Imported server: %s" % server_module)
|
||||
logger.info("Imported server: %s" % server_module)
|
||||
except:
|
||||
server_module = None
|
||||
if muestra_dialogo:
|
||||
@@ -311,17 +311,17 @@ def resolve_video_urls_for_playing(server, url, video_password="", muestra_dialo
|
||||
|
||||
# If it has a function to see if the video exists, check it now
|
||||
if hasattr(server_module, 'test_video_exists'):
|
||||
logger.log("Invoking a %s.test_video_exists" % server)
|
||||
logger.info("Invoking a %s.test_video_exists" % server)
|
||||
try:
|
||||
video_exists, message = server_module.test_video_exists(page_url=url)
|
||||
|
||||
if not video_exists:
|
||||
error_messages.append(message)
|
||||
logger.log("test_video_exists says video doesn't exist")
|
||||
logger.info("test_video_exists says video doesn't exist")
|
||||
if muestra_dialogo:
|
||||
progreso.close()
|
||||
else:
|
||||
logger.log("test_video_exists says the video DOES exist")
|
||||
logger.info("test_video_exists says the video DOES exist")
|
||||
except:
|
||||
logger.error("Could not verify if the video exists")
|
||||
import traceback
|
||||
@@ -348,7 +348,7 @@ def resolve_video_urls_for_playing(server, url, video_password="", muestra_dialo
|
||||
# Free mode
|
||||
if opcion == "free":
|
||||
try:
|
||||
logger.log("Invoking a %s.get_video_url" % server)
|
||||
logger.info("Invoking a %s.get_video_url" % server)
|
||||
response = serverid.get_video_url(page_url=url, video_password=video_password)
|
||||
video_urls.extend(response)
|
||||
except:
|
||||
@@ -360,7 +360,7 @@ def resolve_video_urls_for_playing(server, url, video_password="", muestra_dialo
|
||||
# Premium mode
|
||||
else:
|
||||
try:
|
||||
logger.log("Invoking a %s.get_video_url" % opcion)
|
||||
logger.info("Invoking a %s.get_video_url" % opcion)
|
||||
response = serverid.get_video_url(page_url=url, premium=True,
|
||||
user=config.get_setting("user", server=opcion),
|
||||
password=config.get_setting("password", server=opcion),
|
||||
@@ -470,7 +470,7 @@ def get_server_parameters(server):
|
||||
@return: server data
|
||||
@rtype: dict
|
||||
"""
|
||||
# logger.log("server %s" % server)
|
||||
# logger.info("server %s" % server)
|
||||
global dict_servers_parameters
|
||||
server = server.split('.')[0]
|
||||
if not server:
|
||||
@@ -520,15 +520,15 @@ def get_server_parameters(server):
|
||||
|
||||
|
||||
# def get_server_json(server_name):
|
||||
# # logger.log("server_name=" + server_name)
|
||||
# # logger.info("server_name=" + server_name)
|
||||
# try:
|
||||
# server_path = filetools.join(config.get_runtime_path(), "servers", server_name + ".json")
|
||||
# if not filetools.exists(server_path):
|
||||
# server_path = filetools.join(config.get_runtime_path(), "servers", "debriders", server_name + ".json")
|
||||
#
|
||||
# # logger.log("server_path=" + server_path)
|
||||
# # logger.info("server_path=" + server_path)
|
||||
# server_json = jsontools.load(filetools.read(server_path))
|
||||
# # logger.log("server_json= %s" % server_json)
|
||||
# # logger.info("server_json= %s" % server_json)
|
||||
#
|
||||
# except Exception as ex:
|
||||
# template = "An exception of type %s occured. Arguments:\n%r"
|
||||
@@ -600,7 +600,7 @@ def get_server_setting(name, server, default=None):
|
||||
if isinstance(dict_file, dict) and 'settings' in dict_file:
|
||||
dict_settings = dict_file['settings']
|
||||
except EnvironmentError:
|
||||
logger.log("ERROR when reading the file: %s" % file_settings)
|
||||
logger.info("ERROR when reading the file: %s" % file_settings)
|
||||
|
||||
if not dict_settings or name not in dict_settings:
|
||||
# We get controls from the file ../servers/server.json
|
||||
@@ -614,7 +614,7 @@ def get_server_setting(name, server, default=None):
|
||||
dict_file['settings'] = dict_settings
|
||||
# We create the file ../settings/channel_data.json
|
||||
if not filetools.write(file_settings, jsontools.dump(dict_file)):
|
||||
logger.log("ERROR saving file: %s" % file_settings)
|
||||
logger.info("ERROR saving file: %s" % file_settings)
|
||||
|
||||
# We return the value of the local parameter 'name' if it exists, if default is not returned
|
||||
return dict_settings.get(name, default)
|
||||
@@ -636,7 +636,7 @@ def set_server_setting(name, value, server):
|
||||
dict_file = jsontools.load(filetools.read(file_settings))
|
||||
dict_settings = dict_file.get('settings', {})
|
||||
except EnvironmentError:
|
||||
logger.log("ERROR when reading the file: %s" % file_settings)
|
||||
logger.info("ERROR when reading the file: %s" % file_settings)
|
||||
|
||||
dict_settings[name] = value
|
||||
|
||||
@@ -648,7 +648,7 @@ def set_server_setting(name, value, server):
|
||||
|
||||
# We create the file ../settings/channel_data.json
|
||||
if not filetools.write(file_settings, jsontools.dump(dict_file)):
|
||||
logger.log("ERROR saving file: %s" % file_settings)
|
||||
logger.info("ERROR saving file: %s" % file_settings)
|
||||
return None
|
||||
|
||||
return value
|
||||
@@ -683,7 +683,7 @@ def get_debriders_list():
|
||||
if server.endswith(".json"):
|
||||
server_parameters = get_server_parameters(server)
|
||||
if server_parameters["active"] == True:
|
||||
logger.log(server_parameters)
|
||||
logger.info(server_parameters)
|
||||
server_list[server.split(".")[0]] = server_parameters
|
||||
return server_list
|
||||
|
||||
@@ -729,7 +729,7 @@ def check_list_links(itemlist, numero='', timeout=3):
|
||||
it = res[0]
|
||||
verificacion = res[1]
|
||||
it.title = verificacion + ' ' + it.title.strip()
|
||||
logger.log('VERIFICATION= ' + verificacion)
|
||||
logger.info('VERIFICATION= ' + verificacion)
|
||||
it.alive = verificacion
|
||||
return itemlist
|
||||
|
||||
@@ -750,7 +750,7 @@ def check_video_link(item, timeout=3):
|
||||
server_module = __import__('servers.%s' % server, None, None, ["servers.%s" % server])
|
||||
except:
|
||||
server_module = None
|
||||
logger.log("[check_video_link] Cannot import server! %s" % server)
|
||||
logger.info("[check_video_link] Cannot import server! %s" % server)
|
||||
return item, NK
|
||||
|
||||
if hasattr(server_module, 'test_video_exists'):
|
||||
@@ -760,20 +760,20 @@ def check_video_link(item, timeout=3):
|
||||
try:
|
||||
video_exists, message = server_module.test_video_exists(page_url=url)
|
||||
if not video_exists:
|
||||
logger.log("[check_video_link] Does not exist! %s %s %s" % (message, server, url))
|
||||
logger.info("[check_video_link] Does not exist! %s %s %s" % (message, server, url))
|
||||
resultado = KO
|
||||
else:
|
||||
logger.log("[check_video_link] check ok %s %s" % (server, url))
|
||||
logger.info("[check_video_link] check ok %s %s" % (server, url))
|
||||
resultado = OK
|
||||
except:
|
||||
logger.log("[check_video_link] Can't check now! %s %s" % (server, url))
|
||||
logger.info("[check_video_link] Can't check now! %s %s" % (server, url))
|
||||
resultado = NK
|
||||
|
||||
finally:
|
||||
httptools.HTTPTOOLS_DEFAULT_DOWNLOAD_TIMEOUT = ant_timeout # Restore download time
|
||||
return item, resultado
|
||||
|
||||
logger.log("[check_video_link] There is no test_video_exists for server: %s" % server)
|
||||
logger.info("[check_video_link] There is no test_video_exists for server: %s" % server)
|
||||
return item, NK
|
||||
|
||||
def translate_server_name(name):
|
||||
|
||||
+23
-29
@@ -7,13 +7,12 @@ PY3 = False
|
||||
if sys.version_info[0] >= 3: PY3 = True; unicode = str; unichr = chr; long = int
|
||||
if PY3:
|
||||
from concurrent import futures
|
||||
import urllib.request as urllib
|
||||
from urllib.request import Request, urlopen
|
||||
import urllib.parse as urlparse
|
||||
from urllib.parse import urlencode
|
||||
else:
|
||||
from concurrent_py2 import futures
|
||||
import urllib, urlparse
|
||||
import urlparse
|
||||
from urllib2 import Request, urlopen
|
||||
from urllib import urlencode
|
||||
|
||||
@@ -22,7 +21,7 @@ from core import httptools, scrapertools, servertools, tmdb, channeltools
|
||||
from core.item import Item
|
||||
from lib import unshortenit
|
||||
from platformcode import config
|
||||
from platformcode.logger import log
|
||||
from platformcode.logger import info
|
||||
from platformcode import logger
|
||||
from specials import autoplay
|
||||
|
||||
@@ -35,7 +34,7 @@ def hdpass_get_servers(item):
|
||||
|
||||
for mir_url, srv in scrapertools.find_multiple_matches(mir, patron_option):
|
||||
mir_url = scrapertools.decodeHtmlentities(mir_url)
|
||||
log(mir_url)
|
||||
info(mir_url)
|
||||
it = item.clone(action="play", quality=quality, title=srv, server=srv, url= mir_url)
|
||||
if not servertools.get_server_parameters(srv.lower()): it = hdpass_get_url(it)[0] # do not exists or it's empty
|
||||
ret.append(it)
|
||||
@@ -83,7 +82,7 @@ def color(text, color):
|
||||
|
||||
|
||||
def search(channel, item, texto):
|
||||
log(item.url + " search " + texto)
|
||||
info(item.url + " search " + texto)
|
||||
if 'findhost' in dir(channel): channel.findhost()
|
||||
item.url = channel.host + "/?s=" + texto
|
||||
try:
|
||||
@@ -162,11 +161,10 @@ def unifyEp(ep):
|
||||
|
||||
def scrapeBlock(item, args, block, patron, headers, action, pagination, debug, typeContentDict, typeActionDict, blacklist, search, pag, function, lang, sceneTitle):
|
||||
itemlist = []
|
||||
log("scrapeBlock qui")
|
||||
if debug:
|
||||
regexDbg(item, patron, headers, block)
|
||||
matches = scrapertools.find_multiple_matches_groups(block, patron)
|
||||
log('MATCHES =', matches)
|
||||
logger.debug('MATCHES =', matches)
|
||||
|
||||
known_keys = ['url', 'title', 'title2', 'season', 'episode', 'thumb', 'quality', 'year', 'plot', 'duration', 'genere', 'rating', 'type', 'lang', 'other', 'size', 'seed']
|
||||
# Legenda known_keys per i groups nei patron
|
||||
@@ -283,7 +281,7 @@ def scrapeBlock(item, args, block, patron, headers, action, pagination, debug, t
|
||||
try:
|
||||
parsedTitle = guessit(title)
|
||||
title = longtitle = parsedTitle.get('title', '')
|
||||
log('TITOLO',title)
|
||||
logger.debug('TITOLO',title)
|
||||
if parsedTitle.get('source'):
|
||||
quality = str(parsedTitle.get('source'))
|
||||
if parsedTitle.get('screen_size'):
|
||||
@@ -317,7 +315,7 @@ def scrapeBlock(item, args, block, patron, headers, action, pagination, debug, t
|
||||
longtitle += s + parsedTitle.get('episode_title')
|
||||
item.contentEpisodeTitle = parsedTitle.get('episode_title')
|
||||
except:
|
||||
log('Error')
|
||||
logger.debug('Error')
|
||||
|
||||
longtitle = typo(longtitle, 'bold')
|
||||
lang1, longtitle = scrapeLang(scraped, lang, longtitle)
|
||||
@@ -404,7 +402,7 @@ def scrape(func):
|
||||
|
||||
args = func(*args)
|
||||
function = func.__name__ if not 'actLike' in args else args['actLike']
|
||||
# log('STACK= ',inspect.stack()[1][3])
|
||||
# info('STACK= ',inspect.stack()[1][3])
|
||||
|
||||
item = args['item']
|
||||
|
||||
@@ -436,7 +434,7 @@ def scrape(func):
|
||||
matches = []
|
||||
|
||||
for n in range(2):
|
||||
log('PATRON= ', patron)
|
||||
logger.debug('PATRON= ', patron)
|
||||
if not data:
|
||||
page = httptools.downloadpage(item.url, headers=headers, ignore_response_code=True)
|
||||
data = re.sub("='([^']+)'", '="\\1"', page.data)
|
||||
@@ -452,7 +450,7 @@ def scrape(func):
|
||||
blocks = scrapertools.find_multiple_matches_groups(data, patronBlock)
|
||||
block = ""
|
||||
for bl in blocks:
|
||||
# log(len(blocks),bl)
|
||||
# info(len(blocks),bl)
|
||||
if 'season' in bl and bl['season']:
|
||||
item.season = bl['season']
|
||||
blockItemlist, blockMatches = scrapeBlock(item, args, bl['block'], patron, headers, action, pagination, debug,
|
||||
@@ -477,7 +475,7 @@ def scrape(func):
|
||||
|
||||
# if url may be changed and channel has findhost to update
|
||||
if 'findhost' in func.__globals__ and not itemlist:
|
||||
log('running findhost ' + func.__module__)
|
||||
info('running findhost ' + func.__module__)
|
||||
host = func.__globals__['findhost']()
|
||||
parse = list(urlparse.urlparse(item.url))
|
||||
from core import jsontools
|
||||
@@ -534,7 +532,7 @@ def scrape(func):
|
||||
if config.get_setting('trakt_sync'):
|
||||
from core import trakt_tools
|
||||
trakt_tools.trakt_check(itemlist)
|
||||
log('scraping time: ', time()-scrapingTime)
|
||||
logger.debug('scraping time: ', time()-scrapingTime)
|
||||
return itemlist
|
||||
|
||||
return wrapper
|
||||
@@ -712,15 +710,11 @@ def menuItem(itemlist, filename, title='', action='', url='', contentType='undef
|
||||
|
||||
def menu(func):
|
||||
def wrapper(*args):
|
||||
log()
|
||||
args = func(*args)
|
||||
|
||||
item = args['item']
|
||||
log(item.channel + ' start')
|
||||
logger.debug(item.channel + ' menu start')
|
||||
host = func.__globals__['host']
|
||||
list_servers = func.__globals__['list_servers'] if 'list_servers' in func.__globals__ else ['directo']
|
||||
list_quality = func.__globals__['list_quality'] if 'list_quality' in func.__globals__ else ['default']
|
||||
log('LIST QUALITY', list_quality)
|
||||
filename = func.__module__.split('.')[1]
|
||||
single_search = False
|
||||
# listUrls = ['film', 'filmSub', 'tvshow', 'tvshowSub', 'anime', 'animeSub', 'search', 'top', 'topSub']
|
||||
@@ -735,7 +729,7 @@ def menu(func):
|
||||
|
||||
for name in listUrls:
|
||||
dictUrl[name] = args[name] if name in args else None
|
||||
log(dictUrl[name])
|
||||
logger.debug(dictUrl[name])
|
||||
if name == 'film': title = 'Film'
|
||||
if name == 'tvshow': title = 'Serie TV'
|
||||
if name == 'anime': title = 'Anime'
|
||||
@@ -803,7 +797,7 @@ def menu(func):
|
||||
|
||||
# Apply auto Thumbnails at the menus
|
||||
thumb(itemlist)
|
||||
log(item.channel + ' end')
|
||||
logger.debug(item.channel + ' menu end')
|
||||
return itemlist
|
||||
|
||||
return wrapper
|
||||
@@ -1066,7 +1060,7 @@ def videolibrary(itemlist, item, typography='', function_level=1, function=''):
|
||||
# Simply add this function to add video library support
|
||||
# Function_level is useful if the function is called by another function.
|
||||
# If the call is direct, leave it blank
|
||||
log()
|
||||
info()
|
||||
|
||||
if item.contentType == 'movie':
|
||||
action = 'add_pelicula_to_library'
|
||||
@@ -1116,7 +1110,7 @@ def videolibrary(itemlist, item, typography='', function_level=1, function=''):
|
||||
def nextPage(itemlist, item, data='', patron='', function_or_level=1, next_page='', resub=[]):
|
||||
# Function_level is useful if the function is called by another function.
|
||||
# If the call is direct, leave it blank
|
||||
log()
|
||||
info()
|
||||
action = inspect.stack()[function_or_level][3] if type(function_or_level) == int else function_or_level
|
||||
if next_page == '':
|
||||
next_page = scrapertools.find_single_match(data, patron)
|
||||
@@ -1126,7 +1120,7 @@ def nextPage(itemlist, item, data='', patron='', function_or_level=1, next_page=
|
||||
if 'http' not in next_page:
|
||||
next_page = scrapertools.find_single_match(item.url, 'https?://[a-z0-9.-]+') + (next_page if next_page.startswith('/') else '/' + next_page)
|
||||
next_page = next_page.replace('&', '&')
|
||||
log('NEXT= ', next_page)
|
||||
info('NEXT= ', next_page)
|
||||
itemlist.append(
|
||||
Item(channel=item.channel,
|
||||
action = action,
|
||||
@@ -1154,7 +1148,7 @@ def pagination(itemlist, item, page, perpage, function_level=1):
|
||||
|
||||
|
||||
def server(item, data='', itemlist=[], headers='', AutoPlay=True, CheckLinks=True, Download=True, patronTag=None, Videolibrary=True):
|
||||
log()
|
||||
info()
|
||||
blacklisted_servers = config.get_setting("black_list", server='servers')
|
||||
if not blacklisted_servers: blacklisted_servers = []
|
||||
if not data and not itemlist:
|
||||
@@ -1167,7 +1161,7 @@ def server(item, data='', itemlist=[], headers='', AutoPlay=True, CheckLinks=Tru
|
||||
def getItem(videoitem):
|
||||
if not servertools.get_server_parameters(videoitem.server.lower()): # do not exists or it's empty
|
||||
findS = servertools.get_server_from_url(videoitem.url)
|
||||
log(findS)
|
||||
info(findS)
|
||||
if not findS:
|
||||
if item.channel == 'community':
|
||||
findS= (config.get_localized_string(30137), videoitem.url, 'directo')
|
||||
@@ -1175,7 +1169,7 @@ def server(item, data='', itemlist=[], headers='', AutoPlay=True, CheckLinks=Tru
|
||||
videoitem.url = unshortenit.unshorten_only(videoitem.url)[0]
|
||||
findS = servertools.get_server_from_url(videoitem.url)
|
||||
if not findS:
|
||||
log(videoitem, 'Non supportato')
|
||||
info(videoitem, 'Non supportato')
|
||||
return
|
||||
videoitem.server = findS[2]
|
||||
videoitem.title = findS[0]
|
||||
@@ -1328,7 +1322,7 @@ def addQualityTag(item, itemlist, data, patron):
|
||||
folder=False,
|
||||
thumbnail=thumb('info')))
|
||||
else:
|
||||
log('nessun tag qualità trovato')
|
||||
info('nessun tag qualità trovato')
|
||||
|
||||
def get_jwplayer_mediaurl(data, srvName, onlyHttp=False):
|
||||
video_urls = []
|
||||
@@ -1419,7 +1413,7 @@ def thumb(item_itemlist_string=None, genre=False, live=False):
|
||||
'_tvshow':['serie','tv', 'fiction']}
|
||||
|
||||
def autoselect_thumb(item, genre):
|
||||
log('SPLIT',re.split(r'\.|\{|\}|\[|\]|\(|\)|/| ',item.title.lower()))
|
||||
info('SPLIT',re.split(r'\.|\{|\}|\[|\]|\(|\)|/| ',item.title.lower()))
|
||||
if genre == False:
|
||||
for thumb, titles in icon_dict.items():
|
||||
if any(word in re.split(r'\.|\{|\}|\[|\]|\(|\)|/| ',item.title.lower()) for word in search):
|
||||
|
||||
+9
-9
@@ -87,7 +87,7 @@ create_bd()
|
||||
|
||||
# The function name is the name of the decorator and receives the function that decorates.
|
||||
def cache_response(fn):
|
||||
logger.log()
|
||||
logger.info()
|
||||
|
||||
# import time
|
||||
# start_time = time.time()
|
||||
@@ -498,7 +498,7 @@ def set_infoLabels_item(item, seekTmdb=True, idioma_busqueda=def_lang, lock=None
|
||||
|
||||
|
||||
def find_and_set_infoLabels(item):
|
||||
logger.log()
|
||||
logger.info()
|
||||
|
||||
global otmdb_global
|
||||
tmdb_result = None
|
||||
@@ -908,7 +908,7 @@ class Tmdb(object):
|
||||
cls.dic_generos[idioma][tipo] = {}
|
||||
url = ('http://api.themoviedb.org/3/genre/%s/list?api_key=a1ab8b8669da03637a4b98fa39c39228&language=%s' % (tipo, idioma))
|
||||
try:
|
||||
logger.log("[Tmdb.py] Filling in dictionary of genres")
|
||||
logger.info("[Tmdb.py] Filling in dictionary of genres")
|
||||
|
||||
resultado = cls.get_json(url)
|
||||
if not isinstance(resultado, dict):
|
||||
@@ -940,7 +940,7 @@ class Tmdb(object):
|
||||
'&language=%s' % (self.busqueda_id, source, self.busqueda_idioma))
|
||||
buscando = "%s: %s" % (source.capitalize(), self.busqueda_id)
|
||||
|
||||
logger.log("[Tmdb.py] Searching %s:\n%s" % (buscando, url))
|
||||
logger.info("[Tmdb.py] Searching %s:\n%s" % (buscando, url))
|
||||
resultado = self.get_json(url)
|
||||
if not isinstance(resultado, dict):
|
||||
resultado = ast.literal_eval(resultado.decode('utf-8'))
|
||||
@@ -985,7 +985,7 @@ class Tmdb(object):
|
||||
url += '&year=%s' % self.busqueda_year
|
||||
|
||||
buscando = self.busqueda_texto.capitalize()
|
||||
logger.log("[Tmdb.py] Searching %s on page %s:\n%s" % (buscando, page, url))
|
||||
logger.info("[Tmdb.py] Searching %s on page %s:\n%s" % (buscando, page, url))
|
||||
resultado = self.get_json(url)
|
||||
if not isinstance(resultado, dict):
|
||||
resultado = ast.literal_eval(resultado.decode('utf-8'))
|
||||
@@ -1046,7 +1046,7 @@ class Tmdb(object):
|
||||
url = ('http://api.themoviedb.org/3/%s?api_key=a1ab8b8669da03637a4b98fa39c39228&%s'
|
||||
% (type_search, "&".join(params)))
|
||||
|
||||
logger.log("[Tmdb.py] Searcing %s:\n%s" % (type_search, url))
|
||||
logger.info("[Tmdb.py] Searcing %s:\n%s" % (type_search, url))
|
||||
resultado = self.get_json(url)
|
||||
if not isinstance(resultado, dict):
|
||||
resultado = ast.literal_eval(resultado.decode('utf-8'))
|
||||
@@ -1111,7 +1111,7 @@ class Tmdb(object):
|
||||
return True
|
||||
|
||||
def get_list_resultados(self, num_result=20):
|
||||
# logger.log("self %s" % str(self))
|
||||
# logger.info("self %s" % str(self))
|
||||
res = []
|
||||
|
||||
if num_result <= 0:
|
||||
@@ -1331,7 +1331,7 @@ class Tmdb(object):
|
||||
"&append_to_response=credits" % (self.result["id"], numtemporada, self.busqueda_idioma)
|
||||
|
||||
buscando = "id_Tmdb: " + str(self.result["id"]) + " season: " + str(numtemporada) + "\nURL: " + url
|
||||
logger.log("[Tmdb.py] Searcing " + buscando)
|
||||
logger.info("[Tmdb.py] Searcing " + buscando)
|
||||
try:
|
||||
self.temporada[numtemporada] = self.get_json(url)
|
||||
if not isinstance(self.temporada[numtemporada], dict):
|
||||
@@ -1520,7 +1520,7 @@ class Tmdb(object):
|
||||
|
||||
items.extend(list(self.get_episodio(ret_infoLabels['season'], episodio).items()))
|
||||
|
||||
# logger.log("ret_infoLabels" % ret_infoLabels)
|
||||
# logger.info("ret_infoLabels" % ret_infoLabels)
|
||||
|
||||
for k, v in items:
|
||||
if not v:
|
||||
|
||||
+7
-7
@@ -128,7 +128,7 @@ def token_trakt(item):
|
||||
|
||||
|
||||
def set_trakt_info(item):
|
||||
logger.log()
|
||||
logger.info()
|
||||
import xbmcgui
|
||||
# Envia los datos a trakt
|
||||
try:
|
||||
@@ -139,7 +139,7 @@ def set_trakt_info(item):
|
||||
pass
|
||||
|
||||
def get_trakt_watched(id_type, mediatype, update=False):
|
||||
logger.log()
|
||||
logger.info()
|
||||
|
||||
id_list = []
|
||||
id_dict = dict()
|
||||
@@ -229,7 +229,7 @@ def trakt_check(itemlist):
|
||||
|
||||
|
||||
def get_sync_from_file():
|
||||
logger.log()
|
||||
logger.info()
|
||||
sync_path = os.path.join(config.get_data_path(), 'settings_channels', 'trakt_data.json')
|
||||
trakt_node = {}
|
||||
if os.path.exists(sync_path):
|
||||
@@ -241,7 +241,7 @@ def get_sync_from_file():
|
||||
|
||||
|
||||
def update_trakt_data(mediatype, trakt_data):
|
||||
logger.log()
|
||||
logger.info()
|
||||
|
||||
sync_path = os.path.join(config.get_data_path(), 'settings_channels', 'trakt_data.json')
|
||||
if os.path.exists(sync_path):
|
||||
@@ -251,7 +251,7 @@ def update_trakt_data(mediatype, trakt_data):
|
||||
|
||||
|
||||
def ask_install_script():
|
||||
logger.log()
|
||||
logger.info()
|
||||
|
||||
from platformcode import platformtools
|
||||
|
||||
@@ -265,7 +265,7 @@ def ask_install_script():
|
||||
|
||||
|
||||
def wait_for_update_trakt():
|
||||
logger.log()
|
||||
logger.info()
|
||||
t = Thread(update_all)
|
||||
t.setDaemon(True)
|
||||
t.start()
|
||||
@@ -274,7 +274,7 @@ def wait_for_update_trakt():
|
||||
def update_all():
|
||||
# from core.support import dbg;dbg()
|
||||
from time import sleep
|
||||
logger.log()
|
||||
logger.info()
|
||||
sleep(20)
|
||||
while xbmc.Player().isPlaying():
|
||||
sleep(20)
|
||||
|
||||
+16
-16
@@ -73,8 +73,8 @@ otvdb_global = None
|
||||
|
||||
|
||||
def find_and_set_infoLabels(item):
|
||||
logger.log()
|
||||
# logger.log("item es %s" % item)
|
||||
logger.info()
|
||||
# logger.info("item es %s" % item)
|
||||
|
||||
p_dialog = None
|
||||
if not item.contentSeason:
|
||||
@@ -368,7 +368,7 @@ class Tvdb(object):
|
||||
|
||||
@classmethod
|
||||
def __check_token(cls):
|
||||
# logger.log()
|
||||
# logger.info()
|
||||
if TOKEN == "":
|
||||
cls.__login()
|
||||
else:
|
||||
@@ -383,7 +383,7 @@ class Tvdb(object):
|
||||
|
||||
@staticmethod
|
||||
def __login():
|
||||
# logger.log()
|
||||
# logger.info()
|
||||
global TOKEN
|
||||
|
||||
apikey = "106B699FDC04301C"
|
||||
@@ -413,7 +413,7 @@ class Tvdb(object):
|
||||
|
||||
@classmethod
|
||||
def __refresh_token(cls):
|
||||
# logger.log()
|
||||
# logger.info()
|
||||
global TOKEN
|
||||
is_success = False
|
||||
|
||||
@@ -512,7 +512,7 @@ class Tvdb(object):
|
||||
]
|
||||
}
|
||||
"""
|
||||
logger.log()
|
||||
logger.info()
|
||||
if id_episode and self.episodes.get(id_episode):
|
||||
return self.episodes.get(id_episode)
|
||||
|
||||
@@ -582,7 +582,7 @@ class Tvdb(object):
|
||||
}
|
||||
}
|
||||
"""
|
||||
logger.log()
|
||||
logger.info()
|
||||
|
||||
try:
|
||||
url = HOST + "/series/%s/episodes?page=%s" % (_id, page)
|
||||
@@ -600,7 +600,7 @@ class Tvdb(object):
|
||||
else:
|
||||
self.list_episodes[page] = jsontools.load(html)
|
||||
|
||||
# logger.log("dict_html %s" % self.list_episodes)
|
||||
# logger.info("dict_html %s" % self.list_episodes)
|
||||
|
||||
return self.list_episodes[page]
|
||||
|
||||
@@ -668,7 +668,7 @@ class Tvdb(object):
|
||||
"""
|
||||
if semaforo:
|
||||
semaforo.acquire()
|
||||
logger.log()
|
||||
logger.info()
|
||||
|
||||
url = HOST + "/episodes/%s" % _id
|
||||
|
||||
@@ -691,7 +691,7 @@ class Tvdb(object):
|
||||
dict_html = jsontools.load(html)
|
||||
dict_html = dict_html.pop("data")
|
||||
|
||||
logger.log("dict_html %s" % dict_html)
|
||||
logger.info("dict_html %s" % dict_html)
|
||||
self.episodes[_id] = dict_html
|
||||
|
||||
if semaforo:
|
||||
@@ -722,7 +722,7 @@ class Tvdb(object):
|
||||
"status": "string"
|
||||
}
|
||||
"""
|
||||
logger.log()
|
||||
logger.info()
|
||||
|
||||
try:
|
||||
|
||||
@@ -743,7 +743,7 @@ class Tvdb(object):
|
||||
req = urllib.request.Request(url, headers=DEFAULT_HEADERS)
|
||||
response = urllib.request.urlopen(req)
|
||||
html = response.read()
|
||||
logger.log(html)
|
||||
logger.info(html)
|
||||
response.close()
|
||||
|
||||
except Exception as ex:
|
||||
@@ -821,7 +821,7 @@ class Tvdb(object):
|
||||
}
|
||||
}
|
||||
"""
|
||||
logger.log()
|
||||
logger.info()
|
||||
resultado = {}
|
||||
|
||||
url = HOST + "/series/%s" % _id
|
||||
@@ -880,7 +880,7 @@ class Tvdb(object):
|
||||
@rtype: dict
|
||||
|
||||
"""
|
||||
logger.log()
|
||||
logger.info()
|
||||
|
||||
if self.result.get('image_season_%s' % season):
|
||||
return self.result['image_season_%s' % season]
|
||||
@@ -932,7 +932,7 @@ class Tvdb(object):
|
||||
@return: dictionary with actors
|
||||
@rtype: dict
|
||||
"""
|
||||
logger.log()
|
||||
logger.info()
|
||||
|
||||
url = HOST + "/series/%s/actors" % _id
|
||||
DEFAULT_HEADERS["Accept-Language"] = lang
|
||||
@@ -962,7 +962,7 @@ class Tvdb(object):
|
||||
@rtype: list
|
||||
@return: list of results
|
||||
"""
|
||||
logger.log()
|
||||
logger.info()
|
||||
list_results = []
|
||||
|
||||
# if we have a result and it has seriesName, we already have the info of the series, it is not necessary to search again
|
||||
|
||||
+28
-28
@@ -78,7 +78,7 @@ def save_movie(item, silent=False):
|
||||
@rtype fallidos: int
|
||||
@return: the number of failed items or -1 if all failed
|
||||
"""
|
||||
logger.log()
|
||||
logger.info()
|
||||
# logger.debug(item.tostring('\n'))
|
||||
insertados = 0
|
||||
sobreescritos = 0
|
||||
@@ -144,7 +144,7 @@ def save_movie(item, silent=False):
|
||||
if not path:
|
||||
# Create folder
|
||||
path = filetools.join(MOVIES_PATH, ("%s [%s]" % (base_name, _id)).strip())
|
||||
logger.log("Creating movie directory:" + path)
|
||||
logger.info("Creating movie directory:" + path)
|
||||
if not filetools.mkdir(path):
|
||||
logger.debug("Could not create directory")
|
||||
return 0, 0, -1, path
|
||||
@@ -159,7 +159,7 @@ def save_movie(item, silent=False):
|
||||
|
||||
if not nfo_exists:
|
||||
# We create .nfo if it doesn't exist
|
||||
logger.log("Creating .nfo: " + nfo_path)
|
||||
logger.info("Creating .nfo: " + nfo_path)
|
||||
head_nfo = scraper.get_nfo(item)
|
||||
|
||||
item_nfo = Item(title=item.contentTitle, channel="videolibrary", action='findvideos',
|
||||
@@ -182,7 +182,7 @@ def save_movie(item, silent=False):
|
||||
if item_nfo and strm_exists:
|
||||
|
||||
if json_exists:
|
||||
logger.log("The file exists. Is overwritten")
|
||||
logger.info("The file exists. Is overwritten")
|
||||
sobreescritos += 1
|
||||
else:
|
||||
insertados += 1
|
||||
@@ -209,7 +209,7 @@ def save_movie(item, silent=False):
|
||||
item_nfo.library_urls[item.channel] = item.url
|
||||
|
||||
if filetools.write(nfo_path, head_nfo + item_nfo.tojson()):
|
||||
#logger.log("FOLDER_MOVIES : %s" % FOLDER_MOVIES)
|
||||
#logger.info("FOLDER_MOVIES : %s" % FOLDER_MOVIES)
|
||||
# We update the Kodi video library with the movie
|
||||
if config.is_xbmc() and config.get_setting("videolibrary_kodi") and not silent:
|
||||
from platformcode import xbmc_videolibrary
|
||||
@@ -238,7 +238,7 @@ def update_renumber_options(item, head_nfo, path):
|
||||
json = json_file['TVSHOW_AUTORENUMBER']
|
||||
if item.fulltitle in json:
|
||||
item.channel_prefs[channel]['TVSHOW_AUTORENUMBER'] = json[item.fulltitle]
|
||||
logger.log('UPDATED=\n' + str(item.channel_prefs))
|
||||
logger.info('UPDATED=\n' + str(item.channel_prefs))
|
||||
filetools.write(tvshow_path, head_nfo + item.tojson())
|
||||
|
||||
def add_renumber_options(item, head_nfo, path):
|
||||
@@ -426,7 +426,7 @@ def save_tvshow(item, episodelist, silent=False):
|
||||
@rtype path: str
|
||||
@return: serial directory
|
||||
"""
|
||||
logger.log()
|
||||
logger.info()
|
||||
# logger.debug(item.tostring('\n'))
|
||||
path = ""
|
||||
|
||||
@@ -483,7 +483,7 @@ def save_tvshow(item, episodelist, silent=False):
|
||||
|
||||
if not path:
|
||||
path = filetools.join(TVSHOWS_PATH, ("%s [%s]" % (base_name, _id)).strip())
|
||||
logger.log("Creating series directory: " + path)
|
||||
logger.info("Creating series directory: " + path)
|
||||
try:
|
||||
filetools.mkdir(path)
|
||||
except OSError as exception:
|
||||
@@ -493,7 +493,7 @@ def save_tvshow(item, episodelist, silent=False):
|
||||
tvshow_path = filetools.join(path, "tvshow.nfo")
|
||||
if not filetools.exists(tvshow_path):
|
||||
# We create tvshow.nfo, if it does not exist, with the head_nfo, series info and watched episode marks
|
||||
logger.log("Creating tvshow.nfo: " + tvshow_path)
|
||||
logger.info("Creating tvshow.nfo: " + tvshow_path)
|
||||
head_nfo = scraper.get_nfo(item)
|
||||
item.infoLabels['mediatype'] = "tvshow"
|
||||
item.infoLabels['title'] = item.contentSerieName
|
||||
@@ -567,11 +567,11 @@ def save_episodes(path, episodelist, serie, silent=False, overwrite=True):
|
||||
@rtype fallidos: int
|
||||
@return: the number of failed episodes
|
||||
"""
|
||||
logger.log()
|
||||
logger.info()
|
||||
episodelist = filter_list(episodelist, serie.action, path)
|
||||
# No episode list, nothing to save
|
||||
if not len(episodelist):
|
||||
logger.log("There is no episode list, we go out without creating strm")
|
||||
logger.info("There is no episode list, we go out without creating strm")
|
||||
return 0, 0, 0
|
||||
|
||||
# process local episodes
|
||||
@@ -586,7 +586,7 @@ def save_episodes(path, episodelist, serie, silent=False, overwrite=True):
|
||||
elif config.get_setting("local_episodes", "videolibrary"):
|
||||
done, local_episodes_path = config_local_episodes_path(path, serie)
|
||||
if done < 0:
|
||||
logger.log("An issue has occurred while configuring local episodes, going out without creating strm")
|
||||
logger.info("An issue has occurred while configuring local episodes, going out without creating strm")
|
||||
return 0, 0, done
|
||||
item_nfo.local_episodes_path = local_episodes_path
|
||||
filetools.write(nfo_path, head_nfo + item_nfo.tojson())
|
||||
@@ -710,7 +710,7 @@ def save_episodes(path, episodelist, serie, silent=False, overwrite=True):
|
||||
|
||||
# No episode list, nothing to save
|
||||
if not len(new_episodelist):
|
||||
logger.log("There is no episode list, we go out without creating strm")
|
||||
logger.info("There is no episode list, we go out without creating strm")
|
||||
return 0, 0, 0
|
||||
|
||||
local_episodelist += get_local_content(path)
|
||||
@@ -742,12 +742,12 @@ def save_episodes(path, episodelist, serie, silent=False, overwrite=True):
|
||||
json_path = filetools.join(path, ("%s [%s].json" % (season_episode, e.channel)).lower())
|
||||
|
||||
if season_episode in local_episodelist:
|
||||
logger.log('Skipped: Serie ' + serie.contentSerieName + ' ' + season_episode + ' available as local content')
|
||||
logger.info('Skipped: Serie ' + serie.contentSerieName + ' ' + season_episode + ' available as local content')
|
||||
continue
|
||||
|
||||
# check if the episode has been downloaded
|
||||
if filetools.join(path, "%s [downloads].json" % season_episode) in ficheros:
|
||||
logger.log('INFO: "%s" episode %s has been downloaded, skipping it' % (serie.contentSerieName, season_episode))
|
||||
logger.info('INFO: "%s" episode %s has been downloaded, skipping it' % (serie.contentSerieName, season_episode))
|
||||
continue
|
||||
|
||||
strm_exists = strm_path in ficheros
|
||||
@@ -800,7 +800,7 @@ def save_episodes(path, episodelist, serie, silent=False, overwrite=True):
|
||||
|
||||
if filetools.write(json_path, e.tojson()):
|
||||
if not json_exists:
|
||||
logger.log("Inserted: %s" % json_path)
|
||||
logger.info("Inserted: %s" % json_path)
|
||||
insertados += 1
|
||||
# We mark episode as unseen
|
||||
news_in_playcounts[season_episode] = 0
|
||||
@@ -811,14 +811,14 @@ def save_episodes(path, episodelist, serie, silent=False, overwrite=True):
|
||||
news_in_playcounts[serie.contentSerieName] = 0
|
||||
|
||||
else:
|
||||
logger.log("Overwritten: %s" % json_path)
|
||||
logger.info("Overwritten: %s" % json_path)
|
||||
sobreescritos += 1
|
||||
else:
|
||||
logger.log("Failed: %s" % json_path)
|
||||
logger.info("Failed: %s" % json_path)
|
||||
fallidos += 1
|
||||
|
||||
else:
|
||||
logger.log("Failed: %s" % json_path)
|
||||
logger.info("Failed: %s" % json_path)
|
||||
fallidos += 1
|
||||
|
||||
if not silent and p_dialog.iscanceled():
|
||||
@@ -888,7 +888,7 @@ def save_episodes(path, episodelist, serie, silent=False, overwrite=True):
|
||||
|
||||
|
||||
def config_local_episodes_path(path, item, silent=False):
|
||||
logger.log(item)
|
||||
logger.info(item)
|
||||
from platformcode.xbmc_videolibrary import search_local_path
|
||||
local_episodes_path=search_local_path(item)
|
||||
if not local_episodes_path:
|
||||
@@ -900,11 +900,11 @@ def config_local_episodes_path(path, item, silent=False):
|
||||
platformtools.dialog_ok(config.get_localized_string(30131), config.get_localized_string(80043))
|
||||
local_episodes_path = platformtools.dialog_browse(0, config.get_localized_string(80046))
|
||||
if local_episodes_path == '':
|
||||
logger.log("User has canceled the dialog")
|
||||
logger.info("User has canceled the dialog")
|
||||
return -2, local_episodes_path
|
||||
elif path in local_episodes_path:
|
||||
platformtools.dialog_ok(config.get_localized_string(30131), config.get_localized_string(80045))
|
||||
logger.log("Selected folder is the same of the TV show one")
|
||||
logger.info("Selected folder is the same of the TV show one")
|
||||
return -2, local_episodes_path
|
||||
|
||||
if local_episodes_path:
|
||||
@@ -919,7 +919,7 @@ def config_local_episodes_path(path, item, silent=False):
|
||||
|
||||
|
||||
def process_local_episodes(local_episodes_path, path):
|
||||
logger.log()
|
||||
logger.info()
|
||||
|
||||
sub_extensions = ['.srt', '.sub', '.sbv', '.ass', '.idx', '.ssa', '.smi']
|
||||
artwork_extensions = ['.jpg', '.jpeg', '.png']
|
||||
@@ -958,7 +958,7 @@ def process_local_episodes(local_episodes_path, path):
|
||||
|
||||
|
||||
def get_local_content(path):
|
||||
logger.log()
|
||||
logger.info()
|
||||
|
||||
local_episodelist = []
|
||||
for root, folders, files in filetools.walk(path):
|
||||
@@ -987,7 +987,7 @@ def add_movie(item):
|
||||
@type item: item
|
||||
@param item: item to be saved.
|
||||
"""
|
||||
logger.log()
|
||||
logger.info()
|
||||
from platformcode.launcher import set_search_temp; set_search_temp(item)
|
||||
|
||||
# To disambiguate titles, TMDB is caused to ask for the really desired title
|
||||
@@ -1034,7 +1034,7 @@ def add_tvshow(item, channel=None):
|
||||
@param channel: channel from which the series will be saved. By default, item.from_channel or item.channel will be imported.
|
||||
|
||||
"""
|
||||
logger.log("show=#" + item.show + "#")
|
||||
logger.info("show=#" + item.show + "#")
|
||||
from platformcode.launcher import set_search_temp; set_search_temp(item)
|
||||
|
||||
if item.channel == "downloads":
|
||||
@@ -1105,7 +1105,7 @@ def add_tvshow(item, channel=None):
|
||||
|
||||
else:
|
||||
platformtools.dialog_ok(config.get_localized_string(30131), config.get_localized_string(60070) % item.show)
|
||||
logger.log("%s episodes of series %s have been added to the video library" % (insertados, item.show))
|
||||
logger.info("%s episodes of series %s have been added to the video library" % (insertados, item.show))
|
||||
if config.is_xbmc():
|
||||
if config.get_setting("sync_trakt_new_tvshow", "videolibrary"):
|
||||
import xbmc
|
||||
@@ -1121,7 +1121,7 @@ def add_tvshow(item, channel=None):
|
||||
|
||||
|
||||
def emergency_urls(item, channel=None, path=None, headers={}):
|
||||
logger.log()
|
||||
logger.info()
|
||||
import re
|
||||
from servers import torrent
|
||||
try:
|
||||
|
||||
+8
-8
@@ -17,8 +17,8 @@ from core import filetools
|
||||
|
||||
class ziptools(object):
|
||||
def extract(self, file, dir, folder_to_extract="", overwrite_question=False, backup=False):
|
||||
logger.log("file= %s" % file)
|
||||
logger.log("dir= %s" % dir)
|
||||
logger.info("file= %s" % file)
|
||||
logger.info("dir= %s" % dir)
|
||||
|
||||
if not dir.endswith(':') and not filetools.exists(dir):
|
||||
filetools.mkdir(dir)
|
||||
@@ -30,13 +30,13 @@ class ziptools(object):
|
||||
|
||||
for nameo in zf.namelist():
|
||||
name = nameo.replace(':', '_').replace('<', '_').replace('>', '_').replace('|', '_').replace('"', '_').replace('?', '_').replace('*', '_')
|
||||
logger.log("name=%s" % nameo)
|
||||
logger.info("name=%s" % nameo)
|
||||
if not name.endswith('/'):
|
||||
logger.log("it's not a directory")
|
||||
logger.info("it's not a directory")
|
||||
try:
|
||||
(path, filename) = filetools.split(filetools.join(dir, name))
|
||||
logger.log("path=%s" % path)
|
||||
logger.log("name=%s" % name)
|
||||
logger.info("path=%s" % path)
|
||||
logger.info("name=%s" % name)
|
||||
if folder_to_extract:
|
||||
if path != filetools.join(dir, folder_to_extract):
|
||||
break
|
||||
@@ -49,7 +49,7 @@ class ziptools(object):
|
||||
|
||||
else:
|
||||
outfilename = filetools.join(dir, name)
|
||||
logger.log("outfilename=%s" % outfilename)
|
||||
logger.info("outfilename=%s" % outfilename)
|
||||
try:
|
||||
if filetools.exists(outfilename) and overwrite_question:
|
||||
from platformcode import platformtools
|
||||
@@ -74,7 +74,7 @@ class ziptools(object):
|
||||
try:
|
||||
zf.close()
|
||||
except:
|
||||
logger.log("Error closing .zip " + file)
|
||||
logger.info("Error closing .zip " + file)
|
||||
|
||||
def _createstructure(self, file, dir):
|
||||
self._makedirs(self._listdirs(file), dir)
|
||||
|
||||
Reference in New Issue
Block a user