KoD 1.5
-Nuova Ricerca Globale\n-Nuova Rinumerazione\n-Messaggi di Errore più chiari\n-Fix var\n
This commit is contained in:
+2
-2
@@ -29,7 +29,7 @@ def start(itemlist, item):
|
||||
|
||||
if item.global_search:
|
||||
return itemlist
|
||||
logger.info()
|
||||
logger.debug()
|
||||
|
||||
global PLAYED
|
||||
PLAYED = False
|
||||
@@ -274,7 +274,7 @@ def start(itemlist, item):
|
||||
|
||||
|
||||
def play_multi_channel(item, itemlist):
|
||||
logger.info()
|
||||
logger.debug()
|
||||
start(itemlist, item)
|
||||
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ default_file = dict()
|
||||
remote_path = 'https://raw.githubusercontent.com/kodiondemand/media/master/'
|
||||
|
||||
def is_enabled(channel_name):
|
||||
logger.info("channel_name=" + channel_name)
|
||||
logger.debug("channel_name=" + channel_name)
|
||||
return get_channel_parameters(channel_name)["active"] and get_channel_setting("enabled", channel=channel_name,
|
||||
default=True)
|
||||
|
||||
@@ -27,7 +27,7 @@ def get_channel_parameters(channel_name):
|
||||
if channel_name not in dict_channels_parameters:
|
||||
try:
|
||||
channel_parameters = get_channel_json(channel_name)
|
||||
# logger.debug(channel_parameters)
|
||||
logger.debug(channel_parameters)
|
||||
if channel_parameters:
|
||||
# name and default changes
|
||||
channel_parameters["title"] = channel_parameters.pop("name") + (' [DEPRECATED]' if 'deprecated' in channel_parameters and channel_parameters['deprecated'] else '')
|
||||
@@ -87,7 +87,7 @@ def get_channel_parameters(channel_name):
|
||||
|
||||
|
||||
def get_channel_json(channel_name):
|
||||
# logger.info("channel_name=" + channel_name)
|
||||
logger.debug("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.info("channel_data=" + channel_path)
|
||||
logger.debug("channel_data=" + channel_path)
|
||||
channel_json = jsontools.load(filetools.read(channel_path))
|
||||
# logger.info("channel_json= %s" % channel_json)
|
||||
logger.debug("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.info("channel_name=" + channel_name)
|
||||
logger.debug("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.info(list_language)
|
||||
logger.debug(list_language)
|
||||
else:
|
||||
sub = False
|
||||
langs = []
|
||||
|
||||
+1
-1
@@ -253,7 +253,7 @@ class Downloader(object):
|
||||
self.file.seek(2 ** 31, 0)
|
||||
except OverflowError:
|
||||
self._seekable = False
|
||||
logger.info("Cannot do seek() or tell() in files larger than 2GB")
|
||||
logger.error("Cannot do seek() or tell() in files larger than 2GB")
|
||||
|
||||
self.__get_download_info__()
|
||||
|
||||
|
||||
+2
-3
@@ -8,7 +8,6 @@ from __future__ import division
|
||||
# from builtins import str
|
||||
import io
|
||||
|
||||
from future.builtins import range
|
||||
from past.utils import old_div
|
||||
import sys
|
||||
PY3 = False
|
||||
@@ -814,7 +813,7 @@ def remove_tags(title):
|
||||
@rtype: str
|
||||
@return: string without tags
|
||||
"""
|
||||
logger.info()
|
||||
logger.debug()
|
||||
|
||||
title_without_tags = scrapertools.find_single_match(title, r'\[color .+?\](.+)\[\/color\]')
|
||||
|
||||
@@ -832,7 +831,7 @@ def remove_smb_credential(path):
|
||||
@return: chain without credentials
|
||||
@rtype: str
|
||||
"""
|
||||
logger.info()
|
||||
logger.debug()
|
||||
|
||||
if not scrapertools.find_single_match(path, r'(^\w+:\/\/)'):
|
||||
return path
|
||||
|
||||
+13
-13
@@ -234,7 +234,7 @@ def get_link(list_item, item, list_language, list_quality=None, global_filter_la
|
||||
@return: Item list
|
||||
@rtype: list[Item]
|
||||
"""
|
||||
logger.info()
|
||||
logger.debug()
|
||||
|
||||
# if the required fields are None we leave
|
||||
if list_item is None or item is None:
|
||||
@@ -274,7 +274,7 @@ def get_links(list_item, item, list_language, list_quality=None, global_filter_l
|
||||
@return: lista de Item
|
||||
@rtype: list[Item]
|
||||
"""
|
||||
logger.info()
|
||||
logger.debug()
|
||||
|
||||
|
||||
# if the required fields are None we leave
|
||||
@@ -362,7 +362,7 @@ def no_filter(item):
|
||||
@return: lista de enlaces
|
||||
@rtype: list[Item]
|
||||
"""
|
||||
logger.info()
|
||||
logger.debug()
|
||||
|
||||
itemlist = []
|
||||
for i in item.list_item_all:
|
||||
@@ -384,7 +384,7 @@ def mainlist(channel, list_language, list_quality):
|
||||
@return: Item list
|
||||
@rtype: list[Item]
|
||||
"""
|
||||
logger.info()
|
||||
logger.debug()
|
||||
itemlist = []
|
||||
dict_series = jsontools.get_node_from_file(channel, TAG_TVSHOW_FILTER)
|
||||
|
||||
@@ -425,8 +425,8 @@ def config_item(item):
|
||||
@param item: item
|
||||
@type item: Item
|
||||
"""
|
||||
logger.info()
|
||||
logger.info("item %s" % item.tostring())
|
||||
logger.debug()
|
||||
logger.debug("item %s" % item.tostring())
|
||||
|
||||
# WE GET THE JSON DATA
|
||||
dict_series = jsontools.get_node_from_file(item.from_channel, TAG_TVSHOW_FILTER)
|
||||
@@ -448,8 +448,8 @@ def config_item(item):
|
||||
else:
|
||||
lang_selected = dict_series.get(tvshow, {}).get(TAG_LANGUAGE, default_lang)
|
||||
list_quality = dict_series.get(tvshow, {}).get(TAG_QUALITY_ALLOWED, [x.lower() for x in item.list_quality])
|
||||
# logger.info("lang selected {}".format(lang_selected))
|
||||
# logger.info("list quality {}".format(list_quality))
|
||||
# logger.debug("lang selected {}".format(lang_selected))
|
||||
# logger.debug("list quality {}".format(list_quality))
|
||||
|
||||
active = True
|
||||
custom_button = {'visible': False}
|
||||
@@ -516,7 +516,7 @@ def config_item(item):
|
||||
|
||||
|
||||
def delete(item, dict_values):
|
||||
logger.info()
|
||||
logger.debug()
|
||||
|
||||
if item:
|
||||
dict_series = jsontools.get_node_from_file(item.from_channel, TAG_TVSHOW_FILTER)
|
||||
@@ -554,7 +554,7 @@ def save(item, dict_data_saved):
|
||||
@param dict_data_saved: dictionary with saved data
|
||||
@type dict_data_saved: dict
|
||||
"""
|
||||
logger.info()
|
||||
logger.debug()
|
||||
|
||||
if item and dict_data_saved:
|
||||
logger.debug('item: %s\ndatos: %s' % (item.tostring(), dict_data_saved))
|
||||
@@ -564,7 +564,7 @@ def save(item, dict_data_saved):
|
||||
dict_series = jsontools.get_node_from_file(item.from_channel, TAG_TVSHOW_FILTER)
|
||||
tvshow = item.show.strip().lower()
|
||||
|
||||
logger.info("Data is updated")
|
||||
logger.debug("Data is updated")
|
||||
|
||||
list_quality = []
|
||||
for _id, value in list(dict_data_saved.items()):
|
||||
@@ -599,7 +599,7 @@ def save_from_context(item):
|
||||
@param item: item
|
||||
@type item: item
|
||||
"""
|
||||
logger.info()
|
||||
logger.debug()
|
||||
|
||||
dict_series = jsontools.get_node_from_file(item.from_channel, TAG_TVSHOW_FILTER)
|
||||
tvshow = item.show.strip().lower()
|
||||
@@ -630,7 +630,7 @@ def delete_from_context(item):
|
||||
@param item: item
|
||||
@type item: item
|
||||
"""
|
||||
logger.info()
|
||||
logger.debug()
|
||||
|
||||
# We come from get_links and no result has been obtained, in context menu and we delete
|
||||
if item.to_channel != "":
|
||||
|
||||
+1
-1
@@ -449,7 +449,7 @@ def downloadpage(url, **opt):
|
||||
|
||||
if not 'api.themoviedb' in url and not opt.get('alfa_s', False):
|
||||
show_infobox(info_dict)
|
||||
|
||||
if not config.get_setting("debug"): logger.info('Page URL:',url)
|
||||
return type('HTTPResponse', (), response)
|
||||
|
||||
def fill_fields_pre(url, opt, proxy_data, file_name):
|
||||
|
||||
+4
-4
@@ -11,22 +11,22 @@ from inspect import stack
|
||||
try:
|
||||
import json
|
||||
except:
|
||||
logger.info("json included in the interpreter **NOT** available")
|
||||
logger.error("json included in the interpreter **NOT** available")
|
||||
|
||||
try:
|
||||
import simplejson as json
|
||||
except:
|
||||
logger.info("simplejson included in the interpreter **NOT** available")
|
||||
logger.error("simplejson included in the interpreter **NOT** available")
|
||||
try:
|
||||
from lib import simplejson as json
|
||||
except:
|
||||
logger.info("simplejson in lib directory **NOT** available")
|
||||
logger.error("simplejson in lib directory **NOT** available")
|
||||
logger.error("A valid JSON parser was not found")
|
||||
json = None
|
||||
else:
|
||||
logger.info("Using simplejson in the lib directory")
|
||||
else:
|
||||
logger.info("Using simplejson included in the interpreter")
|
||||
logger.error("Using simplejson included in the interpreter")
|
||||
# ~ else:
|
||||
# ~ logger.info("Usando json incluido en el interprete")
|
||||
|
||||
|
||||
+8
-46
@@ -21,6 +21,7 @@ def find_and_set_infoLabels(item):
|
||||
:param item:
|
||||
:return: Boolean indicating if the 'code' could be found
|
||||
"""
|
||||
# from core.support import dbg;dbg()
|
||||
global scraper
|
||||
scraper = None
|
||||
# logger.debug("item:\n" + item.tostring('\n'))
|
||||
@@ -32,7 +33,7 @@ def find_and_set_infoLabels(item):
|
||||
# Get the default Scraper of the configuration according to the content type
|
||||
if item.contentType == "movie":
|
||||
scraper_actual = ['tmdb'][config.get_setting("scraper_movies", "videolibrary")]
|
||||
tipo_contenido = config.get_localized_string(70283)
|
||||
tipo_contenido = "movie"
|
||||
title = item.contentTitle
|
||||
# Complete list of options for this type of content
|
||||
list_opciones_cuadro.append(scrapers_disponibles['tmdb'])
|
||||
@@ -61,7 +62,7 @@ def find_and_set_infoLabels(item):
|
||||
# Check if there is a 'code'
|
||||
if scraper_result and item.infoLabels['code']:
|
||||
# correct code
|
||||
logger.info("Identificador encontrado: %s" % item.infoLabels['code'])
|
||||
logger.debug("Identificador encontrado: %s" % item.infoLabels['code'])
|
||||
scraper.completar_codigos(item)
|
||||
return True
|
||||
elif scraper_result:
|
||||
@@ -71,57 +72,18 @@ def find_and_set_infoLabels(item):
|
||||
# Content not found
|
||||
msg = config.get_localized_string(60228) % title
|
||||
|
||||
logger.info(msg)
|
||||
logger.debug(msg)
|
||||
# Show box with other options:
|
||||
if scrapers_disponibles[scraper_actual] in list_opciones_cuadro:
|
||||
list_opciones_cuadro.remove(scrapers_disponibles[scraper_actual])
|
||||
index = platformtools.dialog_select(msg, list_opciones_cuadro)
|
||||
|
||||
if index < 0:
|
||||
item = platformtools.dialog_info(item, scraper_actual)
|
||||
if item.exit:
|
||||
logger.debug("You have clicked 'cancel' in the window '%s'" % msg)
|
||||
return False
|
||||
|
||||
elif index == 0:
|
||||
# Ask the title
|
||||
title = platformtools.dialog_input(title, config.get_localized_string(60229) % tipo_contenido)
|
||||
if title:
|
||||
if item.contentType == "movie":
|
||||
item.contentTitle = title
|
||||
else:
|
||||
item.contentSerieName = title
|
||||
else:
|
||||
logger.debug("I clicked 'cancel' in the window 'Enter the correct name'")
|
||||
return False
|
||||
|
||||
elif index == 1:
|
||||
# You have to create a dialog box to enter the data
|
||||
logger.info("Complete information")
|
||||
if cuadro_completar(item):
|
||||
# correct code
|
||||
logger.info("Identifier found: %s" % str(item.infoLabels['code']))
|
||||
return True
|
||||
# raise
|
||||
|
||||
elif list_opciones_cuadro[index] in list(scrapers_disponibles.values()):
|
||||
# Get the name of the scraper module
|
||||
for k, v in list(scrapers_disponibles.items()):
|
||||
if list_opciones_cuadro[index] == v:
|
||||
if scrapers_disponibles[scraper_actual] not in list_opciones_cuadro:
|
||||
list_opciones_cuadro.append(scrapers_disponibles[scraper_actual])
|
||||
# We import the scraper k
|
||||
scraper_actual = k
|
||||
try:
|
||||
scraper = None
|
||||
scraper = __import__('core.%s' % scraper_actual, fromlist=["core.%s" % scraper_actual])
|
||||
except ImportError:
|
||||
exec("import core." + scraper_actual + " as scraper_module")
|
||||
break
|
||||
|
||||
logger.error("Error importing the scraper module %s" % scraper_actual)
|
||||
|
||||
|
||||
def cuadro_completar(item):
|
||||
logger.info()
|
||||
logger.debug()
|
||||
|
||||
global dict_default
|
||||
dict_default = {}
|
||||
@@ -234,7 +196,7 @@ def get_nfo(item):
|
||||
@rtype: str
|
||||
@return:
|
||||
"""
|
||||
logger.info()
|
||||
logger.debug()
|
||||
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.info("%d %s" % (i, match))
|
||||
logger.debug("%d %s" % (i, match))
|
||||
i = i + 1
|
||||
|
||||
|
||||
@@ -447,7 +447,7 @@ def get_season_and_episode(title):
|
||||
except:
|
||||
pass
|
||||
|
||||
logger.info("'" + title + "' -> '" + filename + "'")
|
||||
logger.debug("'" + title + "' -> '" + filename + "'")
|
||||
|
||||
return filename
|
||||
|
||||
|
||||
+22
-19
@@ -47,7 +47,7 @@ def find_video_items(item=None, data=None):
|
||||
@return: returns the itemlist with the results
|
||||
@rtype: list
|
||||
"""
|
||||
logger.info()
|
||||
logger.debug()
|
||||
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.info(pattern["pattern"])
|
||||
logger.debug(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.info()
|
||||
logger.debug()
|
||||
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.info(msg)
|
||||
logger.debug(msg)
|
||||
|
||||
return devuelve
|
||||
|
||||
@@ -193,7 +193,7 @@ def guess_server_thumbnail(serverid):
|
||||
|
||||
|
||||
def get_server_from_url(url):
|
||||
logger.info()
|
||||
logger.debug()
|
||||
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.info('compiled ' + serverid)
|
||||
# logger.debug('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.info(msg)
|
||||
logger.debug(msg)
|
||||
return value
|
||||
|
||||
return None
|
||||
@@ -353,7 +353,7 @@ def resolve_video_urls_for_playing(server, url, video_password="", muestra_dialo
|
||||
video_urls.extend(response)
|
||||
except:
|
||||
logger.error("Error getting url in free mode")
|
||||
error_messages.append(config.get_localized_string(60006) % server_name)
|
||||
error_messages.append(config.get_localized_string(60014))
|
||||
import traceback
|
||||
logger.error(traceback.format_exc())
|
||||
|
||||
@@ -370,10 +370,10 @@ def resolve_video_urls_for_playing(server, url, video_password="", muestra_dialo
|
||||
elif response and response[0][0]:
|
||||
error_messages.append(response[0][0])
|
||||
else:
|
||||
error_messages.append(config.get_localized_string(60006) % server_name)
|
||||
error_messages.append(config.get_localized_string(60014))
|
||||
except:
|
||||
logger.error("Server errorr: %s" % opcion)
|
||||
error_messages.append(config.get_localized_string(60006) % server_name)
|
||||
error_messages.append(config.get_localized_string(60014))
|
||||
import traceback
|
||||
logger.error(traceback.format_exc())
|
||||
|
||||
@@ -394,7 +394,7 @@ def resolve_video_urls_for_playing(server, url, video_password="", muestra_dialo
|
||||
|
||||
# If we do not have urls or error messages, we put a generic one
|
||||
elif not video_urls and not error_messages:
|
||||
error_messages.append(config.get_localized_string(60006) % get_server_parameters(server)["name"])
|
||||
error_messages.append(config.get_localized_string(60014))
|
||||
|
||||
return video_urls, len(video_urls) > 0, "<br/>".join(error_messages)
|
||||
|
||||
@@ -478,6 +478,7 @@ def get_server_parameters(server):
|
||||
|
||||
if server not in dict_servers_parameters:
|
||||
try:
|
||||
path = ''
|
||||
# Servers
|
||||
if filetools.isfile(filetools.join(config.get_runtime_path(), "servers", server + ".json")):
|
||||
path = filetools.join(config.get_runtime_path(), "servers", server + ".json")
|
||||
@@ -489,6 +490,8 @@ def get_server_parameters(server):
|
||||
# When the server is not well defined in the channel (there is no connector), it shows an error because there is no "path" and the channel has to be checked
|
||||
dict_server = jsontools.load(filetools.read(path))
|
||||
|
||||
dict_server["name"] = translate_server_name(dict_server["name"])
|
||||
|
||||
# Images: url and local files are allowed inside "resources / images"
|
||||
if dict_server.get("thumbnail") and "://" not in dict_server["thumbnail"]:
|
||||
dict_server["thumbnail"] = filetools.join(config.get_runtime_path(), "resources", "media",
|
||||
@@ -614,7 +617,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.info("ERROR saving file: %s" % file_settings)
|
||||
logger.error("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 +639,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.info("ERROR when reading the file: %s" % file_settings)
|
||||
logger.error("ERROR when reading the file: %s" % file_settings)
|
||||
|
||||
dict_settings[name] = value
|
||||
|
||||
@@ -648,7 +651,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.info("ERROR saving file: %s" % file_settings)
|
||||
logger.error("ERROR saving file: %s" % file_settings)
|
||||
return None
|
||||
|
||||
return value
|
||||
@@ -750,7 +753,7 @@ def check_video_link(item, timeout=3):
|
||||
server_module = __import__('servers.%s' % server, None, None, ["servers.%s" % server])
|
||||
except:
|
||||
server_module = None
|
||||
logger.info("[check_video_link] Cannot import server! %s" % server)
|
||||
logger.error("[check_video_link] Cannot import server! %s" % server)
|
||||
return item, NK
|
||||
|
||||
if hasattr(server_module, 'test_video_exists'):
|
||||
@@ -760,20 +763,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.info("[check_video_link] Does not exist! %s %s %s" % (message, server, url))
|
||||
logger.error("[check_video_link] Does not exist! %s %s %s" % (message, server, url))
|
||||
resultado = KO
|
||||
else:
|
||||
logger.info("[check_video_link] check ok %s %s" % (server, url))
|
||||
logger.debug("[check_video_link] check ok %s %s" % (server, url))
|
||||
resultado = OK
|
||||
except:
|
||||
logger.info("[check_video_link] Can't check now! %s %s" % (server, url))
|
||||
logger.error("[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.info("[check_video_link] There is no test_video_exists for server: %s" % server)
|
||||
logger.debug("[check_video_link] There is no test_video_exists for server: %s" % server)
|
||||
return item, NK
|
||||
|
||||
def translate_server_name(name):
|
||||
|
||||
+170
-196
@@ -17,7 +17,7 @@ else:
|
||||
from urllib import urlencode
|
||||
|
||||
from time import time
|
||||
from core import httptools, scrapertools, servertools, tmdb, channeltools, autoplay
|
||||
from core import httptools, scrapertools, servertools, tmdb, channeltools, autoplay, scraper
|
||||
from core.item import Item
|
||||
from lib import unshortenit
|
||||
from platformcode import config
|
||||
@@ -33,7 +33,7 @@ def hdpass_get_servers(item):
|
||||
|
||||
for mir_url, srv in scrapertools.find_multiple_matches(mir, patron_option):
|
||||
mir_url = scrapertools.decodeHtmlentities(mir_url)
|
||||
info(mir_url)
|
||||
logger.debug(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)
|
||||
@@ -143,12 +143,16 @@ def scrapeLang(scraped, lang, longtitle):
|
||||
if language: longtitle += typo(language, '_ [] color kod')
|
||||
return language, longtitle
|
||||
|
||||
|
||||
def cleantitle(title):
|
||||
if type(title) != str: title.decode('UTF-8')
|
||||
title = scrapertools.decodeHtmlentities(title)
|
||||
cleantitle = title.replace('"', "'").replace('×', 'x').replace('–', '-').strip()
|
||||
cleantitle = ''
|
||||
if title:
|
||||
if type(title) != str: title.decode('UTF-8')
|
||||
title = scrapertools.decodeHtmlentities(title)
|
||||
cleantitle = title.replace('"', "'").replace('×', 'x').replace('–', '-').strip()
|
||||
return cleantitle
|
||||
|
||||
|
||||
def unifyEp(ep):
|
||||
# ep = re.sub(r'\s-\s|-|–|×|×', 'x', scraped['episode'])
|
||||
ep = ep.replace('-', 'x')
|
||||
@@ -157,7 +161,8 @@ def unifyEp(ep):
|
||||
ep = ep.replace('×', 'x')
|
||||
return ep
|
||||
|
||||
def scrapeBlock(item, args, block, patron, headers, action, pagination, debug, typeContentDict, typeActionDict, blacklist, search, pag, function, lang, sceneTitle):
|
||||
|
||||
def scrapeBlock(item, args, block, patron, headers, action, pagination, debug, typeContentDict, typeActionDict, blacklist, search, pag, function, lang, sceneTitle, group):
|
||||
itemlist = []
|
||||
if debug:
|
||||
regexDbg(item, patron, headers, block)
|
||||
@@ -184,6 +189,8 @@ def scrapeBlock(item, args, block, patron, headers, action, pagination, debug, t
|
||||
# AVVERTENZE: Se il titolo è trovato nella ricerca TMDB/TVDB/Altro allora le locandine e altre info non saranno quelle recuperate nel sito.!!!!
|
||||
|
||||
stagione = '' # per quei siti che hanno la stagione nel blocco ma non nelle puntate
|
||||
contents = []
|
||||
|
||||
for i, match in enumerate(matches):
|
||||
if pagination and (pag - 1) * pagination > i and not search: continue # pagination
|
||||
if pagination and i >= pag * pagination and not search: break # pagination
|
||||
@@ -207,45 +214,52 @@ def scrapeBlock(item, args, block, patron, headers, action, pagination, debug, t
|
||||
val = domain + val
|
||||
scraped[kk] = val.strip() if type(val) == str else val
|
||||
|
||||
if scraped['season']:
|
||||
stagione = scraped['season']
|
||||
ep = unifyEp(scraped['episode'])
|
||||
if 'x' in ep:
|
||||
episode = ep.split('x')[0].strip()
|
||||
second_episode = ep.split('x')[1].strip()
|
||||
episode = ''
|
||||
if not group or item.grouped:
|
||||
if scraped['season'] and scraped['episode']:
|
||||
stagione = scraped['season']
|
||||
ep = unifyEp(scraped['episode'])
|
||||
if 'x' in ep:
|
||||
episode = ep.split('x')[0].strip()
|
||||
second_episode = ep.split('x')[1].strip()
|
||||
else:
|
||||
episode = ep
|
||||
second_episode = ''
|
||||
item.infoLabels['season'] = int(scraped['season'])
|
||||
item.infoLabels['episode'] = int(episode)
|
||||
episode = str(int(scraped['season'])) +'x'+ str(int(episode)).zfill(2) + ('x' + str(int(second_episode)).zfill(2) if second_episode else '')
|
||||
elif item.season:
|
||||
item.infoLabels['season'] = int(item.season)
|
||||
item.infoLabels['episode'] = int(scrapertools.find_single_match(scraped['episode'], r'(\d+)'))
|
||||
episode = item.season +'x'+ scraped['episode']
|
||||
elif item.contentType == 'tvshow' and (scraped['episode'] == '' and scraped['season'] == '' and stagione == ''):
|
||||
item.news = 'season_completed'
|
||||
episode = ''
|
||||
else:
|
||||
episode = ep
|
||||
second_episode = ''
|
||||
item.infoLabels['season'] = int(scraped['season'])
|
||||
item.infoLabels['episode'] = int(episode)
|
||||
episode = str(int(scraped['season'])) +'x'+ str(int(episode)).zfill(2) + ('x' + str(int(second_episode)).zfill(2) if second_episode else '')
|
||||
elif item.season:
|
||||
item.infoLabels['season'] = int(item.season)
|
||||
item.infoLabels['episode'] = int(scrapertools.find_single_match(scraped['episode'], r'(\d+)'))
|
||||
episode = item.season +'x'+ scraped['episode']
|
||||
elif item.contentType == 'tvshow' and (scraped['episode'] == '' and scraped['season'] == '' and stagione == ''):
|
||||
item.news = 'season_completed'
|
||||
episode = ''
|
||||
else:
|
||||
episode = unifyEp(scraped['episode']) if scraped['episode'] else ''
|
||||
try:
|
||||
if 'x' in episode:
|
||||
ep = episode.split('x')
|
||||
episode = str(int(ep[0])).zfill(1) + 'x' + str(int(ep[1])).zfill(2)
|
||||
item.infoLabels['season'] = int(ep[0])
|
||||
item.infoLabels['episode'] = int(ep[1])
|
||||
second_episode = scrapertools.find_single_match(episode, r'x\d+x(\d+)')
|
||||
if second_episode: episode = re.sub(r'(\d+x\d+)x\d+',r'\1-', episode) + second_episode.zfill(2)
|
||||
except:
|
||||
logger.debug('invalid episode: ' + episode)
|
||||
pass
|
||||
episode = unifyEp(scraped['episode']) if scraped['episode'] else ''
|
||||
try:
|
||||
if 'x' in episode:
|
||||
ep = episode.split('x')
|
||||
episode = str(int(ep[0])).zfill(1) + 'x' + str(int(ep[1])).zfill(2)
|
||||
item.infoLabels['season'] = int(ep[0])
|
||||
item.infoLabels['episode'] = int(ep[1])
|
||||
second_episode = scrapertools.find_single_match(episode, r'x\d+x(\d+)')
|
||||
if second_episode: episode = re.sub(r'(\d+x\d+)x\d+',r'\1-', episode) + second_episode.zfill(2)
|
||||
except:
|
||||
logger.debug('invalid episode: ' + episode)
|
||||
pass
|
||||
|
||||
#episode = re.sub(r'\s-\s|-|x|–|×', 'x', scraped['episode']) if scraped['episode'] else ''
|
||||
title = cleantitle(scraped['title']) if scraped['title'] else ''
|
||||
title2 = cleantitle(scraped['title2']) if scraped['title2'] else ''
|
||||
quality = scraped['quality'].strip() if scraped['quality'] else ''
|
||||
Type = scraped['type'] if scraped['type'] else ''
|
||||
plot = cleantitle(scraped["plot"]) if scraped["plot"] else ''
|
||||
title = cleantitle(scraped.get('title', ''))
|
||||
if group and scraped.get('title', '') in contents and not item.grouped: # same title and grouping enabled
|
||||
continue
|
||||
if item.grouped and scraped.get('title', '') != item.fulltitle: # inside a group different tvshow should not be included
|
||||
continue
|
||||
contents.append(title)
|
||||
title2 = cleantitle(scraped.get('title2', '')) if not group or item.grouped else ''
|
||||
quality = scraped.get('quality', '')
|
||||
# Type = scraped['type'] if scraped['type'] else ''
|
||||
plot = cleantitle(scraped.get("plot", ''))
|
||||
|
||||
# if title is set, probably this is a list of episodes or video sources
|
||||
# necessaria l'aggiunta di == scraped["title"] altrimenti non prende i gruppi dopo le categorie
|
||||
@@ -339,7 +353,8 @@ def scrapeBlock(item, args, block, patron, headers, action, pagination, debug, t
|
||||
AC = name
|
||||
break
|
||||
else: AC = action
|
||||
if (scraped["title"] not in blacklist) and (search.lower() in longtitle.lower()):
|
||||
|
||||
if (not scraped['title'] or scraped["title"] not in blacklist) and (search.lower() in longtitle.lower()):
|
||||
contentType = 'episode' if function == 'episodios' else CT if CT else item.contentType
|
||||
it = Item(
|
||||
channel=item.channel,
|
||||
@@ -349,17 +364,20 @@ def scrapeBlock(item, args, block, patron, headers, action, pagination, debug, t
|
||||
fulltitle=item.fulltitle if function == 'episodios' else title,
|
||||
show=item.show if function == 'episodios' else title,
|
||||
quality=quality,
|
||||
url=scraped["url"],
|
||||
url=scraped["url"] if scraped["url"] else item.url,
|
||||
infoLabels=infolabels,
|
||||
thumbnail=item.thumbnail if not scraped["thumb"] else scraped["thumb"],
|
||||
thumbnail=item.prevthumb if item.prevthumb else item.thumbnail if not scraped["thumb"] else scraped["thumb"],
|
||||
args=item.args,
|
||||
contentSerieName= title if 'movie' not in [contentType] and function != 'episodios' else item.contentSerieName,
|
||||
contentTitle= title if 'movie' in [contentType] and function == 'peliculas' else item.contentTitle,
|
||||
contentLanguage = lang1,
|
||||
contentEpisodeNumber=episode if episode else '',
|
||||
news= item.news if item.news else '',
|
||||
other = scraped['other'] if scraped['other'] else ''
|
||||
other = scraped['other'] if scraped['other'] else '',
|
||||
grouped=group
|
||||
)
|
||||
if scraped['episode'] and group and not item.grouped: # some adjustment for grouping feature
|
||||
it.action = function
|
||||
|
||||
# for lg in list(set(listGroups).difference(known_keys)):
|
||||
# it.__setattr__(lg, match[listGroups.index(lg)])
|
||||
@@ -367,38 +385,24 @@ def scrapeBlock(item, args, block, patron, headers, action, pagination, debug, t
|
||||
it.__setattr__(lg, match[lg])
|
||||
|
||||
if 'itemHook' in args:
|
||||
it = args['itemHook'](it)
|
||||
try:
|
||||
it = args['itemHook'](it)
|
||||
except:
|
||||
raise logger.ChannelScraperException
|
||||
itemlist.append(it)
|
||||
|
||||
return itemlist, matches
|
||||
|
||||
|
||||
def scrape(func):
|
||||
# args is a dict containing the foolowing keys:
|
||||
# patron: the patron to use for scraping page, all capturing group must match with listGroups
|
||||
# listGroups: a list containing the scraping info obtained by your patron, in order
|
||||
# accepted values are: url, title, thumb, quality, year, plot, duration, genre, rating, episode, lang
|
||||
def html_uniform(data):
|
||||
"""
|
||||
replace all ' with " and eliminate newline, so we don't need to worry about
|
||||
"""
|
||||
return re.sub("='([^']+)'", '="\\1"', data.replace('\n', ' ').replace('\t', ' ').replace(' ', ' '))
|
||||
|
||||
# headers: values to pass to request header
|
||||
# blacklist: titles that you want to exclude(service articles for example)
|
||||
# data: if you want to pass data manually, maybe because you need some custom replacement
|
||||
# patronBlock: patron to get parts of the page (to scrape with patron attribute),
|
||||
# if you need a "block inside another block" you can create a list, please note that all matches
|
||||
# will be packed as string
|
||||
# patronNext: patron for scraping next page link
|
||||
# action: if you want results perform an action different from "findvideos", useful when scraping film by genres
|
||||
# addVideolibrary: if "add to videolibrary" should appear
|
||||
# example usage:
|
||||
# import support
|
||||
# itemlist = []
|
||||
# patron = 'blablabla'
|
||||
# headers = [['Referer', host]]
|
||||
# blacklist = 'Request a TV serie!'
|
||||
# return support.scrape(item, itemlist, patron, ['thumb', 'quality', 'url', 'title', 'year', 'plot', 'episode', 'lang'],
|
||||
# headers=headers, blacklist=blacklist)
|
||||
# 'type' is a check for typologies of content e.g. Film or TV Series
|
||||
# 'episode' is a key to grab episode numbers if it is separated from the title
|
||||
# IMPORTANT 'type' is a special key, to work need typeContentDict={} and typeActionDict={}
|
||||
|
||||
def scrape(func):
|
||||
"""https://github.com/kodiondemand/addon/wiki/decoratori#scrape"""
|
||||
|
||||
def wrapper(*args):
|
||||
itemlist = []
|
||||
@@ -406,33 +410,34 @@ def scrape(func):
|
||||
args = func(*args)
|
||||
function = func.__name__ if not 'actLike' in args else args['actLike']
|
||||
# info('STACK= ',inspect.stack()[1][3])
|
||||
|
||||
item = args['item']
|
||||
|
||||
action = args['action'] if 'action' in args else 'findvideos'
|
||||
anime = args['anime'] if 'anime' in args else ''
|
||||
addVideolibrary = args['addVideolibrary'] if 'addVideolibrary' in args else True
|
||||
search = args['search'] if 'search' in args else ''
|
||||
blacklist = args['blacklist'] if 'blacklist' in args else []
|
||||
data = args['data'] if 'data' in args else ''
|
||||
patron = args['patron'] if 'patron' in args else args['patronMenu'] if 'patronMenu' in args else ''
|
||||
action = args.get('action', 'findvideos')
|
||||
anime = args.get('anime', '')
|
||||
addVideolibrary = args.get('addVideolibrary', True)
|
||||
search = args.get('search', '')
|
||||
blacklist = args.get('blacklist', [])
|
||||
data = args.get('data', '')
|
||||
patron = args.get('patron', args.get('patronMenu', ''))
|
||||
if 'headers' in args:
|
||||
headers = args['headers']
|
||||
elif 'headers' in func.__globals__:
|
||||
headers = func.__globals__['headers']
|
||||
else:
|
||||
headers = ''
|
||||
patronNext = args['patronNext'] if 'patronNext' in args else ''
|
||||
patronBlock = args['patronBlock'] if 'patronBlock' in args else ''
|
||||
typeActionDict = args['typeActionDict'] if 'typeActionDict' in args else {}
|
||||
typeContentDict = args['typeContentDict'] if 'typeContentDict' in args else {}
|
||||
debug = args['debug'] if 'debug' in args else False
|
||||
debugBlock = args['debugBlock'] if 'debugBlock' in args else False
|
||||
disabletmdb = args['disabletmdb'] if 'disabletmdb' in args else False
|
||||
patronNext = args.get('patronNext', '')
|
||||
patronBlock = args.get('patronBlock', '')
|
||||
typeActionDict = args.get('typeActionDict', {})
|
||||
typeContentDict = args.get('typeContentDict', {})
|
||||
debug = args.get('debug', False)
|
||||
debugBlock = args.get('debugBlock', False)
|
||||
disabletmdb = args.get('disabletmdb', False)
|
||||
if 'pagination' in args and inspect.stack()[1][3] not in ['add_tvshow', 'get_episodes', 'update', 'find_episodes']: pagination = args['pagination'] if args['pagination'] else 20
|
||||
else: pagination = ''
|
||||
lang = args['deflang'] if 'deflang' in args else ''
|
||||
lang = args.get('deflang', '')
|
||||
sceneTitle = args.get('sceneTitle')
|
||||
group = args.get('group', False)
|
||||
downloadEnabled = args.get('downloadEnabled', True)
|
||||
pag = item.page if item.page else 1 # pagination
|
||||
matches = []
|
||||
|
||||
@@ -440,24 +445,19 @@ def scrape(func):
|
||||
logger.debug('PATRON= ', patron)
|
||||
if not data:
|
||||
page = httptools.downloadpage(item.url, headers=headers, ignore_response_code=True)
|
||||
data = re.sub("='([^']+)'", '="\\1"', page.data)
|
||||
data = data.replace('\n', ' ')
|
||||
data = data.replace('\t', ' ')
|
||||
data = data.replace(' ', ' ')
|
||||
data = re.sub(r'>\s{2,}<', '> <', data)
|
||||
# replace all ' with " and eliminate newline, so we don't need to worry about
|
||||
data = page.data
|
||||
data = html_uniform(data)
|
||||
scrapingTime = time()
|
||||
if patronBlock:
|
||||
if debugBlock:
|
||||
regexDbg(item, patronBlock, headers, data)
|
||||
blocks = scrapertools.find_multiple_matches_groups(data, patronBlock)
|
||||
block = ""
|
||||
for bl in blocks:
|
||||
# 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,
|
||||
typeContentDict, typeActionDict, blacklist, search, pag, function, lang, sceneTitle)
|
||||
typeContentDict, typeActionDict, blacklist, search, pag, function, lang, sceneTitle, group)
|
||||
for it in blockItemlist:
|
||||
if 'lang' in bl:
|
||||
it.contentLanguage, it.title = scrapeLang(bl, it.contentLanguage, it.title)
|
||||
@@ -468,36 +468,64 @@ def scrape(func):
|
||||
matches.extend(blockMatches)
|
||||
elif patron:
|
||||
itemlist, matches = scrapeBlock(item, args, data, patron, headers, action, pagination, debug, typeContentDict,
|
||||
typeActionDict, blacklist, search, pag, function, lang, sceneTitle)
|
||||
typeActionDict, blacklist, search, pag, function, lang, sceneTitle, group)
|
||||
|
||||
if 'itemlistHook' in args:
|
||||
itemlist = args['itemlistHook'](itemlist)
|
||||
|
||||
if 'ItemItemlistHook' in args:
|
||||
itemlist = args['ItemItemlistHook'](item, itemlist)
|
||||
try:
|
||||
itemlist = args['itemlistHook'](itemlist)
|
||||
except:
|
||||
raise logger.ChannelScraperException
|
||||
|
||||
# if url may be changed and channel has findhost to update
|
||||
if 'findhost' in func.__globals__ and not itemlist:
|
||||
info('running findhost ' + func.__module__)
|
||||
ch = func.__module__.split('.')[-1]
|
||||
host = config.get_channel_url(func.__globals__['findhost'], ch, True)
|
||||
try:
|
||||
host = config.get_channel_url(func.__globals__['findhost'], ch, True)
|
||||
|
||||
parse = list(urlparse.urlparse(item.url))
|
||||
parse[1] = scrapertools.get_domain_from_url(host)
|
||||
item.url = urlparse.urlunparse(parse)
|
||||
parse = list(urlparse.urlparse(item.url))
|
||||
parse[1] = scrapertools.get_domain_from_url(host)
|
||||
item.url = urlparse.urlunparse(parse)
|
||||
except:
|
||||
raise logger.ChannelScraperException
|
||||
data = None
|
||||
itemlist = []
|
||||
matches = []
|
||||
else:
|
||||
break
|
||||
|
||||
if not data:
|
||||
from platformcode.logger import WebErrorException
|
||||
raise WebErrorException(urlparse.urlparse(item.url)[1], item.channel)
|
||||
|
||||
if group and item.grouped or args.get('groupExplode'):
|
||||
import copy
|
||||
nextArgs = copy.copy(args)
|
||||
@scrape
|
||||
def newFunc():
|
||||
return nextArgs
|
||||
nextArgs['item'] = nextPage(itemlist, item, data, patronNext, function)
|
||||
nextArgs['group'] = False
|
||||
if nextArgs['item']:
|
||||
nextArgs['groupExplode'] = True
|
||||
itemlist.pop() # remove next page just added
|
||||
itemlist.extend(newFunc())
|
||||
else:
|
||||
nextArgs['groupExplode'] = False
|
||||
nextArgs['item'] = item
|
||||
itemlist = newFunc()
|
||||
itemlist = [i for i in itemlist if i.action not in ['add_pelicula_to_library', 'add_serie_to_library']]
|
||||
|
||||
if action != 'play' and function != 'episodios' and 'patronMenu' not in args and item.contentType in ['movie', 'tvshow', 'episode', 'undefined'] and not disabletmdb:
|
||||
tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True)
|
||||
|
||||
if (pagination and len(matches) <= pag * pagination) or not pagination: # next page with pagination
|
||||
if patronNext and inspect.stack()[1][3] not in ['newest']:
|
||||
if not group and not args.get('groupExplode') and ((pagination and len(matches) <= pag * pagination) or not pagination): # next page with pagination
|
||||
if patronNext and inspect.stack()[1][3] not in ['newest'] and inspect.stack()[2][3] not in ['get_channel_results']:
|
||||
nextPage(itemlist, item, data, patronNext, function)
|
||||
|
||||
# if function == 'episodios':
|
||||
# scraper.sort_episode_list(itemlist)
|
||||
|
||||
# next page for pagination
|
||||
if pagination and len(matches) > pag * pagination and not search:
|
||||
if inspect.stack()[1][3] not in ['newest','get_newest']:
|
||||
@@ -511,25 +539,31 @@ def scrape(func):
|
||||
url=item.url,
|
||||
args=item.args,
|
||||
page=pag + 1,
|
||||
thumbnail=thumb()))
|
||||
thumbnail=thumb(),
|
||||
prevthumb=item.prevthumb if item.prevthumb else item.thumbnail))
|
||||
|
||||
if anime:
|
||||
if anime and inspect.stack()[1][3] not in ['find_episodes']:
|
||||
from platformcode import autorenumber
|
||||
if function == 'episodios' or item.action == 'episodios': autorenumber.renumber(itemlist, item, 'bold')
|
||||
else: autorenumber.renumber(itemlist)
|
||||
if (function == 'episodios' or item.action == 'episodios'): autorenumber.start(itemlist, item)
|
||||
else: autorenumber.start(itemlist)
|
||||
# if anime and autorenumber.check(item) == False and len(itemlist)>0 and not scrapertools.find_single_match(itemlist[0].title, r'(\d+.\d+)'):
|
||||
# pass
|
||||
# else:
|
||||
if addVideolibrary and (item.infoLabels["title"] or item.fulltitle):
|
||||
# item.fulltitle = item.infoLabels["title"]
|
||||
videolibrary(itemlist, item, function=function)
|
||||
if function == 'episodios' or function == 'findvideos':
|
||||
download(itemlist, item, function=function)
|
||||
if inspect.stack()[1][3] not in ['find_episodes']:
|
||||
if addVideolibrary and (item.infoLabels["title"] or item.fulltitle):
|
||||
# item.fulltitle = item.infoLabels["title"]
|
||||
videolibrary(itemlist, item, function=function)
|
||||
if downloadEnabled and function == 'episodios' or function == 'findvideos':
|
||||
download(itemlist, item, function=function)
|
||||
|
||||
if 'patronMenu' in args and itemlist:
|
||||
itemlist = thumb(itemlist, genre=True)
|
||||
|
||||
if 'fullItemlistHook' in args:
|
||||
itemlist = args['fullItemlistHook'](itemlist)
|
||||
try:
|
||||
itemlist = args['fullItemlistHook'](itemlist)
|
||||
except:
|
||||
raise logger.ChannelScraperException
|
||||
|
||||
# itemlist = filterLang(item, itemlist) # causa problemi a newest
|
||||
|
||||
@@ -634,63 +668,6 @@ def dooplay_menu(item, type):
|
||||
return locals()
|
||||
|
||||
|
||||
def swzz_get_url(item):
|
||||
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:59.0) Gecko/20100101 Firefox/59.0'}
|
||||
# dbg()
|
||||
if "/link/" in item.url:
|
||||
data = httptools.downloadpage(item.url, headers=headers).data
|
||||
if "link =" in data:
|
||||
data = scrapertools.find_single_match(data, 'link = "([^"]+)"')
|
||||
if 'http' not in data:
|
||||
data = 'https:' + data
|
||||
elif 'linkId = ' in data:
|
||||
id = scrapertools.find_single_match(data, 'linkId = "([^"]+)"')
|
||||
data = stayonline(id)
|
||||
else:
|
||||
match = scrapertools.find_single_match(data, r'<meta name="og:url" content="([^"]+)"')
|
||||
match = scrapertools.find_single_match(data, r'URL=([^"]+)">') if not match else match
|
||||
|
||||
if not match:
|
||||
from lib import jsunpack
|
||||
|
||||
try:
|
||||
data = scrapertools.find_single_match(data.replace('\n', ''), r"(eval\s?\(function\(p,a,c,k,e,d.*?)</script>")
|
||||
data = jsunpack.unpack(data)
|
||||
|
||||
logger.debug("##### play /link/ unpack ##\n%s\n##" % data)
|
||||
except:
|
||||
logger.debug("##### The content is yet unpacked ##\n%s\n##" % data)
|
||||
|
||||
data = scrapertools.find_single_match(data, r'var link(?:\s)?=(?:\s)?"([^"]+)";')
|
||||
data, c = unshortenit.unwrap_30x_only(data)
|
||||
else:
|
||||
data = match
|
||||
if data.startswith('/'):
|
||||
data = urlparse.urljoin("http://swzz.xyz", data)
|
||||
if not "vcrypt" in data:
|
||||
data = httptools.downloadpage(data).data
|
||||
logger.debug("##### play /link/ data ##\n%s\n##" % data)
|
||||
|
||||
elif 'stayonline.pro' in item.url:
|
||||
id = item.url.split('/')[-2]
|
||||
data = stayonline(id)
|
||||
else:
|
||||
data = item.url
|
||||
|
||||
return data.replace('\\','')
|
||||
|
||||
def stayonline(id):
|
||||
reqUrl = 'https://stayonline.pro/ajax/linkView.php'
|
||||
p = urlencode({"id": id})
|
||||
data = httptools.downloadpage(reqUrl, post=p).data
|
||||
try:
|
||||
import json
|
||||
data = json.loads(data)['data']['value']
|
||||
except:
|
||||
data = scrapertools.find_single_match(data, r'"value"\s*:\s*"([^"]+)"')
|
||||
return data
|
||||
|
||||
|
||||
def menuItem(itemlist, filename, title='', action='', url='', contentType='undefined', args=[], style=True):
|
||||
# Function to simplify menu creation
|
||||
|
||||
@@ -708,11 +685,13 @@ def menuItem(itemlist, filename, title='', action='', url='', contentType='undef
|
||||
url = url,
|
||||
extra = extra,
|
||||
args = args,
|
||||
contentType = contentType
|
||||
contentType = contentType,
|
||||
))
|
||||
|
||||
|
||||
def menu(func):
|
||||
"""https://github.com/kodiondemand/addon/wiki/decoratori#menu"""
|
||||
|
||||
def wrapper(*args):
|
||||
args = func(*args)
|
||||
|
||||
@@ -732,7 +711,7 @@ def menu(func):
|
||||
itemlist = []
|
||||
|
||||
for name in listUrls:
|
||||
dictUrl[name] = args[name] if name in args else None
|
||||
dictUrl[name] = args.get(name, None)
|
||||
logger.debug(dictUrl[name])
|
||||
if name == 'film': title = 'Film'
|
||||
if name == 'tvshow': title = 'Serie TV'
|
||||
@@ -782,7 +761,7 @@ def menu(func):
|
||||
if name not in listUrls and name != 'item':
|
||||
listUrls_extra.append(name)
|
||||
for name in listUrls_extra:
|
||||
dictUrl[name] = args[name] if name in args else None
|
||||
dictUrl[name] = args.get(name, None)
|
||||
for sub, var in dictUrl[name]:
|
||||
menuItem(itemlist, filename,
|
||||
title = sub + ' ',
|
||||
@@ -827,7 +806,7 @@ def typo(string, typography=''):
|
||||
typography = string.split('{')[1].strip(' }').lower()
|
||||
string = string.replace('{' + typography + '}','').strip()
|
||||
else:
|
||||
string = string.strip()
|
||||
string = string
|
||||
typography.lower()
|
||||
|
||||
|
||||
@@ -924,12 +903,7 @@ def match(item_url_string, **args):
|
||||
data = httptools.downloadpage(url, **args).data
|
||||
|
||||
# format page data
|
||||
data = re.sub("='([^']+)'", '="\\1"', data)
|
||||
data = data.replace('\n', ' ')
|
||||
data = data.replace('\t', ' ')
|
||||
data = data.replace(' ', ' ')
|
||||
data = re.sub(r'>\s+<', '><', data)
|
||||
data = re.sub(r'([a-zA-Z])"([a-zA-Z])', "\1'\2", data)
|
||||
data = html_uniform(data)
|
||||
|
||||
# collect blocks of a page
|
||||
if patronBlock:
|
||||
@@ -1064,7 +1038,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
|
||||
info()
|
||||
logger.debug()
|
||||
|
||||
if item.contentType == 'movie':
|
||||
action = 'add_pelicula_to_library'
|
||||
@@ -1094,7 +1068,7 @@ def videolibrary(itemlist, item, typography='', function_level=1, function=''):
|
||||
or (function == 'episodios' and contentType != 'movie'):
|
||||
if config.get_videolibrary_support() and len(itemlist) > 0:
|
||||
itemlist.append(
|
||||
Item(channel=item.channel,
|
||||
item.clone(channel=item.channel,
|
||||
title=title,
|
||||
fulltitle=item.fulltitle,
|
||||
show=item.fulltitle,
|
||||
@@ -1111,10 +1085,11 @@ def videolibrary(itemlist, item, typography='', function_level=1, function=''):
|
||||
|
||||
return itemlist
|
||||
|
||||
|
||||
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
|
||||
info()
|
||||
logger.debug()
|
||||
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)
|
||||
@@ -1124,9 +1099,9 @@ 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('&', '&')
|
||||
info('NEXT= ', next_page)
|
||||
logger.debug('NEXT= ', next_page)
|
||||
itemlist.append(
|
||||
Item(channel=item.channel,
|
||||
item.clone(channel=item.channel,
|
||||
action = action,
|
||||
contentType=item.contentType,
|
||||
title=typo(config.get_localized_string(30992), 'color kod bold'),
|
||||
@@ -1134,8 +1109,7 @@ def nextPage(itemlist, item, data='', patron='', function_or_level=1, next_page=
|
||||
args=item.args,
|
||||
nextPage=True,
|
||||
thumbnail=thumb()))
|
||||
|
||||
return itemlist
|
||||
return itemlist[-1]
|
||||
|
||||
def pagination(itemlist, item, page, perpage, function_level=1):
|
||||
if len(itemlist) >= page * perpage:
|
||||
@@ -1152,9 +1126,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):
|
||||
info()
|
||||
blacklisted_servers = config.get_setting("black_list", server='servers')
|
||||
if not blacklisted_servers: blacklisted_servers = []
|
||||
logger.debug()
|
||||
if not data and not itemlist:
|
||||
data = httptools.downloadpage(item.url, headers=headers, ignore_response_code=True).data
|
||||
if data:
|
||||
@@ -1191,6 +1163,7 @@ def server(item, data='', itemlist=[], headers='', AutoPlay=True, CheckLinks=Tru
|
||||
videoitem.contentType = item.contentType
|
||||
videoitem.infoLabels = item.infoLabels
|
||||
videoitem.quality = quality
|
||||
videoitem.referer = item.url
|
||||
videoitem.action = "play"
|
||||
# videoitem.nfo = item.nfo
|
||||
# videoitem.strm_path = item.strm_path
|
||||
@@ -1199,7 +1172,7 @@ def server(item, data='', itemlist=[], headers='', AutoPlay=True, CheckLinks=Tru
|
||||
with futures.ThreadPoolExecutor() as executor:
|
||||
thL = [executor.submit(getItem, videoitem) for videoitem in itemlist if videoitem.url]
|
||||
for it in futures.as_completed(thL):
|
||||
if it.result() and it.result().server.lower() not in blacklisted_servers:
|
||||
if it.result() and not config.get_setting("black_list", server=it.result().server.lower()):
|
||||
verifiedItemlist.append(it.result())
|
||||
try:
|
||||
verifiedItemlist.sort(key=lambda it: int(re.sub(r'\D','',it.quality)))
|
||||
@@ -1322,6 +1295,7 @@ def addQualityTag(item, itemlist, data, patron):
|
||||
itemlist.insert(0,Item(channel=item.channel,
|
||||
action="",
|
||||
title=typo(qualityStr, '[] color kod bold'),
|
||||
fulltitle=qualityStr,
|
||||
plot=descr,
|
||||
folder=False,
|
||||
thumbnail=thumb('info')))
|
||||
@@ -1417,7 +1391,7 @@ def thumb(item_itemlist_string=None, genre=False, live=False):
|
||||
'_tvshow':['serie','tv', 'fiction']}
|
||||
|
||||
def autoselect_thumb(item, genre):
|
||||
info('SPLIT',re.split(r'\.|\{|\}|\[|\]|\(|\)|/| ',item.title.lower()))
|
||||
# logger.debug('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):
|
||||
|
||||
+10
-12
@@ -19,7 +19,7 @@ import ast, copy, re, sqlite3, time, xbmcaddon
|
||||
|
||||
from core import filetools, httptools, jsontools, scrapertools
|
||||
from core.item import InfoLabels
|
||||
from platformcode import config, logger
|
||||
from platformcode import config, logger, platformtools
|
||||
|
||||
info_language = ["de", "en", "es", "fr", "it", "pt"] # from videolibrary.json
|
||||
def_lang = info_language[config.get_setting("info_language", "videolibrary")]
|
||||
@@ -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.info()
|
||||
logger.debug()
|
||||
|
||||
# import time
|
||||
# start_time = time.time()
|
||||
@@ -495,7 +495,7 @@ def set_infoLabels_item(item, seekTmdb=True, idioma_busqueda=def_lang, lock=None
|
||||
|
||||
|
||||
def find_and_set_infoLabels(item):
|
||||
logger.info()
|
||||
logger.debug()
|
||||
|
||||
global otmdb_global
|
||||
tmdb_result = None
|
||||
@@ -524,9 +524,7 @@ def find_and_set_infoLabels(item):
|
||||
otmdb_global = Tmdb(id_Tmdb=item.infoLabels['tmdb_id'], tipo=tipo_busqueda, idioma_busqueda=def_lang)
|
||||
|
||||
results = otmdb_global.get_list_resultados()
|
||||
|
||||
if len(results) > 1:
|
||||
from platformcode import platformtools
|
||||
tmdb_result = platformtools.show_video_info(results, item=item, caption= tipo_contenido % title)
|
||||
elif len(results) > 0:
|
||||
tmdb_result = results[0]
|
||||
@@ -904,7 +902,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.info("[Tmdb.py] Filling in dictionary of genres")
|
||||
logger.debug("[Tmdb.py] Filling in dictionary of genres")
|
||||
|
||||
resultado = cls.get_json(url)
|
||||
if not isinstance(resultado, dict):
|
||||
@@ -936,7 +934,7 @@ class Tmdb(object):
|
||||
'&language=%s' % (self.busqueda_id, source, self.busqueda_idioma))
|
||||
buscando = "%s: %s" % (source.capitalize(), self.busqueda_id)
|
||||
|
||||
logger.info("[Tmdb.py] Searching %s:\n%s" % (buscando, url))
|
||||
logger.debug("[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'))
|
||||
@@ -983,7 +981,7 @@ class Tmdb(object):
|
||||
url += '&year=%s' % self.busqueda_year
|
||||
|
||||
buscando = self.busqueda_texto.capitalize()
|
||||
logger.info("[Tmdb.py] Searching %s on page %s:\n%s" % (buscando, page, url))
|
||||
logger.debug("[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'))
|
||||
@@ -1044,7 +1042,7 @@ class Tmdb(object):
|
||||
url = ('http://api.themoviedb.org/3/%s?api_key=a1ab8b8669da03637a4b98fa39c39228&%s'
|
||||
% (type_search, "&".join(params)))
|
||||
|
||||
logger.info("[Tmdb.py] Searcing %s:\n%s" % (type_search, url))
|
||||
logger.debug("[Tmdb.py] Searcing %s:\n%s" % (type_search, url))
|
||||
resultado = self.get_json(url, cache=False)
|
||||
if not isinstance(resultado, dict):
|
||||
resultado = ast.literal_eval(resultado.decode('utf-8'))
|
||||
@@ -1109,7 +1107,7 @@ class Tmdb(object):
|
||||
return True
|
||||
|
||||
def get_list_resultados(self, num_result=20):
|
||||
# logger.info("self %s" % str(self))
|
||||
# logger.debug("self %s" % str(self))
|
||||
res = []
|
||||
|
||||
if num_result <= 0:
|
||||
@@ -1329,7 +1327,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.info("[Tmdb.py] Searcing " + buscando)
|
||||
logger.debug("[Tmdb.py] Searcing " + buscando)
|
||||
try:
|
||||
self.temporada[numtemporada] = self.get_json(url)
|
||||
if not isinstance(self.temporada[numtemporada], dict):
|
||||
@@ -1518,7 +1516,7 @@ class Tmdb(object):
|
||||
|
||||
items.extend(list(self.get_episodio(ret_infoLabels['season'], episodio).items()))
|
||||
|
||||
# logger.info("ret_infoLabels" % ret_infoLabels)
|
||||
# logger.debug("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.info()
|
||||
logger.debug()
|
||||
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.info()
|
||||
logger.debug()
|
||||
|
||||
id_list = []
|
||||
id_dict = dict()
|
||||
@@ -229,7 +229,7 @@ def trakt_check(itemlist):
|
||||
|
||||
|
||||
def get_sync_from_file():
|
||||
logger.info()
|
||||
logger.debug()
|
||||
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.info()
|
||||
logger.debug()
|
||||
|
||||
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.info()
|
||||
logger.debug()
|
||||
|
||||
from platformcode import platformtools
|
||||
|
||||
@@ -265,7 +265,7 @@ def ask_install_script():
|
||||
|
||||
|
||||
def wait_for_update_trakt():
|
||||
logger.info()
|
||||
logger.debug()
|
||||
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.info()
|
||||
logger.debug()
|
||||
sleep(20)
|
||||
while xbmc.Player().isPlaying():
|
||||
sleep(20)
|
||||
|
||||
+108
-134
@@ -77,8 +77,9 @@ otvdb_global = None
|
||||
|
||||
|
||||
def find_and_set_infoLabels(item):
|
||||
logger.info()
|
||||
# logger.info("item es %s" % item)
|
||||
logger.debug()
|
||||
# from core.support import dbg;dbg()
|
||||
# logger.debug("item es %s" % item)
|
||||
|
||||
p_dialog = None
|
||||
if not item.contentSeason:
|
||||
@@ -89,16 +90,18 @@ def find_and_set_infoLabels(item):
|
||||
|
||||
title = item.contentSerieName
|
||||
# If the title includes the (year) we will remove it
|
||||
year = scrapertools.find_single_match(title, "^.+?\s*(\(\d{4}\))$")
|
||||
year = scrapertools.find_single_match(title, r"^.+?\s*(\(\d{4}\))$")
|
||||
if year:
|
||||
title = title.replace(year, "").strip()
|
||||
item.infoLabels['year'] = year[1:-1]
|
||||
|
||||
if not item.infoLabels.get("tvdb_id"):
|
||||
if not item.infoLabels.get("imdb_id"):
|
||||
if item.infoLabels.get("tvdb_id", '') in ['', 'None']:
|
||||
if item.infoLabels['year']:
|
||||
otvdb_global = Tvdb(search=title, year=item.infoLabels['year'])
|
||||
else:
|
||||
elif item.infoLabels.get("imdb_id"):
|
||||
otvdb_global = Tvdb(imdb_id=item.infoLabels.get("imdb_id"))
|
||||
else:
|
||||
otvdb_global = Tvdb(search=title)
|
||||
|
||||
elif not otvdb_global or otvdb_global.get_id() != item.infoLabels['tvdb_id']:
|
||||
otvdb_global = Tvdb(tvdb_id=item.infoLabels['tvdb_id'])
|
||||
@@ -114,9 +117,16 @@ def find_and_set_infoLabels(item):
|
||||
|
||||
if len(results) > 1:
|
||||
tvdb_result = platformtools.show_video_info(results, item=item, scraper=Tvdb, caption=config.get_localized_string(60298) % title)
|
||||
# if not tvdb_result:
|
||||
# res = platformtools.dialog_info(item, 'tvdb')
|
||||
# if not res.exit: return find_and_set_infoLabels(res)
|
||||
elif len(results) > 0:
|
||||
tvdb_result = results[0]
|
||||
|
||||
# else:
|
||||
# res = platformtools.dialog_info(item, 'tvdb')
|
||||
# if not res.exit: return find_and_set_infoLabels(res)
|
||||
|
||||
# todo revisar
|
||||
if isinstance(item.infoLabels, InfoLabels):
|
||||
logger.debug("is an instance of infoLabels")
|
||||
@@ -160,7 +170,7 @@ def set_infoLabels_item(item):
|
||||
if 'infoLabels' in item and 'fanart' in item.infoLabels['fanart']:
|
||||
item.fanart = item.infoLabels['fanart']
|
||||
|
||||
if 'infoLabels' in item and 'season' in item.infoLabels:
|
||||
if 'infoLabels' in item and 'season' in item.infoLabels and item.contentType != 'tvshow':
|
||||
try:
|
||||
int_season = int(item.infoLabels['season'])
|
||||
except ValueError:
|
||||
@@ -372,7 +382,7 @@ class Tvdb(object):
|
||||
|
||||
@classmethod
|
||||
def __check_token(cls):
|
||||
# logger.info()
|
||||
# logger.debug()
|
||||
if TOKEN == "":
|
||||
cls.__login()
|
||||
else:
|
||||
@@ -387,7 +397,7 @@ class Tvdb(object):
|
||||
|
||||
@staticmethod
|
||||
def __login():
|
||||
# logger.info()
|
||||
# logger.debug()
|
||||
global TOKEN
|
||||
|
||||
apikey = "106B699FDC04301C"
|
||||
@@ -398,19 +408,13 @@ class Tvdb(object):
|
||||
else: params = jsontools.dump(params)
|
||||
|
||||
try:
|
||||
req = urllib.request.Request(url, data=params, headers=DEFAULT_HEADERS)
|
||||
response = urllib.request.urlopen(req)
|
||||
html = response.read()
|
||||
response.close()
|
||||
dict_html = requests.post(url, data=params, headers=DEFAULT_HEADERS).json()
|
||||
|
||||
except Exception as ex:
|
||||
message = "An exception of type %s occured. Arguments:\n%s" % (type(ex).__name__, repr(ex.args))
|
||||
logger.error("error: %s" % message)
|
||||
|
||||
else:
|
||||
dict_html = jsontools.load(html)
|
||||
# logger.debug("dict_html %s" % dict_html)
|
||||
|
||||
if "token" in dict_html:
|
||||
token = dict_html["token"]
|
||||
DEFAULT_HEADERS["Authorization"] = "Bearer " + token
|
||||
@@ -419,22 +423,19 @@ class Tvdb(object):
|
||||
|
||||
@classmethod
|
||||
def __refresh_token(cls):
|
||||
# logger.info()
|
||||
# logger.debug()
|
||||
global TOKEN
|
||||
is_success = False
|
||||
|
||||
url = HOST + "/refresh_token"
|
||||
|
||||
try:
|
||||
req = urllib.request.Request(url, headers=DEFAULT_HEADERS)
|
||||
response = urllib.request.urlopen(req)
|
||||
html = response.read()
|
||||
response.close()
|
||||
req = requests.get(url, headers=DEFAULT_HEADERS)
|
||||
|
||||
except urllib.error.HTTPError as err:
|
||||
logger.error("err.code %s" % err.code)
|
||||
|
||||
except req as err:
|
||||
logger.error("err.code %s" % err.status_code)
|
||||
# if there is error 401 it is that the token has passed the time and we have to call login again
|
||||
if err.code == 401:
|
||||
if err.status_code == 401:
|
||||
cls.__login()
|
||||
else:
|
||||
raise
|
||||
@@ -444,13 +445,15 @@ class Tvdb(object):
|
||||
logger.error("error: %s" % message)
|
||||
|
||||
else:
|
||||
dict_html = jsontools.load(html)
|
||||
dict_html = req.json()
|
||||
# logger.error("tokencito %s" % dict_html)
|
||||
if "token" in dict_html:
|
||||
token = dict_html["token"]
|
||||
DEFAULT_HEADERS["Authorization"] = "Bearer " + token
|
||||
TOKEN = config.set_setting("tvdb_token", token)
|
||||
is_success = True
|
||||
else:
|
||||
cls.__login()
|
||||
|
||||
return is_success
|
||||
|
||||
@@ -518,7 +521,7 @@ class Tvdb(object):
|
||||
]
|
||||
}
|
||||
"""
|
||||
logger.info()
|
||||
logger.debug()
|
||||
if id_episode and self.episodes.get(id_episode):
|
||||
return self.episodes.get(id_episode)
|
||||
|
||||
@@ -531,18 +534,16 @@ class Tvdb(object):
|
||||
DEFAULT_HEADERS["Accept-Language"] = lang
|
||||
logger.debug("url: %s, \nheaders: %s" % (url, DEFAULT_HEADERS))
|
||||
|
||||
req = urllib.request.Request(url, headers=DEFAULT_HEADERS)
|
||||
response = urllib.request.urlopen(req)
|
||||
html = response.read()
|
||||
response.close()
|
||||
req = requests.get(url, headers=DEFAULT_HEADERS)
|
||||
|
||||
except Exception as ex:
|
||||
message = "An exception of type %s occured. Arguments:\n%s" % (type(ex).__name__, repr(ex.args))
|
||||
logger.error("error: %s" % message)
|
||||
|
||||
else:
|
||||
dict_html = jsontools.load(html)
|
||||
|
||||
dict_html = req.json()
|
||||
if 'Error' in dict_html:
|
||||
logger.debug("code %s " % dict_html['Error'])
|
||||
if "data" in dict_html and "id" in dict_html["data"][0]:
|
||||
self.get_episode_by_id(dict_html["data"][0]["id"], lang)
|
||||
return dict_html["data"]
|
||||
@@ -588,27 +589,14 @@ class Tvdb(object):
|
||||
}
|
||||
}
|
||||
"""
|
||||
logger.info()
|
||||
logger.debug()
|
||||
|
||||
try:
|
||||
url = HOST + "/series/%s/episodes?page=%s" % (_id, page)
|
||||
logger.debug("url: %s, \nheaders: %s" % (url, DEFAULT_HEADERS))
|
||||
|
||||
req = urllib.request.Request(url, headers=DEFAULT_HEADERS)
|
||||
response = urllib.request.urlopen(req)
|
||||
html = response.read()
|
||||
response.close()
|
||||
|
||||
except Exception as ex:
|
||||
message = "An exception of type %s occured. Arguments:\n%s" % (type(ex).__name__, repr(ex.args))
|
||||
logger.error("error: %s" % message)
|
||||
|
||||
else:
|
||||
self.list_episodes[page] = jsontools.load(html)
|
||||
|
||||
# logger.info("dict_html %s" % self.list_episodes)
|
||||
|
||||
return self.list_episodes[page]
|
||||
url = HOST + "/series/%s/episodes?page=%s" % (_id, page)
|
||||
logger.debug("url: %s, \nheaders: %s" % (url, DEFAULT_HEADERS))
|
||||
js = requests.get(url, headers=DEFAULT_HEADERS).json()
|
||||
self.list_episodes[page] = js if 'Error' not in js else {}
|
||||
return self.list_episodes[page]
|
||||
|
||||
def get_episode_by_id(self, _id, lang=DEFAULT_LANG, semaforo=None):
|
||||
"""
|
||||
@@ -674,31 +662,27 @@ class Tvdb(object):
|
||||
"""
|
||||
if semaforo:
|
||||
semaforo.acquire()
|
||||
logger.info()
|
||||
logger.debug()
|
||||
|
||||
url = HOST + "/episodes/%s" % _id
|
||||
|
||||
# from core.support import dbg;dbg()
|
||||
|
||||
try:
|
||||
DEFAULT_HEADERS["Accept-Language"] = lang
|
||||
logger.debug("url: %s, \nheaders: %s" % (url, DEFAULT_HEADERS))
|
||||
req = urllib.request.Request(url, headers=DEFAULT_HEADERS)
|
||||
response = urllib.request.urlopen(req)
|
||||
html = response.read()
|
||||
response.close()
|
||||
req = requests.get(url, headers=DEFAULT_HEADERS)
|
||||
|
||||
except Exception as ex:
|
||||
# if isinstance(ex, urllib).HTTPError:
|
||||
logger.debug("code %s " % ex.code)
|
||||
|
||||
logger.debug("code %s " % ex)
|
||||
message = "An exception of type %s occured. Arguments:\n%s" % (type(ex).__name__, repr(ex.args))
|
||||
logger.error("error en: %s" % message)
|
||||
|
||||
else:
|
||||
dict_html = jsontools.load(html)
|
||||
dict_html = dict_html.pop("data")
|
||||
|
||||
logger.info("dict_html %s" % dict_html)
|
||||
self.episodes[_id] = dict_html
|
||||
dict_html = req.json()
|
||||
# logger.debug("dict_html %s" % dict_html)
|
||||
self.episodes[_id] = dict_html.pop("data") if 'Error' not in dict_html else {}
|
||||
|
||||
if semaforo:
|
||||
semaforo.release()
|
||||
@@ -728,39 +712,30 @@ class Tvdb(object):
|
||||
"status": "string"
|
||||
}
|
||||
"""
|
||||
logger.info()
|
||||
logger.debug()
|
||||
|
||||
try:
|
||||
params = {}
|
||||
if name:
|
||||
params["name"] = name
|
||||
elif imdb_id:
|
||||
params["imdbId"] = imdb_id
|
||||
elif zap2it_id:
|
||||
params["zap2itId"] = zap2it_id
|
||||
|
||||
params = {}
|
||||
if name:
|
||||
params["name"] = name
|
||||
elif imdb_id:
|
||||
params["imdbId"] = imdb_id
|
||||
elif zap2it_id:
|
||||
params["zap2itId"] = zap2it_id
|
||||
params = urllib.parse.urlencode(params)
|
||||
|
||||
params = urllib.parse.urlencode(params)
|
||||
DEFAULT_HEADERS["Accept-Language"] = lang
|
||||
url = HOST + "/search/series?%s" % params
|
||||
logger.debug("url: %s, \nheaders: %s" % (url, DEFAULT_HEADERS))
|
||||
|
||||
DEFAULT_HEADERS["Accept-Language"] = lang
|
||||
url = HOST + "/search/series?%s" % params
|
||||
logger.debug("url: %s, \nheaders: %s" % (url, DEFAULT_HEADERS))
|
||||
dict_html = requests.get(url, headers=DEFAULT_HEADERS).json()
|
||||
|
||||
req = urllib.request.Request(url, headers=DEFAULT_HEADERS)
|
||||
response = urllib.request.urlopen(req)
|
||||
html = response.read()
|
||||
logger.info(html)
|
||||
response.close()
|
||||
|
||||
except Exception as ex:
|
||||
if 'Error' in dict_html:
|
||||
# if isinstance(ex, urllib.parse).HTTPError:
|
||||
logger.debug("code %s " % ex.code)
|
||||
|
||||
message = "An exception of type %s occured. Arguments:\n%s" % (type(ex).__name__, repr(ex.args))
|
||||
logger.error("error: %s" % message)
|
||||
logger.debug("code %s " % dict_html['Error'])
|
||||
|
||||
else:
|
||||
dict_html = jsontools.load(html)
|
||||
|
||||
if "errors" in dict_html and "invalidLanguage" in dict_html["errors"]:
|
||||
# no hay información en idioma por defecto
|
||||
@@ -827,20 +802,16 @@ class Tvdb(object):
|
||||
}
|
||||
}
|
||||
"""
|
||||
logger.info()
|
||||
logger.debug()
|
||||
resultado = {}
|
||||
|
||||
url = HOST + "/series/%s" % _id
|
||||
|
||||
try:
|
||||
DEFAULT_HEADERS["Accept-Language"] = lang
|
||||
req = urllib.request.Request(url, headers=DEFAULT_HEADERS)
|
||||
req = requests.get(url, headers=DEFAULT_HEADERS)
|
||||
logger.debug("url: %s, \nheaders: %s" % (url, DEFAULT_HEADERS))
|
||||
|
||||
response = urllib.request.urlopen(req)
|
||||
html = response.read()
|
||||
response.close()
|
||||
|
||||
except Exception as ex:
|
||||
# if isinstance(ex, urllib).HTTPError:
|
||||
logger.debug("code %s " % ex)
|
||||
@@ -849,26 +820,24 @@ class Tvdb(object):
|
||||
logger.error("error: %s" % message)
|
||||
|
||||
else:
|
||||
dict_html = jsontools.load(html)
|
||||
|
||||
if "errors" in dict_html and "invalidLanguage" in dict_html["errors"]:
|
||||
dict_html = req.json()
|
||||
if "Error" in dict_html and "invalidLanguage" in dict_html["Error"]:
|
||||
return {}
|
||||
else:
|
||||
resultado1 = dict_html["data"]
|
||||
if not resultado1 and from_get_list:
|
||||
return self.__get_by_id(_id, "en")
|
||||
resultado1 = dict_html["data"]
|
||||
if not resultado1 and from_get_list:
|
||||
return self.__get_by_id(_id, "en")
|
||||
|
||||
logger.debug("Result %s" % dict_html)
|
||||
resultado2 = {"image_poster": [{'keyType': 'poster', 'fileName': 'posters/%s-1.jpg' % _id}]}
|
||||
resultado3 = {"image_fanart": [{'keyType': 'fanart', 'fileName': 'fanart/original/%s-1.jpg' % _id}]}
|
||||
logger.debug("Result %s" % dict_html)
|
||||
resultado2 = {"image_poster": [{'keyType': 'poster', 'fileName': 'posters/%s-1.jpg' % _id}]}
|
||||
resultado3 = {"image_fanart": [{'keyType': 'fanart', 'fileName': 'fanart/original/%s-1.jpg' % _id}]}
|
||||
|
||||
resultado = resultado1.copy()
|
||||
resultado.update(resultado2)
|
||||
resultado.update(resultado3)
|
||||
resultado = resultado1.copy()
|
||||
resultado.update(resultado2)
|
||||
resultado.update(resultado3)
|
||||
|
||||
logger.debug("total result %s" % resultado)
|
||||
self.list_results = [resultado]
|
||||
self.result = resultado
|
||||
logger.debug("total result %s" % resultado)
|
||||
self.list_results = [resultado]
|
||||
self.result = resultado
|
||||
|
||||
return resultado
|
||||
|
||||
@@ -886,7 +855,7 @@ class Tvdb(object):
|
||||
@rtype: dict
|
||||
|
||||
"""
|
||||
logger.info()
|
||||
logger.debug()
|
||||
|
||||
if self.result.get('image_season_%s' % season):
|
||||
return self.result['image_season_%s' % season]
|
||||
@@ -909,24 +878,26 @@ class Tvdb(object):
|
||||
url = HOST + "/series/%s/images/query?%s" % (_id, params)
|
||||
logger.debug("url: %s, \nheaders: %s" % (url, DEFAULT_HEADERS))
|
||||
|
||||
req = urllib.request.Request(url, headers=DEFAULT_HEADERS)
|
||||
response = urllib.request.urlopen(req)
|
||||
html = response.read()
|
||||
response.close()
|
||||
res = requests.get(url, headers=DEFAULT_HEADERS)
|
||||
|
||||
except Exception as ex:
|
||||
# if isinstance(ex, urllib).HTTPError:
|
||||
logger.debug("code %s " % ex)
|
||||
|
||||
message = "An exception of type %s occured. Arguments:\n%s" % (type(ex).__name__, repr(ex.args))
|
||||
logger.error("error: %s" % message)
|
||||
|
||||
return {}
|
||||
|
||||
else:
|
||||
dict_html = jsontools.load(html)
|
||||
dict_html = res.json()
|
||||
if 'Error' in dict_html:
|
||||
# if isinstance(ex, urllib.parse).HTTPError:
|
||||
logger.debug("code %s " % dict_html['Error'])
|
||||
else:
|
||||
dict_html["image_" + image] = dict_html.pop("data")
|
||||
self.result.update(dict_html)
|
||||
|
||||
dict_html["image_" + image] = dict_html.pop("data")
|
||||
self.result.update(dict_html)
|
||||
|
||||
return dict_html
|
||||
return dict_html
|
||||
|
||||
def get_tvshow_cast(self, _id, lang=DEFAULT_LANG):
|
||||
"""
|
||||
@@ -938,20 +909,23 @@ class Tvdb(object):
|
||||
@return: dictionary with actors
|
||||
@rtype: dict
|
||||
"""
|
||||
logger.info()
|
||||
logger.debug()
|
||||
|
||||
url = HOST + "/series/%s/actors" % _id
|
||||
DEFAULT_HEADERS["Accept-Language"] = lang
|
||||
logger.debug("url: %s, \nheaders: %s" % (url, DEFAULT_HEADERS))
|
||||
|
||||
req = urllib.request.Request(url, headers=DEFAULT_HEADERS)
|
||||
response = urllib.request.urlopen(req)
|
||||
html = response.read()
|
||||
response.close()
|
||||
|
||||
dict_html = jsontools.load(html)
|
||||
|
||||
dict_html["cast"] = dict_html.pop("data")
|
||||
try:
|
||||
req = requests.get(url, headers=DEFAULT_HEADERS)
|
||||
except Exception as ex:
|
||||
logger.debug("code %s " % ex)
|
||||
message = "An exception of type %s occured. Arguments:\n%s" % (type(ex).__name__, repr(ex.args))
|
||||
logger.error("error en: %s" % message)
|
||||
else:
|
||||
dict_html = req.json()
|
||||
if 'Error' in dict_html:
|
||||
logger.debug("code %s " % dict_html['Error'])
|
||||
else:
|
||||
dict_html["cast"] = dict_html.pop("data")
|
||||
self.result.update(dict_html)
|
||||
|
||||
def get_id(self):
|
||||
@@ -968,7 +942,7 @@ class Tvdb(object):
|
||||
@rtype: list
|
||||
@return: list of results
|
||||
"""
|
||||
logger.info()
|
||||
logger.debug()
|
||||
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
|
||||
@@ -1034,12 +1008,12 @@ class Tvdb(object):
|
||||
if 'data' in thumbs:
|
||||
ret_infoLabels['thumbnail'] = HOST_IMAGE + thumbs['data'][0]['fileName']
|
||||
elif 'poster' in origen and origen['poster']:
|
||||
ret_infoLabels['thumbnail'] = origen['poster']
|
||||
ret_infoLabels['thumbnail'] = HOST_IMAGE + origen['poster']
|
||||
fanarts = requests.get(HOST + '/series/' + str(origen['id']) + '/images/query?keyType=fanart').json()
|
||||
if 'data' in fanarts:
|
||||
ret_infoLabels['fanart'] = HOST_IMAGE + fanarts['data'][0]['fileName']
|
||||
elif 'fanart' in origen and origen['fanart']:
|
||||
ret_infoLabels['thumbnail'] = origen['fanart']
|
||||
ret_infoLabels['fanart'] = HOST_IMAGE + origen['fanart']
|
||||
if 'overview' in origen and origen['overview']:
|
||||
ret_infoLabels['plot'] = origen['overview']
|
||||
if 'duration' in origen and origen['duration']:
|
||||
|
||||
+49
-44
@@ -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.info()
|
||||
logger.debug()
|
||||
# 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.info("Creating movie directory:" + path)
|
||||
logger.debug("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.info("Creating .nfo: " + nfo_path)
|
||||
logger.debug("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.info("The file exists. Is overwritten")
|
||||
logger.debug("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.info("FOLDER_MOVIES : %s" % FOLDER_MOVIES)
|
||||
#logger.debug("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.info('UPDATED=\n' + str(item.channel_prefs))
|
||||
logger.debug('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.info()
|
||||
logger.debug()
|
||||
# logger.debug(item.tostring('\n'))
|
||||
path = ""
|
||||
|
||||
@@ -486,7 +486,7 @@ def save_tvshow(item, episodelist, silent=False):
|
||||
|
||||
if not path:
|
||||
path = filetools.join(TVSHOWS_PATH, ("%s [%s]" % (base_name, _id)).strip())
|
||||
logger.info("Creating series directory: " + path)
|
||||
logger.debug("Creating series directory: " + path)
|
||||
try:
|
||||
filetools.mkdir(path)
|
||||
except OSError as exception:
|
||||
@@ -496,7 +496,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.info("Creating tvshow.nfo: " + tvshow_path)
|
||||
logger.debug("Creating tvshow.nfo: " + tvshow_path)
|
||||
head_nfo = scraper.get_nfo(item)
|
||||
item.infoLabels['mediatype'] = "tvshow"
|
||||
item.infoLabels['title'] = item.contentSerieName
|
||||
@@ -570,11 +570,11 @@ def save_episodes(path, episodelist, serie, silent=False, overwrite=True):
|
||||
@rtype fallidos: int
|
||||
@return: the number of failed episodes
|
||||
"""
|
||||
logger.info()
|
||||
logger.debug()
|
||||
episodelist = filter_list(episodelist, serie.action, path)
|
||||
# No episode list, nothing to save
|
||||
if not len(episodelist):
|
||||
logger.info("There is no episode list, we go out without creating strm")
|
||||
logger.debug("There is no episode list, we go out without creating strm")
|
||||
return 0, 0, 0
|
||||
|
||||
# process local episodes
|
||||
@@ -589,7 +589,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.info("An issue has occurred while configuring local episodes, going out without creating strm")
|
||||
logger.debug("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())
|
||||
@@ -601,7 +601,7 @@ def save_episodes(path, episodelist, serie, silent=False, overwrite=True):
|
||||
local_episodelist += get_local_content(local_episodes_path)
|
||||
clean_list = []
|
||||
for f in filetools.listdir(path):
|
||||
match = scrapertools.find_single_match(f, r'[Ss]?(\d+)(?:x|_|\.|\s+)?[Ee]?[Pp]?(\d+)')
|
||||
match = scrapertools.find_single_match(f, r'[Ss]?(\d+)(?:x|_|\s+)?[Ee]?[Pp]?(\d+)')
|
||||
if match:
|
||||
ep = '%dx%02d' % (int(match[0]), int(match[1]))
|
||||
if ep in local_episodelist:
|
||||
@@ -713,7 +713,7 @@ def save_episodes(path, episodelist, serie, silent=False, overwrite=True):
|
||||
|
||||
# No episode list, nothing to save
|
||||
if not len(new_episodelist):
|
||||
logger.info("There is no episode list, we go out without creating strm")
|
||||
logger.debug("There is no episode list, we go out without creating strm")
|
||||
return 0, 0, 0
|
||||
|
||||
local_episodelist += get_local_content(path)
|
||||
@@ -745,12 +745,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.info('Skipped: Serie ' + serie.contentSerieName + ' ' + season_episode + ' available as local content')
|
||||
logger.debug('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.info('INFO: "%s" episode %s has been downloaded, skipping it' % (serie.contentSerieName, season_episode))
|
||||
logger.debug('INFO: "%s" episode %s has been downloaded, skipping it' % (serie.contentSerieName, season_episode))
|
||||
continue
|
||||
|
||||
strm_exists = strm_path in ficheros
|
||||
@@ -806,7 +806,7 @@ def save_episodes(path, episodelist, serie, silent=False, overwrite=True):
|
||||
|
||||
if filetools.write(json_path, e.tojson()):
|
||||
if not json_exists:
|
||||
logger.info("Inserted: %s" % json_path)
|
||||
logger.debug("Inserted: %s" % json_path)
|
||||
insertados += 1
|
||||
# We mark episode as unseen
|
||||
news_in_playcounts[season_episode] = 0
|
||||
@@ -817,14 +817,14 @@ def save_episodes(path, episodelist, serie, silent=False, overwrite=True):
|
||||
news_in_playcounts[serie.contentSerieName] = 0
|
||||
|
||||
else:
|
||||
logger.info("Overwritten: %s" % json_path)
|
||||
logger.debug("Overwritten: %s" % json_path)
|
||||
sobreescritos += 1
|
||||
else:
|
||||
logger.info("Failed: %s" % json_path)
|
||||
logger.debug("Failed: %s" % json_path)
|
||||
fallidos += 1
|
||||
|
||||
else:
|
||||
logger.info("Failed: %s" % json_path)
|
||||
logger.debug("Failed: %s" % json_path)
|
||||
fallidos += 1
|
||||
|
||||
if not silent and p_dialog.iscanceled():
|
||||
@@ -894,7 +894,7 @@ def save_episodes(path, episodelist, serie, silent=False, overwrite=True):
|
||||
|
||||
|
||||
def config_local_episodes_path(path, item, silent=False):
|
||||
logger.info(item)
|
||||
logger.debug(item)
|
||||
from platformcode.xbmc_videolibrary import search_local_path
|
||||
local_episodes_path=search_local_path(item)
|
||||
if not local_episodes_path:
|
||||
@@ -906,11 +906,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.info("User has canceled the dialog")
|
||||
logger.debug("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.info("Selected folder is the same of the TV show one")
|
||||
logger.debug("Selected folder is the same of the TV show one")
|
||||
return -2, local_episodes_path
|
||||
|
||||
if local_episodes_path:
|
||||
@@ -925,7 +925,7 @@ def config_local_episodes_path(path, item, silent=False):
|
||||
|
||||
|
||||
def process_local_episodes(local_episodes_path, path):
|
||||
logger.info()
|
||||
logger.debug()
|
||||
|
||||
sub_extensions = ['.srt', '.sub', '.sbv', '.ass', '.idx', '.ssa', '.smi']
|
||||
artwork_extensions = ['.jpg', '.jpeg', '.png']
|
||||
@@ -964,7 +964,7 @@ def process_local_episodes(local_episodes_path, path):
|
||||
|
||||
|
||||
def get_local_content(path):
|
||||
logger.info()
|
||||
logger.debug()
|
||||
|
||||
local_episodelist = []
|
||||
for root, folders, files in filetools.walk(path):
|
||||
@@ -993,7 +993,7 @@ def add_movie(item):
|
||||
@type item: item
|
||||
@param item: item to be saved.
|
||||
"""
|
||||
logger.info()
|
||||
logger.debug()
|
||||
from platformcode.launcher import set_search_temp; set_search_temp(item)
|
||||
|
||||
# To disambiguate titles, TMDB is caused to ask for the really desired title
|
||||
@@ -1006,17 +1006,17 @@ def add_movie(item):
|
||||
item = generictools.update_title(item) # We call the method that updates the title with tmdb.find_and_set_infoLabels
|
||||
#if item.tmdb_stat:
|
||||
# del item.tmdb_stat # We clean the status so that it is not recorded in the Video Library
|
||||
if item:
|
||||
new_item = item.clone(action="findvideos")
|
||||
insertados, sobreescritos, fallidos, path = save_movie(new_item)
|
||||
# if item:
|
||||
new_item = item.clone(action="findvideos")
|
||||
insertados, sobreescritos, fallidos, path = save_movie(new_item)
|
||||
|
||||
if fallidos == 0:
|
||||
platformtools.dialog_ok(config.get_localized_string(30131),
|
||||
config.get_localized_string(30135) % new_item.contentTitle) # 'has been added to the video library'
|
||||
else:
|
||||
filetools.rmdirtree(path)
|
||||
platformtools.dialog_ok(config.get_localized_string(30131),
|
||||
config.get_localized_string(60066) % new_item.contentTitle) # "ERROR, the movie has NOT been added to the video library")
|
||||
if fallidos == 0:
|
||||
platformtools.dialog_ok(config.get_localized_string(30131),
|
||||
config.get_localized_string(30135) % new_item.contentTitle) # 'has been added to the video library'
|
||||
else:
|
||||
filetools.rmdirtree(path)
|
||||
platformtools.dialog_ok(config.get_localized_string(30131),
|
||||
config.get_localized_string(60066) % new_item.contentTitle) # "ERROR, the movie has NOT been added to the video library")
|
||||
|
||||
|
||||
def add_tvshow(item, channel=None):
|
||||
@@ -1040,7 +1040,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.info("show=#" + item.show + "#")
|
||||
logger.debug("show=#" + item.show + "#")
|
||||
from platformcode.launcher import set_search_temp; set_search_temp(item)
|
||||
|
||||
if item.channel == "downloads":
|
||||
@@ -1073,21 +1073,26 @@ def add_tvshow(item, channel=None):
|
||||
# If the second screen is canceled, the variable "scraper_return" will be False. The user does not want to continue
|
||||
|
||||
item = generictools.update_title(item) # We call the method that updates the title with tmdb.find_and_set_infoLabels
|
||||
if not item: return
|
||||
#if item.tmdb_stat:
|
||||
# del item.tmdb_stat # We clean the status so that it is not recorded in the Video Library
|
||||
|
||||
# Get the episode list
|
||||
# from core.support import dbg;dbg()
|
||||
itemlist = getattr(channel, item.action)(item)
|
||||
if itemlist and not scrapertools.find_single_match(itemlist[0].title, r'(\d+x\d+)'):
|
||||
from platformcode.autorenumber import select_type, renumber, check
|
||||
if itemlist and not scrapertools.find_single_match(itemlist[0].title, r'[Ss]?(\d+)(?:x|_|\s+)[Ee]?[Pp]?(\d+)'):
|
||||
from platformcode.autorenumber import start, check
|
||||
if not check(item):
|
||||
action = item.action
|
||||
select_type(item)
|
||||
item.renumber = True
|
||||
start(item)
|
||||
item.renumber = False
|
||||
item.action = action
|
||||
return add_tvshow(item, channel)
|
||||
if not item.exit:
|
||||
return add_tvshow(item, channel)
|
||||
itemlist = getattr(channel, item.action)(item)
|
||||
else:
|
||||
itemlist = renumber(itemlist)
|
||||
itemlist = getattr(channel, item.action)(item)
|
||||
|
||||
global magnet_caching
|
||||
magnet_caching = False
|
||||
@@ -1112,7 +1117,7 @@ def add_tvshow(item, channel=None):
|
||||
|
||||
else:
|
||||
platformtools.dialog_ok(config.get_localized_string(30131), config.get_localized_string(60070) % item.show)
|
||||
logger.info("%s episodes of series %s have been added to the video library" % (insertados, item.show))
|
||||
logger.debug("%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
|
||||
@@ -1128,7 +1133,7 @@ def add_tvshow(item, channel=None):
|
||||
|
||||
|
||||
def emergency_urls(item, channel=None, path=None, headers={}):
|
||||
logger.info()
|
||||
logger.debug()
|
||||
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.info("file= %s" % file)
|
||||
logger.info("dir= %s" % dir)
|
||||
logger.debug("file= %s" % file)
|
||||
logger.debug("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.info("name=%s" % nameo)
|
||||
logger.debug("name=%s" % nameo)
|
||||
if not name.endswith('/'):
|
||||
logger.info("it's not a directory")
|
||||
logger.debug("it's not a directory")
|
||||
try:
|
||||
(path, filename) = filetools.split(filetools.join(dir, name))
|
||||
logger.info("path=%s" % path)
|
||||
logger.info("name=%s" % name)
|
||||
logger.debug("path=%s" % path)
|
||||
logger.debug("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.info("outfilename=%s" % outfilename)
|
||||
logger.debug("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.info("Error closing .zip " + file)
|
||||
logger.error("Error closing .zip " + file)
|
||||
|
||||
def _createstructure(self, file, dir):
|
||||
self._makedirs(self._listdirs(file), dir)
|
||||
|
||||
Reference in New Issue
Block a user