- completato il supporto ai torrent e aggiunto ilcorsaronero.xyz
- aggiunto supporto agli episodi locali, ovvero poter inserire nella libreria di kodi un misto tra puntate di kod e file scaricati altrove
- le viste ora si salvano di nuovo dal menu laterale, ma rimangono salvate per il tipo di contenuto visualizzato e non per il singolo menu
- ripensato il menu rapido, che ora è più rapido, ridisegnate alcune finestre
This commit is contained in:
marco
2020-05-14 21:26:48 +02:00
parent cdf84d5573
commit a8d5fad1a8
778 changed files with 49736 additions and 40697 deletions
+6 -23
View File
@@ -14,13 +14,6 @@ default_file = dict()
remote_path = 'https://raw.githubusercontent.com/kodiondemand/media/master/'
def is_adult(channel_name):
logger.info("channel_name=" + channel_name)
channel_parameters = get_channel_parameters(channel_name)
return channel_parameters["adult"]
def is_enabled(channel_name):
logger.info("channel_name=" + channel_name)
return get_channel_parameters(channel_name)["active"] and get_channel_setting("enabled", channel=channel_name,
@@ -41,14 +34,8 @@ def get_channel_parameters(channel_name):
channel_parameters["channel"] = channel_parameters.pop("id")
# si no existe el key se declaran valor por defecto para que no de fallos en las funciones que lo llaman
channel_parameters["adult"] = channel_parameters.get("adult", False)
logger.info(channel_parameters["adult"])
if channel_parameters["adult"]:
channel_parameters["update_url"] = channel_parameters.get("update_url", DEFAULT_UPDATE_URL + 'porn/')
else:
channel_parameters["update_url"] = channel_parameters.get("update_url", DEFAULT_UPDATE_URL)
channel_parameters["update_url"] = channel_parameters.get("update_url", DEFAULT_UPDATE_URL)
channel_parameters["language"] = channel_parameters.get("language", ["all"])
## channel_parameters["adult"] = channel_parameters.get("adult", False)
channel_parameters["active"] = channel_parameters.get("active", False)
channel_parameters["include_in_global_search"] = channel_parameters.get("include_in_global_search",
False)
@@ -92,7 +79,6 @@ def get_channel_parameters(channel_name):
logger.error(channel_name + ".json error \n%s" % ex)
channel_parameters = dict()
channel_parameters["channel"] = ""
channel_parameters["adult"] = False
channel_parameters['active'] = False
channel_parameters["language"] = ""
channel_parameters["update_url"] = DEFAULT_UPDATE_URL
@@ -108,14 +94,12 @@ def get_channel_json(channel_name):
try:
channel_path = filetools.join(config.get_runtime_path(), "channels", channel_name + ".json")
if not filetools.isfile(channel_path):
channel_path = filetools.join(config.get_runtime_path(), 'channels', "porn", channel_name + ".json")
channel_path = filetools.join(config.get_runtime_path(), "specials", channel_name + ".json")
if not filetools.isfile(channel_path):
channel_path = filetools.join(config.get_runtime_path(), "specials", channel_name + ".json")
channel_path = filetools.join(config.get_runtime_path(), "servers", channel_name + ".json")
if not filetools.isfile(channel_path):
channel_path = filetools.join(config.get_runtime_path(), "servers", channel_name + ".json")
if not filetools.isfile(channel_path):
channel_path = filetools.join(config.get_runtime_path(), "servers", "debriders",
channel_name + ".json")
channel_path = filetools.join(config.get_runtime_path(), "servers", "debriders",
channel_name + ".json")
if filetools.isfile(channel_path):
# logger.info("channel_data=" + channel_path)
@@ -182,10 +166,9 @@ def get_default_settings(channel_name):
default_file = jsontools.load(filetools.read(default_path))
channel_path = filetools.join(config.get_runtime_path(), 'channels', channel_name + '.json')
adult_path = filetools.join(config.get_runtime_path(), 'channels', 'porn', channel_name + '.json')
# from core.support import dbg; dbg()
if filetools.exists(channel_path) or filetools.exists(adult_path):
if filetools.exists(channel_path):
default_controls = default_file['settings']
default_controls_renumber = default_file['renumber']
channel_json = get_channel_json(channel_name)
+1 -1
View File
@@ -621,7 +621,7 @@ def downloadfileGzipped(url, pathfichero):
else:
tiempofalta = 0
logger.info(sec_to_hms(tiempofalta))
progreso.update(percent, "%.2fMB/%.2fMB (%d%%) %.2f Kb/s %s falta " %
progreso.update(percent, "%.2fMB/%.2fMB (%d%%) %.2f Kb/s %s mancanti " %
(descargadosmb, totalmb, percent, old_div(velocidad, 1024), sec_to_hms(tiempofalta)))
break
except:
+36 -9
View File
@@ -41,12 +41,23 @@ if HTTPTOOLS_DEFAULT_DOWNLOAD_TIMEOUT == 0: HTTPTOOLS_DEFAULT_DOWNLOAD_TIMEOUT =
# Random use of User-Agents, if nad is not specified
HTTPTOOLS_DEFAULT_RANDOM_HEADERS = False
domainCF = list()
channelsCF = ['guardaserieclick', 'casacinema', 'dreamsub', 'ilgeniodellostreaming', 'piratestreaming', 'altadefinizioneclick', 'altadefinizione01_link', 'cineblog01']
otherCF = ['altadefinizione-nuovo.link', 'wstream.video', 'akvideo.stream', 'backin.net', 'vcrypt.net']
for ch in channelsCF:
domainCF.append(urlparse.urlparse(config.get_channel_url(name=ch)).hostname)
domainCF.extend(otherCF)
# old
# domainCF = list()
# channelsCF = ['guardaserieclick', 'ilgeniodellostreaming']
# otherCF = ['akvideo.stream', 'backin.net', 'vcrypt.net']
# for ch in channelsCF:
# domainCF.append(urlparse.urlparse(config.get_channel_url(name=ch)).hostname)
# domainCF.extend(otherCF)
global CF_LIST
CF_LIST = list()
CF_LIST_PATH = os.path.join(config.get_data_path(), "CF_Domains.txt")
if os.path.exists(CF_LIST_PATH):
with open(CF_LIST_PATH, "rb") as CF_File:
CF_LIST = CF_File.read().splitlines()
FORCE_CLOUDSCRAPER_LIST = ['akvideo.stream']
def get_user_agent():
# Returns the global user agent to be used when necessary for the url.
@@ -212,7 +223,7 @@ def show_infobox(info_dict):
def downloadpage(url, **opt):
logger.info()
# logger.info()
"""
Open a url and return the data obtained
@@ -257,9 +268,10 @@ def downloadpage(url, **opt):
"""
url = scrapertools.unescape(url)
domain = urlparse.urlparse(url).netloc
global domainCF
global CF_LIST
CF = False
if domain in domainCF or opt.get('cf', False):
if domain in FORCE_CLOUDSCRAPER_LIST:
from lib import cloudscraper
session = cloudscraper.create_scraper()
CF = True
@@ -267,6 +279,10 @@ def downloadpage(url, **opt):
from lib import requests
session = requests.session()
if domain in CF_LIST or opt.get('CF', False):
url = 'https://web.archive.org/save/' + url
CF = True
if config.get_setting('resolver_dns') and not opt.get('use_requests', False):
from specials import resolverdns
session.mount('https://', resolverdns.CipherSuiteAdapter(domain, CF))
@@ -383,7 +399,18 @@ def downloadpage(url, **opt):
response_code = req.status_code
if req.headers.get('Server', '').startswith('cloudflare') and response_code in [429, 503, 403] and not opt.get('CF', False):
if domain not in CF_LIST:
opt["CF"] = True
with open(CF_LIST_PATH, "a") as CF_File:
CF_File.write("%s\n" % domain)
logger.debug("CF retry... for domain: %s" % domain)
return downloadpage(url, **opt)
response['data'] = req.content if req.content else ''
if CF:
import re
response['data'] = re.sub('["|\']/save/[^"]*(https?://[^"]+)', '"\\1', response['data'])
response['url'] = req.url
if type(response['data']) != str:
+1 -1
View File
@@ -41,7 +41,7 @@ class InfoLabels(dict):
# super(InfoLabels, self).__setitem__('code', value)
super(InfoLabels, self).__setitem__('imdb_id', str(value))
elif name == "mediatype" and value not in ["list", "movie", "tvshow", "season", "episode"]:
elif name == "mediatype" and value not in ["list", "movie", "tvshow", "season", "episode", "music"]:
super(InfoLabels, self).__setitem__('mediatype', 'list')
elif name in ['tmdb_id', 'tvdb_id', 'noscrap_id']:
+7 -5
View File
@@ -6,6 +6,7 @@
import traceback
from platformcode import logger
from inspect import stack
try:
import json
@@ -43,6 +44,7 @@ def load(*args, **kwargs):
except:
logger.error("**NOT** able to load the JSON")
logger.error(traceback.format_exc())
logger.error('ERROR STACK ' + str(stack()[1][3]))
value = {}
return value
@@ -146,7 +148,7 @@ def check_to_backup(data, fname, dict_data):
logger.debug("The file is empty: %s" % fname)
def update_node(dict_node, name_file, node, path=None):
def update_node(dict_node, name_file, node, path=None, silent=False):
"""
actualiza el json_data de un fichero con el diccionario pasado
@@ -162,7 +164,7 @@ def update_node(dict_node, name_file, node, path=None):
@return json_data
@rtype: dict
"""
logger.info()
if not silent: logger.info()
from platformcode import config
from core import filetools
@@ -183,14 +185,14 @@ def update_node(dict_node, name_file, node, path=None):
# es un dict
if dict_data:
if node in dict_data:
logger.debug(" the key exists %s" % node)
if not silent: logger.debug(" the key exists %s" % node)
dict_data[node] = dict_node
else:
logger.debug(" The key does NOT exist %s" % node)
if not silent: logger.debug(" The key does NOT exist %s" % node)
new_dict = {node: dict_node}
dict_data.update(new_dict)
else:
logger.debug(" It is NOT a dict")
if not silent: logger.debug(" It is NOT a dict")
dict_data = {node: dict_node}
json_data = dump(dict_data)
result = filetools.write(fname, json_data)
+57 -46
View File
@@ -6,6 +6,9 @@ import inspect
import os
import re
import sys
from lib.guessit import guessit
PY3 = False
if sys.version_info[0] >= 3: PY3 = True; unicode = str; unichr = chr; long = int
if PY3:
@@ -137,17 +140,6 @@ def regexDbg(item, patron, headers, data=''):
webbrowser.open(url + "/r/" + permaLink)
def scrape2(item, patron = '', listGroups = [], headers="", blacklist="", data="", patronBlock="",
patronNext="", action="findvideos", addVideolibrary = True, typeContentDict={}, typeActionDict={}):
m = re.search(r'(?<!\\|\[)\((?!\?)', patron)
n = 0
while m:
patron = patron[:m.end()] + '?P<' + listGroups[n] + '>' + patron[m.end():]
m = re.search(r'(?<!\\|\[)\((?!\?)', patron)
n += 1
regexDbg(item, patron, headers)
def scrapeLang(scraped, lang, longtitle):
## Aggiunto/modificato per gestire i siti che hanno i video
## in ita e subita delle serie tv nella stessa pagina
@@ -171,7 +163,7 @@ def cleantitle(title):
cleantitle = title.replace('"', "'").replace('×', 'x').replace('', '-').strip()
return cleantitle
def scrapeBlock(item, args, block, patron, headers, action, pagination, debug, typeContentDict, typeActionDict, blacklist, search, pag, function, lang):
def scrapeBlock(item, args, block, patron, headers, action, pagination, debug, typeContentDict, typeActionDict, blacklist, search, pag, function, lang, sceneTitle):
itemlist = []
log("scrapeBlock qui")
if debug:
@@ -240,17 +232,6 @@ def scrapeBlock(item, args, block, patron, headers, action, pagination, debug, t
Type = scraped['type'] if scraped['type'] else ''
plot = cleantitle(scraped["plot"]) if scraped["plot"] else ''
# make formatted Title [longtitle]
s = ' - '
title = episode + (s if episode and title else '') + title
longtitle = title + (s if title and title2 else '') + title2
longtitle = typo(longtitle, 'bold')
longtitle += typo(quality, '_ [] color kod') if quality else ''
longtitle += typo(scraped['size'], '_ [] color kod') if scraped['size'] else ''
longtitle += typo(scraped['seed']+ ' SEEDS', '_ [] color kod') if scraped['seed'] else ''
lang1, longtitle = scrapeLang(scraped, lang, longtitle)
# 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
if item.infoLabels["title"] == scraped["title"]:
@@ -275,6 +256,49 @@ def scrapeBlock(item, args, block, patron, headers, action, pagination, debug, t
if scraped["rating"]:
infolabels['rating'] = scrapertools.decodeHtmlentities(scraped["rating"])
# make formatted Title [longtitle]
s = ' - '
title = episode + (s if episode and title else '') + title
longtitle = title + (s if title and title2 else '') + title2 + '\n'
if sceneTitle:
try:
parsedTitle = guessit(title)
title = longtitle = parsedTitle.get('title', '')
log('TITOLO',title)
if parsedTitle.get('source'):
quality = str(parsedTitle.get('source'))
if parsedTitle.get('screen_size'):
quality += ' ' + str(parsedTitle.get('screen_size', ''))
if not scraped['year']:
infolabels['year'] = parsedTitle.get('year', '')
if parsedTitle.get('episode') and parsedTitle.get('season'):
longtitle = title + s
if type(parsedTitle.get('season')) == list:
longtitle += str(parsedTitle.get('season')[0]) + '-' + str(parsedTitle.get('season')[-1])
else:
longtitle += str(parsedTitle.get('season'))
if type(parsedTitle.get('episode')) == list:
longtitle += 'x' + str(parsedTitle.get('episode')[0]).zfill(2) + '-' + str(parsedTitle.get('episode')[-1]).zfill(2)
else:
longtitle += 'x' + str(parsedTitle.get('episode')).zfill(2)
elif parsedTitle.get('season') and type(parsedTitle.get('season')) == list:
longtitle += s + config.get_localized_string(30140) + " " +str(parsedTitle.get('season')[0]) + '-' + str(parsedTitle.get('season')[-1])
elif parsedTitle.get('season'):
longtitle += s + config.get_localized_string(60027) % str(parsedTitle.get('season'))
if parsedTitle.get('episode_title'):
longtitle += s + parsedTitle.get('episode_title')
except:
log('Error')
longtitle = typo(longtitle, 'bold')
lang1, longtitle = scrapeLang(scraped, lang, longtitle)
longtitle += typo(quality, '_ [] color kod') if quality else ''
longtitle += typo(scraped['size'], '_ [] color kod') if scraped['size'] else ''
longtitle += typo(scraped['seed'] + ' SEEDS', '_ [] color kod') if scraped['seed'] else ''
AC = CT = ''
if typeContentDict:
for name, variants in typeContentDict.items():
@@ -288,7 +312,6 @@ 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()):
it = Item(
channel=item.channel,
@@ -380,6 +403,7 @@ def scrape(func):
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 ''
sceneTitle = args.get('sceneTitle')
pag = item.page if item.page else 1 # pagination
matches = []
@@ -402,7 +426,7 @@ def scrape(func):
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)
typeContentDict, typeActionDict, blacklist, search, pag, function, lang, sceneTitle)
for it in blockItemlist:
if 'lang' in bl:
it.contentLanguage, it.title = scrapeLang(bl, it.contentLanguage, it.title)
@@ -413,7 +437,7 @@ 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)
typeActionDict, blacklist, search, pag, function, lang, sceneTitle)
if 'itemlistHook' in args:
itemlist = args['itemlistHook'](itemlist)
@@ -453,7 +477,7 @@ def scrape(func):
page=pag + 1,
thumbnail=thumb()))
if action != 'play' and function != 'episodios' and 'patronMenu' not in args:
if action != 'play' and function != 'episodios' and 'patronMenu' not in args and item.contentType in ['movie', 'tvshow', 'episode']:
tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True)
from specials import autorenumber
@@ -826,7 +850,6 @@ def match(item_url_string, **args):
match: first match
matches: all the matches
'''
log()
matches = blocks = []
url = None
@@ -839,7 +862,7 @@ def match(item_url_string, **args):
string = args.get('string', False)
# remove scrape arguments
args = dict([(key, val) for key, val in args.items() if key not in ['patron', 'patronBlock', 'patronBlocks', 'debug', 'debugBlock', 'string']])
args = dict([(key, val) for key, val in args.items() if key not in ['patron', 'patronBlock', 'patronBlocks', 'debug', 'debugBlock', 'string']])
# check type of item_url_string
if string:
@@ -927,11 +950,13 @@ def download(itemlist, item, typography='', function_level=1, function=''):
elif item.contentType == 'episode':
from_action = 'findvideos'
title = typo(config.get_localized_string(60356), typography) + ' - ' + item.title
else:
elif item.contentType == 'tvshow':
from_action = 'episodios'
title = typo(config.get_localized_string(60355), typography)
else: # content type does not support download
return itemlist
function = function if function else inspect.stack()[function_level][3]
# function = function if function else inspect.stack()[function_level][3]
contentSerieName=item.contentSerieName if item.contentSerieName else ''
contentTitle=item.contentTitle if item.contentTitle else ''
@@ -1119,21 +1144,7 @@ def controls(itemlist, item, AutoPlay=True, CheckLinks=True, down_load=True, vid
from platformcode.config import get_setting
CL = get_setting('checklinks') or get_setting('checklinks', item.channel)
autoplay_node = jsontools.get_node_from_file('autoplay', 'AUTOPLAY')
channel_node = autoplay_node.get(item.channel, {})
if not channel_node: # non ha mai aperto il menu del canale quindi in autoplay_data.json non c'e la key
try:
channelFile = __import__('channels.' + item.channel, fromlist=["channels.%s" % item.channel])
except:
channelFile = __import__('specials.' + item.channel, fromlist=["specials.%s" % item.channel])
if hasattr(channelFile, 'list_servers') and hasattr(channelFile, 'list_quality'):
autoplay.init(item.channel, channelFile.list_servers, channelFile.list_quality)
autoplay_node = jsontools.get_node_from_file('autoplay', 'AUTOPLAY')
channel_node = autoplay_node.get(item.channel, {})
settings_node = channel_node.get('settings', {})
AP = get_setting('autoplay') or (settings_node['active'] if 'active' in settings_node else False)
HS = config.get_setting('hide_servers') or (settings_node['hide_servers'] if 'hide_server' in settings_node else False)
AP, HS = autoplay.get_channel_AP_HS(item)
if CL and not AP:
if get_setting('checklinks', item.channel):
+2 -2
View File
@@ -826,7 +826,7 @@ class Tmdb(object):
self.busqueda_texto = re.sub('\[\\\?(B|I|COLOR)\s?[^\]]*\]', '', self.texto_buscado).strip()
self.busqueda_tipo = kwargs.get('tipo', '')
self.busqueda_idioma = kwargs.get('idioma_busqueda', def_lang)
self.busqueda_include_adult = kwargs.get('include_adult', False)
# self.busqueda_include_adult = kwargs.get('include_adult', False)
self.busqueda_year = kwargs.get('year', '')
self.busqueda_filtro = kwargs.get('filtro', {})
self.discover = kwargs.get('discover', {})
@@ -978,7 +978,7 @@ class Tmdb(object):
# &include_adult=false&page=1
url = ('http://api.themoviedb.org/3/search/%s?api_key=a1ab8b8669da03637a4b98fa39c39228&query=%s&language=%s'
'&include_adult=%s&page=%s' % (self.busqueda_tipo, text_quote,
self.busqueda_idioma, self.busqueda_include_adult, page))
self.busqueda_idioma, True, page))
if self.busqueda_year:
url += '&year=%s' % self.busqueda_year
+97 -22
View File
@@ -111,7 +111,7 @@ def save_movie(item, silent=False):
# Si llegados a este punto no tenemos titulo, salimos
if not item.contentTitle or not item.channel:
logger.debug("contentTitle NOT FOUND")
return 0, 0, -1 # Salimos sin guardar
return 0, 0, -1, path # Salimos sin guardar
scraper_return = scraper.find_and_set_infoLabels(item)
@@ -123,7 +123,7 @@ def save_movie(item, silent=False):
# TODO de momento si no hay resultado no añadimos nada,
# aunq podriamos abrir un cuadro para introducir el identificador/nombre a mano
logger.debug("NOT FOUND IN SCRAPER OR DO NOT HAVE code")
return 0, 0, -1
return 0, 0, -1, path
_id = item.infoLabels['code'][0]
@@ -158,7 +158,7 @@ def save_movie(item, silent=False):
logger.info("Creating movie directory:" + path)
if not filetools.mkdir(path):
logger.debug("Could not create directory")
return 0, 0, -1
return 0, 0, -1, path
nfo_path = filetools.join(path, "%s [%s].nfo" % (base_name, _id))
strm_path = filetools.join(path, "%s.strm" % base_name)
@@ -227,14 +227,14 @@ def save_movie(item, silent=False):
xbmc_videolibrary.update()
if not silent: p_dialog.close()
return insertados, sobreescritos, fallidos
return insertados, sobreescritos, fallidos, path
# Si llegamos a este punto es por q algo ha fallado
logger.error("Could not save %s in the video library" % item.contentTitle)
if not silent:
p_dialog.update(100, config.get_localized_string(60063), item.contentTitle)
p_dialog.close()
return 0, 0, -1
return 0, 0, -1, path
def update_renumber_options(item, head_nfo, path):
from core import jsontools
@@ -586,6 +586,22 @@ def save_episodes(path, episodelist, serie, silent=False, overwrite=True):
logger.info("There is no episode list, we go out without creating strm")
return 0, 0, 0
# process local episodes
local_episodes_path = ''
nfo_path = filetools.join(path, "tvshow.nfo")
head_nfo, item_nfo = read_nfo(nfo_path)
if item_nfo.update_last:
local_episodes_path = item_nfo.local_episodes_path
elif config.get_setting("local_episodes", "videolibrary"):
done, local_episodes_path = config_local_episodes_path(path, serie.show)
if done < 0:
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())
if local_episodes_path:
process_local_episodes(local_episodes_path, path)
insertados = 0
sobreescritos = 0
fallidos = 0
@@ -671,9 +687,6 @@ def save_episodes(path, episodelist, serie, silent=False, overwrite=True):
except:
t = 0
local_episodelist = get_local_content(path)
last_season_episode = ''
for i, e in enumerate(scraper.sort_episode_list(new_episodelist)):
if not silent:
p_dialog.update(int(math.ceil((i + 1) * t)), config.get_localized_string(60064), e.title)
@@ -695,9 +708,11 @@ def save_episodes(path, episodelist, serie, silent=False, overwrite=True):
nfo_path = filetools.join(path, "%s.nfo" % season_episode)
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')
# 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))
continue
strm_exists = strm_path in ficheros
nfo_exists = nfo_path in ficheros
json_exists = json_path in ficheros
@@ -808,7 +823,8 @@ def save_episodes(path, episodelist, serie, silent=False, overwrite=True):
tvshow_item.infoLabels["title"] = tvshow_item.infoLabels["tvshowtitle"]
if max_sea == high_sea and max_epi == high_epi and (tvshow_item.infoLabels["status"] == "Ended"
or tvshow_item.infoLabels["status"] == "Canceled") and insertados == 0 and fallidos == 0:
or tvshow_item.infoLabels["status"] == "Canceled") and insertados == 0 and fallidos == 0 \
and not tvshow_item.local_episodes_path:
tvshow_item.active = 0 # ... no la actualizaremos más
logger.debug("%s [%s]: serie 'Terminada' o 'Cancelada'. Se desactiva la actualización periódica" % \
(serie.contentSerieName, serie.channel))
@@ -838,19 +854,72 @@ def save_episodes(path, episodelist, serie, silent=False, overwrite=True):
return insertados, sobreescritos, fallidos
def get_local_content(path):
def config_local_episodes_path(path, title, silent=False):
logger.info()
local_episodelist = []
for root, folders, files in filetools.walk(path):
for file in files:
season_episode = scrapertools.get_season_and_episode(file)
if season_episode == "" or filetools.exists(filetools.join(path, "%s.strm" % season_episode)):
continue
local_episodelist.append(season_episode)
local_episodelist = sorted(set(local_episodelist))
local_episodes_path = ''
if not silent:
silent = platformtools.dialog_yesno(config.get_localized_string(30131), config.get_localized_string(80044) % title)
if silent:
if config.is_xbmc() and not config.get_setting("videolibrary_kodi"):
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")
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")
return -2, local_episodes_path
return local_episodelist
if local_episodes_path:
# import artwork
artwork_extensions = ['.jpg', '.jpeg', '.png']
files = filetools.listdir(local_episodes_path)
for file in files:
if os.path.splitext(file)[1] in artwork_extensions:
filetools.copy(filetools.join(local_episodes_path, file), filetools.join(path, file))
return 0, local_episodes_path
def process_local_episodes(local_episodes_path, path):
logger.info()
sub_extensions = ['.srt', '.sub', '.sbv', '.ass', '.idx', '.ssa', '.smi']
artwork_extensions = ['.jpg', '.jpeg', '.png']
extensions = sub_extensions + artwork_extensions
local_episodes_list = []
files_list = []
for root, folders, files in filetools.walk(local_episodes_path):
for file in files:
if os.path.splitext(file)[1] in extensions:
continue
season_episode = scrapertools.get_season_and_episode(file)
if season_episode == "":
continue
local_episodes_list.append(season_episode)
files_list.append(file)
nfo_path = filetools.join(path, "tvshow.nfo")
head_nfo, item_nfo = read_nfo(nfo_path)
# if a local episode has been added, overwrites the strm
for season_episode, file in zip(local_episodes_list, files_list):
if not season_episode in item_nfo.local_episodes_list:
filetools.write(filetools.join(path, season_episode + '.strm'), filetools.join(root, file))
# if a local episode has been removed, deletes the strm
for season_episode in set(item_nfo.local_episodes_list).difference(local_episodes_list):
filetools.remove(filetools.join(path, season_episode + '.strm'))
# updates the local episodes path and list in the nfo
if not local_episodes_list:
item_nfo.local_episodes_path = ''
item_nfo.local_episodes_list = sorted(set(local_episodes_list))
filetools.write(nfo_path, head_nfo + item_nfo.tojson())
def add_movie(item):
@@ -883,12 +952,13 @@ def add_movie(item):
# del item.tmdb_stat #Limpiamos el status para que no se grabe en la Videoteca
new_item = item.clone(action="findvideos")
insertados, sobreescritos, fallidos = save_movie(new_item)
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) # 'se ha añadido a la videoteca'
else:
filetools.rmdirtree(path)
platformtools.dialog_ok(config.get_localized_string(30131),
config.get_localized_string(60066) % new_item.contentTitle) #"ERROR, la pelicula NO se ha añadido a la videoteca")
@@ -968,13 +1038,18 @@ def add_tvshow(item, channel=None):
insertados, sobreescritos, fallidos, path = save_tvshow(item, itemlist)
if not insertados and not sobreescritos and not fallidos:
filetools.rmdirtree(path)
platformtools.dialog_ok(config.get_localized_string(30131), config.get_localized_string(60067) % item.show)
logger.error("La serie %s no se ha podido añadir a la videoteca. No se ha podido obtener ningun episodio" % item.show)
elif fallidos == -1:
filetools.rmdirtree(path)
platformtools.dialog_ok(config.get_localized_string(30131), config.get_localized_string(60068) % item.show)
logger.error("La serie %s no se ha podido añadir a la videoteca" % item.show)
elif fallidos == -2:
filetools.rmdirtree(path)
elif fallidos > 0:
platformtools.dialog_ok(config.get_localized_string(30131), config.get_localized_string(60069) % item.show)
logger.error("No se han podido añadir %s episodios de la serie %s a la videoteca" % (fallidos, item.show))