riorganizzazione cartelle
This commit is contained in:
@@ -0,0 +1,285 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from core import filetools, jsontools
|
||||
from core.item import Item
|
||||
from platformcode import config, logger, platformtools
|
||||
from time import sleep
|
||||
|
||||
__channel__ = "autoplay"
|
||||
|
||||
PLAYED = False
|
||||
|
||||
quality_list = ['4k', '2160p', '2160', '4k2160p', '4k2160', '4k 2160p', '4k 2160', '2k',
|
||||
'fullhd', 'fullhd 1080', 'fullhd 1080p', 'full hd', 'full hd 1080', 'full hd 1080p', 'hd1080', 'hd1080p', 'hd 1080', 'hd 1080p', '1080', '1080p',
|
||||
'hd', 'hd720', 'hd720p', 'hd 720', 'hd 720p', '720', '720p', 'hdtv',
|
||||
'sd', '480p', '480', '360p', '360', '240p', '240',
|
||||
'default']
|
||||
|
||||
|
||||
def start(itemlist, item):
|
||||
'''
|
||||
Main method from which the links are automatically reproduced
|
||||
- In case the option to activate it will use the options defined by the user.
|
||||
- Otherwise it will try to reproduce any link that has the preferred language.
|
||||
|
||||
:param itemlist: list (list of items ready to play, ie with action = 'play')
|
||||
:param item: item (the main item of the channel)
|
||||
:return: try to auto-reproduce, in case of failure it returns the itemlist that it received in the beginning
|
||||
'''
|
||||
|
||||
if item.global_search:
|
||||
return itemlist
|
||||
logger.info()
|
||||
|
||||
global PLAYED
|
||||
PLAYED = False
|
||||
|
||||
base_item = item
|
||||
|
||||
if not config.is_xbmc():
|
||||
return itemlist
|
||||
|
||||
if config.get_setting('autoplay'):
|
||||
url_list_valid = []
|
||||
autoplay_list = []
|
||||
autoplay_b = []
|
||||
favorite_quality = []
|
||||
favorite_servers = []
|
||||
blacklisted_servers = config.get_setting("black_list", server='servers')
|
||||
if not blacklisted_servers: blacklisted_servers = []
|
||||
|
||||
from core import servertools
|
||||
servers_list = list(servertools.get_servers_list().items())
|
||||
for server, server_parameters in servers_list:
|
||||
if config.get_setting('favorites_servers_list', server=server):
|
||||
favorite_servers.append(server.lower())
|
||||
|
||||
if not favorite_servers:
|
||||
config.set_setting('favorites_servers_list', [], server='servers')
|
||||
favorite_servers = []
|
||||
else:
|
||||
favorite_servers = list(set(favorite_servers) - set(blacklisted_servers))
|
||||
|
||||
# Save the current value of "Action and Player Mode" in preferences
|
||||
user_config_setting_action = config.get_setting("default_action")
|
||||
user_config_setting_player = config.get_setting("player_mode")
|
||||
|
||||
# Enable the "View in high quality" action (if the server returns more than one quality, eg gdrive)
|
||||
if not user_config_setting_action: config.set_setting("default_action", 2)
|
||||
|
||||
if user_config_setting_player != 0: config.set_setting("player_mode", 0)
|
||||
|
||||
# Priorities when ordering itemlist:
|
||||
# 0: Servers and qualities
|
||||
# 1: Qualities and servers
|
||||
# 2: Servers only
|
||||
# 3: Only qualities
|
||||
# 4: Do not order
|
||||
if config.get_setting('favorites_servers') and favorite_servers and config.get_setting('default_action'):
|
||||
priority = 0 # 0: Servers and qualities or 1: Qualities and servers
|
||||
elif config.get_setting('favorites_servers') and favorite_servers:
|
||||
priority = 2 # Servers only
|
||||
elif config.get_setting('default_action'):
|
||||
priority = 3 # Only qualities
|
||||
else:
|
||||
priority = 4 # Do not order
|
||||
|
||||
if config.get_setting('default_action') == 1:
|
||||
quality_list.reverse()
|
||||
favorite_quality = quality_list
|
||||
|
||||
for item in itemlist:
|
||||
autoplay_elem = dict()
|
||||
b_dict = dict()
|
||||
|
||||
# We check that it is a video item
|
||||
if 'server' not in item:
|
||||
continue
|
||||
|
||||
if item.server.lower() in blacklisted_servers:
|
||||
continue
|
||||
|
||||
# If it does not have a defined quality, it assigns a 'default' quality.
|
||||
if item.quality.lower() not in quality_list:
|
||||
item.quality = 'default'
|
||||
# The list for custom settings is created
|
||||
|
||||
if priority < 2: # 0: Servers and qualities or 1: Qualities and servers
|
||||
|
||||
# if the server and the quality are not in the favorites lists or the url is repeated, we discard the item
|
||||
if item.server.lower() not in favorite_servers or item.quality.lower() not in favorite_quality or item.url in url_list_valid:
|
||||
item.type_b = True
|
||||
item.play_from = base_item.play_from
|
||||
b_dict['videoitem']= item
|
||||
autoplay_b.append(b_dict)
|
||||
continue
|
||||
autoplay_elem["indice_server"] = favorite_servers.index(item.server.lower())
|
||||
autoplay_elem["indice_quality"] = favorite_quality.index(item.quality.lower())
|
||||
|
||||
elif priority == 2: # Servers only
|
||||
|
||||
# if the server is not in the favorites list or the url is repeated, we discard the item
|
||||
if item.server.lower() not in favorite_servers or item.url in url_list_valid:
|
||||
item.type_b = True
|
||||
item.play_from = base_item.play_from
|
||||
b_dict['videoitem'] = item
|
||||
autoplay_b.append(b_dict)
|
||||
continue
|
||||
autoplay_elem["indice_server"] = favorite_servers.index(item.server.lower())
|
||||
|
||||
elif priority == 3: # Only qualities
|
||||
|
||||
# if the quality is not in the favorites list or the url is repeated, we discard the item
|
||||
if item.quality.lower() not in favorite_quality or item.url in url_list_valid:
|
||||
item.type_b = True
|
||||
item.play_from = base_item.play_from
|
||||
b_dict['videoitem'] = item
|
||||
autoplay_b.append(b_dict)
|
||||
continue
|
||||
autoplay_elem["indice_quality"] = favorite_quality.index(item.quality.lower())
|
||||
|
||||
else: # Do not order
|
||||
|
||||
# if the url is repeated, we discard the item
|
||||
item.play_from = base_item.play_from
|
||||
if item.url in url_list_valid:
|
||||
continue
|
||||
|
||||
# If the item reaches here we add it to the list of valid urls and to autoplay_list
|
||||
url_list_valid.append(item.url)
|
||||
item.plan_b=True
|
||||
item.play_from = base_item.play_from
|
||||
autoplay_elem['videoitem'] = item
|
||||
autoplay_list.append(autoplay_elem)
|
||||
|
||||
# We order according to priority
|
||||
if priority == 0: autoplay_list.sort(key=lambda orden: (orden['indice_quality'], orden['indice_server'])) # Servers and qualities
|
||||
elif priority == 1: autoplay_list.sort(key=lambda orden: (orden['indice_quality'], orden['indice_server'])) # Qualities and servers
|
||||
elif priority == 2: autoplay_list.sort(key=lambda orden: (orden['indice_server'])) # Servers only
|
||||
elif priority == 3: autoplay_list.sort(key=lambda orden: (orden['indice_quality'])) # Only qualities
|
||||
|
||||
# if quality priority is active
|
||||
if priority == 0 and config.get_setting('quality_priority'):
|
||||
max_quality = autoplay_list[0]["indice_quality"] if autoplay_list and "indice_quality" in autoplay_list[0] else 0
|
||||
for n, item in enumerate(itemlist):
|
||||
if 'server' not in item:
|
||||
continue
|
||||
|
||||
if item.server.lower() in blacklisted_servers:
|
||||
continue
|
||||
|
||||
# If it does not have a defined quality, it assigns a 'default' quality.
|
||||
if item.quality == '':
|
||||
item.quality = 'default'
|
||||
|
||||
if favorite_quality.index(item.quality.lower()) < max_quality:
|
||||
item.type_b = False
|
||||
autoplay_elem["indice_server"] = n
|
||||
autoplay_elem["indice_quality"] = favorite_quality.index(item.quality.lower())
|
||||
autoplay_elem['videoitem'] = item
|
||||
autoplay_list.append(autoplay_elem)
|
||||
autoplay_list.sort(key=lambda orden: (orden['indice_quality'], orden['indice_server']))
|
||||
|
||||
# Plan b is prepared, in case it is active the non-favorite elements are added at the end
|
||||
# try: plan_b = settings_node['plan_b']
|
||||
# except:
|
||||
plan_b = True
|
||||
text_b = ''
|
||||
if plan_b: autoplay_list.extend(autoplay_b)
|
||||
# If there are elements in the autoplay list, an attempt is made to reproduce each element, until one is found or all fail.
|
||||
|
||||
if autoplay_list or (plan_b and autoplay_b):
|
||||
|
||||
max_intentos = 5
|
||||
max_intentos_servers = {}
|
||||
|
||||
# If something is playing it stops playing
|
||||
if platformtools.is_playing():
|
||||
platformtools.stop_video()
|
||||
|
||||
for autoplay_elem in autoplay_list:
|
||||
play_item = Item
|
||||
channel_id = autoplay_elem['videoitem'].channel
|
||||
if autoplay_elem['videoitem'].channel == 'videolibrary':
|
||||
channel_id = autoplay_elem['videoitem'].contentChannel
|
||||
|
||||
# If it is not a favorite element if you add the text plan b
|
||||
if autoplay_elem['videoitem'].type_b:
|
||||
text_b = '(Plan B)'
|
||||
if not platformtools.is_playing() and not PLAYED:
|
||||
videoitem = autoplay_elem['videoitem']
|
||||
if videoitem.server.lower() not in max_intentos_servers:
|
||||
max_intentos_servers[videoitem.server.lower()] = max_intentos
|
||||
|
||||
# If the maximum number of attempts of this server have been reached, we jump to the next
|
||||
if max_intentos_servers[videoitem.server.lower()] == 0:
|
||||
continue
|
||||
|
||||
lang = " "
|
||||
if hasattr(videoitem, 'language') and videoitem.language != "":
|
||||
lang = " '%s' " % videoitem.language
|
||||
name = servername(videoitem.server)
|
||||
platformtools.dialog_notification("AutoPlay %s" %text_b, "%s%s%s" % (name, lang, videoitem.quality.upper()), sound=False)
|
||||
|
||||
# Try to play the links If the channel has its own play method, use it
|
||||
try: channel = __import__('channels.%s' % channel_id, None, None, ["channels.%s" % channel_id])
|
||||
except: channel = __import__('specials.%s' % channel_id, None, None, ["specials.%s" % channel_id])
|
||||
if hasattr(channel, 'play'):
|
||||
resolved_item = getattr(channel, 'play')(videoitem)
|
||||
if len(resolved_item) > 0:
|
||||
if isinstance(resolved_item[0], list): videoitem.video_urls = resolved_item
|
||||
else: videoitem = resolved_item[0]
|
||||
|
||||
# If not directly reproduce and mark as seen
|
||||
# Check if the item comes from the video library
|
||||
try:
|
||||
if base_item.contentChannel == 'videolibrary' or base_item.nfo:
|
||||
# Fill the video with the data of the main item and play
|
||||
play_item = base_item.clone(**videoitem.__dict__)
|
||||
platformtools.play_video(play_item, autoplay=True)
|
||||
else:
|
||||
# If it doesn't come from the video library, just play
|
||||
platformtools.play_video(videoitem, autoplay=True)
|
||||
except:
|
||||
pass
|
||||
sleep(3)
|
||||
try:
|
||||
if platformtools.is_playing():
|
||||
PLAYED = True
|
||||
break
|
||||
except:
|
||||
logger.debug(str(len(autoplay_list)))
|
||||
|
||||
# If we have come this far, it is because it could not be reproduced
|
||||
max_intentos_servers[videoitem.server.lower()] -= 1
|
||||
|
||||
# If the maximum number of attempts of this server has been reached, ask if we want to continue testing or ignore it.
|
||||
if max_intentos_servers[videoitem.server.lower()] == 0:
|
||||
text = config.get_localized_string(60072) % name
|
||||
if not platformtools.dialog_yesno("AutoPlay", text, config.get_localized_string(60073)):
|
||||
max_intentos_servers[videoitem.server.lower()] = max_intentos
|
||||
|
||||
# If there are no items in the list, it is reported
|
||||
if autoplay_elem == autoplay_list[-1]:
|
||||
platformtools.dialog_notification('AutoPlay', config.get_localized_string(60072) % name)
|
||||
|
||||
else:
|
||||
platformtools.dialog_notification(config.get_localized_string(60074), config.get_localized_string(60075))
|
||||
|
||||
# Restore if necessary the previous value of "Action and Player Mode" in preferences
|
||||
if not user_config_setting_action: config.set_setting("default_action", user_config_setting_action)
|
||||
if user_config_setting_player != 0: config.set_setting("player_mode", user_config_setting_player)
|
||||
|
||||
return itemlist
|
||||
|
||||
|
||||
def play_multi_channel(item, itemlist):
|
||||
logger.info()
|
||||
start(itemlist, item)
|
||||
|
||||
|
||||
def servername(server):
|
||||
from core.servertools import translate_server_name
|
||||
path = filetools.join(config.get_runtime_path(), 'servers', server.lower() + '.json')
|
||||
name = jsontools.load(open(path, "r").read())['name'].upper()
|
||||
return translate_server_name(name)
|
||||
@@ -0,0 +1,567 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# --------------------------------------------------------------------------------
|
||||
# autorenumber - Rinomina Automaticamente gli Episodi
|
||||
# --------------------------------------------------------------------------------
|
||||
|
||||
'''
|
||||
USO:
|
||||
1) utilizzare autorenumber.renumber(itemlist) nelle le funzioni peliculas e similari per aggiungere il menu contestuale
|
||||
2) utilizzare autorenumber.renumber(itemlist, item, typography) nella funzione episodios
|
||||
|
||||
3) Aggiungere le seguinti stringhe nel json del canale (per attivare la configurazione di autonumerazione del canale)
|
||||
{
|
||||
"id": "autorenumber",
|
||||
"type": "bool",
|
||||
"label": "@70712",
|
||||
"default": false,
|
||||
"enabled": true,
|
||||
"visible": true
|
||||
},
|
||||
{
|
||||
"id": "autorenumber_mode",
|
||||
"type": "bool",
|
||||
"label": "@70688",
|
||||
"default": false,
|
||||
"enabled": true,
|
||||
"visible": "eq(-1,true)"
|
||||
}
|
||||
'''
|
||||
|
||||
try:
|
||||
import xbmcgui
|
||||
except:
|
||||
xbmcgui = None
|
||||
import re, base64, json, inspect
|
||||
from core import jsontools, tvdb, scrapertools, filetools
|
||||
from core.support import typo, info
|
||||
from platformcode import config, platformtools
|
||||
|
||||
TAG_TVSHOW_RENUMERATE = "TVSHOW_AUTORENUMBER"
|
||||
TAG_ID = "ID"
|
||||
TAG_SEASON = "Season"
|
||||
TAG_EPISODE = "Episode"
|
||||
TAG_SPECIAL = "Special"
|
||||
TAG_MODE = "Mode"
|
||||
TAG_EPLIST = "EpList"
|
||||
TAG_CHECK = "ReCheck"
|
||||
TAG_SPLIST = "SpList"
|
||||
TAG_TYPE = "Type"
|
||||
|
||||
|
||||
def renumber(itemlist, item='', typography=''):
|
||||
info()
|
||||
dict_series = load(itemlist[0]) if len(itemlist) > 0 else {}
|
||||
|
||||
if item:
|
||||
# from core.support import dbg;dbg()
|
||||
item.channel = item.from_channel if item.from_channel else item.channel
|
||||
title = item.fulltitle.rstrip()
|
||||
already_renumbered = scrapertools.find_single_match(itemlist[0].title, r'(\d+\D\d+)')
|
||||
if already_renumbered :
|
||||
return itemlist
|
||||
elif item.channel in item.channel_prefs and TAG_TVSHOW_RENUMERATE in item.channel_prefs[item.channel] and title not in dict_series:
|
||||
from core.videolibrarytools import check_renumber_options
|
||||
from specials.videolibrary import update_videolibrary
|
||||
check_renumber_options(item)
|
||||
update_videolibrary(item)
|
||||
|
||||
elif inspect.stack()[2][3] == 'find_episodes':
|
||||
return itemlist
|
||||
|
||||
elif title in dict_series and TAG_ID in dict_series[title]:
|
||||
ID = dict_series[title][TAG_ID]
|
||||
Episode = dict_series[title][TAG_EPISODE]
|
||||
Season = dict_series[title][TAG_SEASON] if TAG_SEASON in dict_series[title] else ''
|
||||
Mode = dict_series[title][TAG_MODE] if TAG_MODE in dict_series[title] else False
|
||||
Type = dict_series[title][TAG_TYPE] if TAG_TYPE in dict_series[title] else 'auto'
|
||||
|
||||
renumeration(itemlist, item, typography, dict_series, ID, Season, Episode, Mode, title, Type)
|
||||
|
||||
else:
|
||||
if config.get_setting('autorenumber', item.channel):
|
||||
config_item(item, itemlist, typography, True)
|
||||
else:
|
||||
return itemlist
|
||||
|
||||
else:
|
||||
for item in itemlist:
|
||||
title = item.fulltitle.rstrip()
|
||||
if title in dict_series and TAG_ID in dict_series[title]:
|
||||
ID = dict_series[title][TAG_ID]
|
||||
exist = True
|
||||
else:
|
||||
exist = False
|
||||
|
||||
if item.contentType != 'movie':
|
||||
if item.context:
|
||||
context2 = item.context
|
||||
item.show = item.fulltitle = title
|
||||
item.context = context(exist) + context2
|
||||
else:
|
||||
item.show = item.fulltitle = title
|
||||
item.context = context(exist)
|
||||
|
||||
|
||||
def config_item(item, itemlist=[], typography='', active=False):
|
||||
info()
|
||||
# Configurazione Automatica, Tenta la numerazione Automatica degli episodi
|
||||
title = item.fulltitle.rstrip()
|
||||
|
||||
dict_series = load(item)
|
||||
ID = dict_series[title][TAG_ID] if title in dict_series and TAG_ID in dict_series[title] else ''
|
||||
|
||||
# Pulizia del Titolo
|
||||
if any( word in title.lower() for word in ['specials', 'speciali']):
|
||||
title = re.sub(r'\sspecials|\sspeciali', '', title.lower())
|
||||
tvdb.find_and_set_infoLabels(item)
|
||||
elif not item.infoLabels['tvdb_id']:
|
||||
item.contentSerieName= title.rstrip('123456789 ')
|
||||
tvdb.find_and_set_infoLabels(item)
|
||||
|
||||
if not ID and active:
|
||||
if item.infoLabels['tvdb_id']:
|
||||
ID = item.infoLabels['tvdb_id']
|
||||
dict_renumerate = {TAG_ID: ID}
|
||||
dict_series[title] = dict_renumerate
|
||||
# Trova La Stagione
|
||||
if any(word in title.lower() for word in ['specials', 'speciali']):
|
||||
dict_renumerate[TAG_SEASON] = '0'
|
||||
elif RepresentsInt(title.split()[-1]):
|
||||
dict_renumerate[TAG_SEASON] = title.split()[-1]
|
||||
else: dict_renumerate[TAG_SEASON] = '1'
|
||||
dict_renumerate[TAG_EPISODE] = ''
|
||||
write(item, dict_series)
|
||||
return renumber(itemlist, item, typography)
|
||||
else:
|
||||
return itemlist
|
||||
|
||||
else:
|
||||
return renumber(itemlist, item, typography)
|
||||
|
||||
|
||||
def semiautomatic_config_item(item):
|
||||
info()
|
||||
# Configurazione Semi Automatica, utile in caso la numerazione automatica fallisca
|
||||
|
||||
tvdb.find_and_set_infoLabels(item)
|
||||
item.channel = item.from_channel if item.from_channel else item.channel
|
||||
dict_series = load(item)
|
||||
title = item.fulltitle.rstrip()
|
||||
|
||||
# Trova l'ID della serie
|
||||
while not item.infoLabels['tvdb_id']:
|
||||
try:
|
||||
item.show = platformtools.dialog_input(default=item.show, heading=config.get_localized_string(30112)) # <- Enter title to search
|
||||
tvdb.find_and_set_infoLabels(item)
|
||||
except:
|
||||
heading = config.get_localized_string(70704) # <- TMDB ID (0 to cancel)
|
||||
info = platformtools.dialog_numeric(0, heading)
|
||||
item.infoLabels['tvdb_id'] = '0' if info == '' else info
|
||||
|
||||
|
||||
if item.infoLabels['tvdb_id']:
|
||||
ID = item.infoLabels['tvdb_id']
|
||||
dict_renumerate = {TAG_ID: ID}
|
||||
dict_series[title] = dict_renumerate
|
||||
|
||||
# Trova la Stagione
|
||||
if any( word in title.lower() for word in ['specials', 'speciali'] ):
|
||||
heading = config.get_localized_string(70686) # <- Enter the number of the starting season (for specials)
|
||||
season = platformtools.dialog_numeric(0, heading, '0')
|
||||
dict_renumerate[TAG_SEASON] = season
|
||||
elif RepresentsInt(title.split()[-1]):
|
||||
heading = config.get_localized_string(70686) # <- Enter the number of the starting season (for season > 1)
|
||||
season = platformtools.dialog_numeric(0, heading, title.split()[-1])
|
||||
dict_renumerate[TAG_SEASON] = season
|
||||
else:
|
||||
heading = config.get_localized_string(70686) # <- Enter the number of the starting season (for season 1)
|
||||
season = platformtools.dialog_numeric(0, heading, '1')
|
||||
dict_renumerate[TAG_SEASON] = season
|
||||
|
||||
mode = platformtools.dialog_yesno(config.get_localized_string(70687), config.get_localized_string(70688), nolabel=config.get_localized_string(30023), yeslabel=config.get_localized_string(30022))
|
||||
if mode == True:
|
||||
dict_renumerate[TAG_MODE] = False
|
||||
|
||||
if TAG_SPECIAL in dict_series[title]:
|
||||
specials = dict_renumerate[TAG_SPECIAL]
|
||||
else:
|
||||
specials = []
|
||||
|
||||
write(item, dict_series)
|
||||
_list = []
|
||||
|
||||
itemlist = find_episodes(item)
|
||||
for item in itemlist:
|
||||
Title = re.sub(r'\d+x\d+ - ', '', item.title)
|
||||
if item.action == 'findvideos':
|
||||
_list.append(Title)
|
||||
|
||||
selected = platformtools.dialog_multiselect(config.get_localized_string(70734), _list)
|
||||
# if len(selected) > 0:
|
||||
for select in selected:
|
||||
specials.append(int(scrapertools.find_single_match(_list[select], r'(\d+)')))
|
||||
dict_renumerate[TAG_SPECIAL] = specials
|
||||
|
||||
dict_renumerate[TAG_MODE] = False
|
||||
|
||||
dict_renumerate[TAG_TYPE] = 'auto'
|
||||
dict_renumerate[TAG_EPISODE] = ''
|
||||
write(item, dict_series)
|
||||
# xbmc.executebuiltin("Container.Refresh")
|
||||
|
||||
else:
|
||||
message = config.get_localized_string(60444)
|
||||
heading = item.fulltitle.strip()
|
||||
platformtools.dialog_notification(heading, message)
|
||||
|
||||
|
||||
def renumeration (itemlist, item, typography, dict_series, ID, Season, Episode, Mode, Title, Type):
|
||||
|
||||
# Se ID è 0 salta la rinumerazione
|
||||
if ID == '0':
|
||||
return itemlist
|
||||
|
||||
# Numerazione per gli Speciali
|
||||
elif Season == '0':
|
||||
EpisodeDict = {}
|
||||
for item in itemlist:
|
||||
if config.get_localized_string(30992) not in item.title:
|
||||
number = scrapertools.find_single_match(item.title, r'\d+')
|
||||
item.title = typo('0x' + number + ' - ', typography) + item.title
|
||||
|
||||
|
||||
# Usa la lista degli Episodi se esiste nel Json
|
||||
|
||||
elif Episode:
|
||||
EpisodeDict = json.loads(base64.b64decode(Episode))
|
||||
|
||||
# Controlla che la lista egli Episodi sia della stessa lunghezza di Itemlist
|
||||
if EpisodeDict == 'none':
|
||||
return error(itemlist)
|
||||
if Type == 'manual' and len(EpisodeDict) < len(itemlist):
|
||||
EpisodeDict = manual_renumeration(item, True)
|
||||
if len(EpisodeDict) >= len(itemlist) and scrapertools.find_single_match(itemlist[0].title, r'\d+') in EpisodeDict:
|
||||
for item in itemlist:
|
||||
if config.get_localized_string(30992) not in item.title:
|
||||
number = scrapertools.find_single_match(item.title, r'\d+')
|
||||
number = int(number) # if number !='0': number.lstrip('0')
|
||||
item.title = typo(EpisodeDict[str(number)] + ' - ', typography) + item.title
|
||||
else:
|
||||
make_list(itemlist, item, typography, dict_series, ID, Season, Episode, Mode, Title)
|
||||
|
||||
else:
|
||||
make_list(itemlist, item, typography, dict_series, ID, Season, Episode, Mode, Title)
|
||||
|
||||
|
||||
def manual_renumeration(item, modify=False):
|
||||
info()
|
||||
_list = []
|
||||
if item.from_channel: item.channel = item.from_channel
|
||||
title = item.fulltitle.rstrip()
|
||||
|
||||
dict_series = load(item)
|
||||
|
||||
if title not in dict_series: dict_series[title] = {}
|
||||
|
||||
if TAG_EPISODE in dict_series[title] and dict_series[title][TAG_EPISODE]:
|
||||
EpisodeDict = json.loads(base64.b64decode(dict_series[title][TAG_EPISODE]))
|
||||
del dict_series[title][TAG_EPISODE]
|
||||
else: EpisodeDict = {}
|
||||
|
||||
if TAG_EPLIST in dict_series[title]: del dict_series[title][TAG_EPLIST]
|
||||
if TAG_MODE in dict_series[title]: del dict_series[title][TAG_MODE]
|
||||
if TAG_CHECK in dict_series[title]: del dict_series[title][TAG_CHECK]
|
||||
if TAG_SEASON in dict_series[title]: del dict_series[title][TAG_SEASON]
|
||||
if TAG_SPECIAL in dict_series[title]: del dict_series[title][TAG_SPECIAL]
|
||||
dict_series[title][TAG_TYPE] = 'manual'
|
||||
write(item, dict_series)
|
||||
|
||||
if TAG_ID not in dict_series[title] or (TAG_ID in dict_series[title] and not dict_series[title][TAG_ID]):
|
||||
tvdb.find_and_set_infoLabels(item)
|
||||
|
||||
# Trova l'ID della serie
|
||||
while not item.infoLabels['tvdb_id']:
|
||||
try:
|
||||
item.show = platformtools.dialog_input(default=item.show, heading=config.get_localized_string(30112)) # <- Enter title to search
|
||||
tvdb.find_and_set_infoLabels(item)
|
||||
except:
|
||||
heading = config.get_localized_string(70704) # <- TMDB ID (0 to cancel)
|
||||
info = platformtools.dialog_numeric(0, heading)
|
||||
item.infoLabels['tvdb_id'] = '0' if info == '' else info
|
||||
|
||||
if item.infoLabels['tvdb_id']:
|
||||
ID = item.infoLabels['tvdb_id']
|
||||
dict_renumerate = {TAG_ID: ID}
|
||||
dict_series[title] = dict_renumerate
|
||||
|
||||
itemlist = find_episodes(item)
|
||||
for item in itemlist:
|
||||
Title = re.sub(r'\d+x\d+ - ', '', item.title)
|
||||
if modify == True:
|
||||
ep = int(scrapertools.find_single_match(Title, r'(\d+)'))
|
||||
if item.action == 'findvideos' and str(ep) not in EpisodeDict:
|
||||
_list.append(Title)
|
||||
else:
|
||||
if item.action == 'findvideos':
|
||||
_list.append(Title)
|
||||
|
||||
count = 1
|
||||
preselect = platformtools.dialog_select(config.get_localized_string(70732),[typo(config.get_localized_string(70518),'bold'),typo(config.get_localized_string(70519),'bold')])
|
||||
selection = []
|
||||
if preselect == 0:
|
||||
for i in _list:
|
||||
selection.append(_list.index(i))
|
||||
while len(_list) > 0:
|
||||
selected = platformtools.dialog_multiselect(config.get_localized_string(70734), _list, preselect=selection)
|
||||
if selected == None: break
|
||||
season = ''
|
||||
while not season:
|
||||
season = platformtools.dialog_numeric(0, config.get_localized_string(70733))
|
||||
for select in selected:
|
||||
ep = int(scrapertools.find_single_match(_list[select], r'(\d+)'))
|
||||
if season == '0':
|
||||
episode = ''
|
||||
while not episode:
|
||||
episode = platformtools.dialog_numeric(0, config.get_localized_string(70735) % _list[select] )
|
||||
EpisodeDict[str(ep)] = '%sx%s' %(season, episode.zfill(2))
|
||||
else:
|
||||
EpisodeDict[str(ep)] = '%sx%s' %(season, str(count).zfill(2))
|
||||
count += 1
|
||||
|
||||
for select in reversed(selected):
|
||||
del _list[select]
|
||||
|
||||
|
||||
dict_series[title][TAG_TYPE] = 'manual'
|
||||
EpisodeDict = base64.b64encode(json.dumps(EpisodeDict).encode())
|
||||
dict_series[title][TAG_EPISODE] = EpisodeDict.decode()
|
||||
write(item, dict_series)
|
||||
# xbmc.executebuiltin("Container.Refresh")
|
||||
if modify == True:
|
||||
return json.loads(base64.b64decode(EpisodeDict))
|
||||
|
||||
|
||||
def delete_renumeration(item):
|
||||
info()
|
||||
if item.from_channel: item.channel = item.from_channel
|
||||
title = item.fulltitle.rstrip()
|
||||
|
||||
dict_series = load(item)
|
||||
if title in dict_series: del dict_series[title]
|
||||
write(item, dict_series)
|
||||
|
||||
|
||||
def make_list(itemlist, item, typography, dict_series, ID, Season, Episode, Mode, title):
|
||||
info()
|
||||
exist = True
|
||||
item.infoLabels['tvdb_id'] = ID
|
||||
tvdb.set_infoLabels_item(item)
|
||||
FirstOfSeason= 0
|
||||
|
||||
EpisodeDict = json.loads(base64.b64decode(Episode)) if Episode else {}
|
||||
Special = dict_series[title][TAG_SPECIAL] if TAG_SPECIAL in dict_series[title] else []
|
||||
EpList = json.loads(base64.b64decode(dict_series[title][TAG_EPLIST])) if TAG_EPLIST in dict_series[title] else []
|
||||
Pages = dict_series[title][TAG_CHECK] if TAG_CHECK in dict_series[title] else [1]
|
||||
|
||||
# Ricava Informazioni da TVDB
|
||||
checkpages = []
|
||||
check = True
|
||||
Page = Pages[-1]
|
||||
|
||||
while exist:
|
||||
if check:
|
||||
for page in Pages:
|
||||
data = tvdb.otvdb_global.get_list_episodes(ID,page)
|
||||
for episodes in data['data']:
|
||||
if episodes['firstAired'] and [episodes['firstAired'], episodes['airedSeason'], episodes['airedEpisodeNumber']] not in EpList:
|
||||
EpList.append([episodes['firstAired'], episodes['airedSeason'], episodes['airedEpisodeNumber']])
|
||||
else:
|
||||
if page not in checkpages:
|
||||
checkpages.append(page)
|
||||
check = False
|
||||
|
||||
data = tvdb.otvdb_global.get_list_episodes(ID,Page)
|
||||
if data:
|
||||
Page = Page + 1
|
||||
for episodes in data['data']:
|
||||
if episodes['firstAired'] and [episodes['firstAired'], episodes['airedSeason'], episodes['airedEpisodeNumber']] not in EpList:
|
||||
EpList.append([episodes['firstAired'], episodes['airedSeason'], episodes['airedEpisodeNumber']])
|
||||
else:
|
||||
if page not in checkpages:
|
||||
checkpages.append(Page -1)
|
||||
exist = False
|
||||
|
||||
EpList.sort()
|
||||
|
||||
dict_series[title][TAG_CHECK] = checkpages
|
||||
EpList = base64.b64encode(json.dumps(EpList).encode())
|
||||
dict_series[title][TAG_EPLIST] = EpList.decode()
|
||||
write(item, dict_series)
|
||||
|
||||
# Crea Dizionari per la numerazione
|
||||
if EpList:
|
||||
EpList = json.loads(base64.b64decode(dict_series[title][TAG_EPLIST]))
|
||||
specials = []
|
||||
regular = {}
|
||||
complete = {}
|
||||
allep = 1
|
||||
ep = 1
|
||||
specialep = 0
|
||||
for episode in EpList:
|
||||
complete[allep] = [str(episode[1]) + 'x' + str(episode[2]), episode[0]]
|
||||
if episode[1] == 0:
|
||||
specials.append(allep)
|
||||
specialep = specialep + 1
|
||||
else:
|
||||
regular[ep] = [str(episode[1]) + 'x' + str(episode[2]), str(episode[0]), allep - 1]
|
||||
ep = ep + 1
|
||||
allep = allep + 1
|
||||
|
||||
# seleziona l'Episodio di partenza
|
||||
if int(Season) > 1:
|
||||
for numbers, data in regular.items():
|
||||
if data[0] == Season + 'x1':
|
||||
FirstOfSeason = numbers - 1
|
||||
|
||||
if Mode == True: Special = specials
|
||||
|
||||
addiction = 0
|
||||
for item in itemlist:
|
||||
# Otiene Numerazione Episodi
|
||||
scraped_ep = scrapertools.find_single_match(re.sub(r'\[[^\]]+\]','',item.title), r'\d+')
|
||||
if scraped_ep:
|
||||
episode = int(scraped_ep)
|
||||
number = episode + FirstOfSeason - addiction
|
||||
count = number + addiction
|
||||
# Crea Dizionario Episodi
|
||||
|
||||
if episode == 0:
|
||||
EpisodeDict[str(episode)] = str(complete[regular[FirstOfSeason+1][2]][0])
|
||||
elif addiction < len(Special):
|
||||
if episode in Special:
|
||||
try:
|
||||
season = complete[regular[count][2]][0]
|
||||
EpisodeDict[str(episode)] = str(complete[regular[count][2]][0]) if season.startswith( '0' ) else '0x' + platformtools.dialog_numeric(0, item.title + '?', '')
|
||||
|
||||
except:
|
||||
EpisodeDict[str(episode)] = '0x' + platformtools.dialog_numeric(0, item.title + '?', '')
|
||||
addiction = addiction + 1
|
||||
elif number <= len(regular):
|
||||
EpisodeDict[str(episode)] = str(regular[number][0])
|
||||
else:
|
||||
try: EpisodeDict[str(episode)] = str(complete[regular[number+2][2]][0])
|
||||
except: EpisodeDict[str(episode)] = '0x0'
|
||||
elif number <= len(regular) and number in regular:
|
||||
EpisodeDict[str(episode)] = str(regular[number][0])
|
||||
else:
|
||||
try: EpisodeDict[str(episode)] = str(complete[regular[number+2][2]][0])
|
||||
except: EpisodeDict[str(episode)] = '0x0'
|
||||
|
||||
# Aggiunge numerazione agli Episodi
|
||||
|
||||
item.title = typo(EpisodeDict[str(episode)] + ' - ', typography) + item.title
|
||||
|
||||
# Scrive Dizionario Episodi sul json
|
||||
EpisodeDict = base64.b64encode(json.dumps(EpisodeDict).encode())
|
||||
dict_series[title][TAG_EPISODE] = EpisodeDict.decode()
|
||||
write(item, dict_series)
|
||||
|
||||
else:
|
||||
heading = config.get_localized_string(70704)
|
||||
ID = platformtools.dialog_numeric(0, heading)
|
||||
dict_series[title][TAG_ID] = ID
|
||||
write(item, dict_series)
|
||||
if ID == '0':
|
||||
return itemlist
|
||||
else:
|
||||
return make_list(itemlist, item, typography, dict_series, ID, Season, Episode, Mode, title)
|
||||
|
||||
|
||||
def check(item):
|
||||
info()
|
||||
dict_series = load(item)
|
||||
title = item.fulltitle.rstrip()
|
||||
if title in dict_series: title = dict_series[title]
|
||||
return True if TAG_ID in title and TAG_EPISODE in title else False
|
||||
|
||||
|
||||
def error(itemlist):
|
||||
message = config.get_localized_string(70713)
|
||||
heading = itemlist[0].fulltitle.strip()
|
||||
platformtools.dialog_notification(heading, message)
|
||||
return itemlist
|
||||
|
||||
|
||||
def find_episodes(item):
|
||||
info()
|
||||
ch = __import__('channels.' + item.channel, fromlist=["channels.%s" % item.channel])
|
||||
itemlist = ch.episodios(item)
|
||||
return itemlist
|
||||
|
||||
|
||||
def RepresentsInt(s):
|
||||
# Controllo Numro Stagione
|
||||
info()
|
||||
try:
|
||||
int(s)
|
||||
return True
|
||||
except ValueError:
|
||||
return False
|
||||
|
||||
|
||||
def access():
|
||||
allow = False
|
||||
|
||||
if config.is_xbmc():
|
||||
allow = True
|
||||
|
||||
return allow
|
||||
|
||||
|
||||
def context(exist):
|
||||
if access():
|
||||
modify = config.get_localized_string(70714) if exist else ''
|
||||
_context = [{"title": typo(modify + config.get_localized_string(70585), 'bold'),
|
||||
"action": "select_type",
|
||||
"channel": "autorenumber",}]
|
||||
|
||||
return _context
|
||||
|
||||
|
||||
def select_type(item):
|
||||
select = platformtools.dialog_select(config.get_localized_string(70730),[typo(config.get_localized_string(70731),'bold'), typo(config.get_localized_string(70732),'bold'), typo(config.get_localized_string(707433),'bold')])
|
||||
if select == 0: semiautomatic_config_item(item)
|
||||
elif select == 1: manual_renumeration(item)
|
||||
elif select == 2: return delete_renumeration(item)
|
||||
else: return
|
||||
|
||||
|
||||
def filename(item):
|
||||
info()
|
||||
name_file = item.channel + "_data.json"
|
||||
path = filetools.join(config.get_data_path(), "settings_channels")
|
||||
fname = filetools.join(path, name_file)
|
||||
|
||||
return fname
|
||||
|
||||
|
||||
def load(item):
|
||||
info()
|
||||
try:
|
||||
json_file = open(filename(item), "r").read()
|
||||
json = jsontools.load(json_file)[TAG_TVSHOW_RENUMERATE]
|
||||
|
||||
except:
|
||||
json = {}
|
||||
|
||||
return json
|
||||
|
||||
|
||||
def write(item, json):
|
||||
info()
|
||||
json_file = open(filename(item), "r").read()
|
||||
js = jsontools.load(json_file)
|
||||
js[TAG_TVSHOW_RENUMERATE] = json
|
||||
with open(filename(item), "w") as file:
|
||||
file.write(jsontools.dump(js))
|
||||
file.close()
|
||||
@@ -0,0 +1,658 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# ------------------------------------------------------------
|
||||
# filtertools - is responsible for filtering results
|
||||
# ------------------------------------------------------------
|
||||
|
||||
from builtins import object
|
||||
|
||||
from core import jsontools
|
||||
from core.item import Item
|
||||
from platformcode import config, logger
|
||||
from platformcode import platformtools
|
||||
from core import channeltools
|
||||
|
||||
TAG_TVSHOW_FILTER = "TVSHOW_FILTER"
|
||||
TAG_NAME = "name"
|
||||
TAG_ACTIVE = "active"
|
||||
TAG_LANGUAGE = "language"
|
||||
TAG_QUALITY_ALLOWED = "quality_allowed"
|
||||
|
||||
COLOR = {"parent_item": "yellow", "error": "red", "striped_even_active": "blue",
|
||||
"striped_even_inactive": "0xff00bfff", "striped_odd_active": "0xff008000",
|
||||
"striped_odd_inactive": "0xff00fa9a", "selected": "blue"
|
||||
}
|
||||
|
||||
filter_global = None
|
||||
|
||||
__channel__ = "filtertools"
|
||||
|
||||
|
||||
# TODO take a look at https://pyformat.info/, you can format the style and make references directly to elements
|
||||
|
||||
|
||||
class ResultFilter(object):
|
||||
def __init__(self, dict_filter):
|
||||
self.active = dict_filter[TAG_ACTIVE]
|
||||
self.language = dict_filter[TAG_LANGUAGE]
|
||||
self.quality_allowed = dict_filter[TAG_QUALITY_ALLOWED]
|
||||
|
||||
def __str__(self):
|
||||
return "{active: '%s', language: '%s', quality_allowed: '%s'}" % (self.active, self.language, self.quality_allowed)
|
||||
|
||||
|
||||
class Filter(object):
|
||||
def __init__(self, item, global_filter_lang_id):
|
||||
self.result = None
|
||||
self.__get_data(item, global_filter_lang_id)
|
||||
|
||||
def __get_data(self, item, global_filter_lang_id):
|
||||
|
||||
dict_filtered_shows = jsontools.get_node_from_file(item.channel, TAG_TVSHOW_FILTER)
|
||||
tvshow = item.show.lower().strip()
|
||||
|
||||
global_filter_language = config.get_setting(global_filter_lang_id, item.channel)
|
||||
|
||||
if tvshow in list(dict_filtered_shows.keys()):
|
||||
|
||||
self.result = ResultFilter({TAG_ACTIVE: dict_filtered_shows[tvshow][TAG_ACTIVE],
|
||||
TAG_LANGUAGE: dict_filtered_shows[tvshow][TAG_LANGUAGE],
|
||||
TAG_QUALITY_ALLOWED: dict_filtered_shows[tvshow][TAG_QUALITY_ALLOWED]})
|
||||
|
||||
# general option "do not filter"
|
||||
elif global_filter_language != 0:
|
||||
from core import channeltools
|
||||
list_controls, dict_settings = channeltools.get_channel_controls_settings(item.channel)
|
||||
|
||||
for control in list_controls:
|
||||
if control["id"] == global_filter_lang_id:
|
||||
|
||||
try:
|
||||
language = control["lvalues"][global_filter_language]
|
||||
# logger.debug("language %s" % language)
|
||||
except:
|
||||
logger.error("The value associated with the code was not found '%s': %s" % (global_filter_lang_id, global_filter_language))
|
||||
break
|
||||
|
||||
self.result = ResultFilter({TAG_ACTIVE: True, TAG_LANGUAGE: language, TAG_QUALITY_ALLOWED: []})
|
||||
break
|
||||
|
||||
def __str__(self):
|
||||
return "{'%s'}" % self.result
|
||||
|
||||
|
||||
def access():
|
||||
"""
|
||||
Returns whether or not filtertools can be used
|
||||
"""
|
||||
allow = False
|
||||
|
||||
if config.is_xbmc() or config.get_platform() == "mediaserver":
|
||||
allow = True
|
||||
|
||||
return allow
|
||||
|
||||
|
||||
def context(item, list_language=None, list_quality=None, exist=False):
|
||||
"""
|
||||
For xbmc / kodi and mediaserver since they can show the contextual menu, a filter option is added to the configuration menu, only if it is for series.
|
||||
Depending on the place and if there is a filter, more options will be added to show.
|
||||
The context -is shown only for series-.
|
||||
|
||||
@param item: eelement to get the information and see what context to add
|
||||
@type item: item
|
||||
param list_language: list of possible languages
|
||||
@type list_language: list[str]
|
||||
@param list_quality: list of possible qualities
|
||||
@type list_quality: list[str]
|
||||
@param exist: if the filter exists
|
||||
@type exist: bool
|
||||
@return: list of options to display in the context menu
|
||||
@rtype: list
|
||||
"""
|
||||
|
||||
# Depending on how the context is, we save it and add the filtertools options.
|
||||
if isinstance(item.context, str):
|
||||
_context = item.context.split("|")
|
||||
elif isinstance(item.context, list):
|
||||
_context = item.context
|
||||
else:
|
||||
_context = []
|
||||
|
||||
if access():
|
||||
dict_data = {"title": config.get_localized_string(60426), "action": "config_item", "channel": "filtertools"}
|
||||
if list_language:
|
||||
dict_data["list_language"] = list_language
|
||||
if list_quality:
|
||||
dict_data["list_quality"] = list_quality
|
||||
|
||||
added = False
|
||||
if isinstance(_context, list):
|
||||
for x in _context:
|
||||
if x and isinstance(x, dict):
|
||||
if x["channel"] == "filtertools":
|
||||
added = True
|
||||
break
|
||||
|
||||
if not added:
|
||||
_context.append(dict_data)
|
||||
|
||||
if item.action == "play":
|
||||
if not exist:
|
||||
_context.append({"title": config.get_localized_string(60427) % item.language, "action": "save_from_context",
|
||||
"channel": "filtertools", "from_channel": item.channel})
|
||||
else:
|
||||
_context.append({"title": config.get_localized_string(60428) % item.language, "action": "delete_from_context",
|
||||
"channel": "filtertools", "from_channel": item.channel})
|
||||
|
||||
return _context
|
||||
|
||||
|
||||
def show_option(itemlist, channel, list_language, list_quality):
|
||||
if access():
|
||||
itemlist.append(Item(channel=__channel__, title=config.get_localized_string(60429) % COLOR.get("parent_item", "auto"), action="load",
|
||||
list_language=list_language, list_quality=list_quality, from_channel=channel))
|
||||
|
||||
return itemlist
|
||||
|
||||
|
||||
def load(item):
|
||||
return mainlist(channel=item.from_channel, list_language=item.list_language, list_quality=item.list_quality)
|
||||
|
||||
|
||||
def check_conditions(_filter, list_item, item, list_language, list_quality, quality_count=0, language_count=0):
|
||||
is_language_valid = True
|
||||
|
||||
if _filter.language:
|
||||
# logger.debug("title es %s" % item.title)
|
||||
# 2nd lang
|
||||
|
||||
from platformcode import unify
|
||||
_filter.language = unify.set_lang(_filter.language).upper()
|
||||
|
||||
# comes from episodes
|
||||
if isinstance(item.language, list):
|
||||
# 2nd lang
|
||||
for n, lang in enumerate(item.language):
|
||||
item.language[n] = unify.set_lang(lang).upper()
|
||||
|
||||
if _filter.language in item.language:
|
||||
language_count += 1
|
||||
else:
|
||||
is_language_valid = False
|
||||
# comes from findvideos
|
||||
else:
|
||||
# 2nd lang
|
||||
item.language = unify.set_lang(item.language).upper()
|
||||
|
||||
if item.language.lower() == _filter.language.lower():
|
||||
language_count += 1
|
||||
else:
|
||||
is_language_valid = False
|
||||
|
||||
is_quality_valid = True
|
||||
quality = ""
|
||||
|
||||
if _filter.quality_allowed and item.quality != "":
|
||||
# if hasattr (item, 'quality'): # this validation is not necessary because the empty attribute is ALWAYS returned
|
||||
if item.quality.lower() in _filter.quality_allowed:
|
||||
quality = item.quality.lower()
|
||||
quality_count += 1
|
||||
else:
|
||||
is_quality_valid = False
|
||||
|
||||
if is_language_valid and is_quality_valid:
|
||||
#TODO 2nd lang: we should see if it is convenient to unify the language here or not
|
||||
item.list_language = list_language
|
||||
if list_quality:
|
||||
item.list_quality = list_quality
|
||||
item.context = context(item, exist=True)
|
||||
list_item.append(item)
|
||||
# logger.debug("{0} | context: {1}".format(item.title, item.context))
|
||||
# logger.debug(" -Enlace añadido")
|
||||
elif not item.language:
|
||||
list_item.append(item)
|
||||
logger.debug(" idioma valido?: %s, item.language: %s, filter.language: %s" % (is_language_valid, item.language, _filter.language))
|
||||
logger.debug(" calidad valida?: %s, item.quality: %s, filter.quality_allowed: %s" % (is_quality_valid, quality, _filter.quality_allowed))
|
||||
|
||||
return list_item, quality_count, language_count, _filter.language
|
||||
|
||||
|
||||
def get_link(list_item, item, list_language, list_quality=None, global_filter_lang_id="filter_languages"):
|
||||
"""
|
||||
Returns a list of links, if the item is correctly filtered it is added to the received list.
|
||||
|
||||
@param list_item: list of links
|
||||
@type list_item: list[Item]
|
||||
@param item: element to filter
|
||||
@type item: Item
|
||||
@param list_language: list of possible languages
|
||||
@type list_language: list[str]
|
||||
@param list_quality: list of possible qualities
|
||||
@type list_quality: list[str]
|
||||
@param global_filter_lang_id: id of the filtering variable by language that is in settings
|
||||
@type global_filter_lang_id: str
|
||||
@return: Item list
|
||||
@rtype: list[Item]
|
||||
"""
|
||||
logger.info()
|
||||
|
||||
# if the required fields are None we leave
|
||||
if list_item is None or item is None:
|
||||
return []
|
||||
|
||||
logger.debug("total de items : %s" % len(list_item))
|
||||
|
||||
global filter_global
|
||||
|
||||
if not filter_global:
|
||||
filter_global = Filter(item, global_filter_lang_id).result
|
||||
logger.debug("filter: '%s' datos: '%s'" % (item.show, filter_global))
|
||||
|
||||
if filter_global and filter_global.active:
|
||||
list_item, quality_count, language_count = check_conditions(filter_global, list_item, item, list_language, list_quality)[:3]
|
||||
else:
|
||||
item.context = context(item)
|
||||
list_item.append(item)
|
||||
|
||||
return list_item
|
||||
|
||||
|
||||
def get_links(list_item, item, list_language, list_quality=None, global_filter_lang_id="filter_languages"):
|
||||
"""
|
||||
Returns a list of filtered links.
|
||||
|
||||
@param list_item: list of links
|
||||
@type list_item: list[Item]
|
||||
@param item: element to filter
|
||||
@type item: item
|
||||
@param list_language: list of possible languages
|
||||
@type list_language: list[str]
|
||||
@param list_quality: list of possible qualities
|
||||
@type list_quality: list[str]
|
||||
@param global_filter_lang_id: id of the filtering variable by language that is in settings
|
||||
@type global_filter_lang_id: str
|
||||
@return: lista de Item
|
||||
@rtype: list[Item]
|
||||
"""
|
||||
logger.info()
|
||||
|
||||
|
||||
# if the required fields are None we leave
|
||||
if list_item is None or item is None:
|
||||
return []
|
||||
|
||||
# if list_item is empty we go back, no platform validation is added so Plex can do global filter
|
||||
if len(list_item) == 0:
|
||||
return list_item
|
||||
|
||||
|
||||
second_lang = config.get_setting('second_language')
|
||||
|
||||
logger.debug("total de items : %s" % len(list_item))
|
||||
|
||||
new_itemlist = []
|
||||
quality_count = 0
|
||||
language_count = 0
|
||||
|
||||
_filter = Filter(item, global_filter_lang_id).result
|
||||
logger.debug("filter: '%s' datos: '%s'" % (item.show, _filter))
|
||||
|
||||
|
||||
if _filter and _filter.active:
|
||||
|
||||
for item in list_item:
|
||||
new_itemlist, quality_count, language_count, first_lang = check_conditions(_filter, new_itemlist, item, list_language, list_quality, quality_count, language_count)
|
||||
|
||||
#2nd lang
|
||||
if second_lang and second_lang != 'No' and first_lang.lower() != second_lang.lower() :
|
||||
second_list= []
|
||||
_filter2 = _filter
|
||||
_filter2.language = second_lang
|
||||
for it in new_itemlist:
|
||||
if isinstance(it.language, list):
|
||||
if not second_lang in it.language:
|
||||
second_list.append(it)
|
||||
else:
|
||||
second_list = new_itemlist
|
||||
break
|
||||
for item in list_item:
|
||||
new_itemlist, quality_count, language_count, second_lang = check_conditions(_filter2, second_list, item, list_language, list_quality, quality_count, language_count)
|
||||
|
||||
|
||||
logger.debug("FILTERED ITEMS: %s/%s, language [%s]: %s, allowed quality %s: %s" % (len(new_itemlist), len(list_item), _filter.language, language_count, _filter.quality_allowed, quality_count))
|
||||
|
||||
if len(new_itemlist) == 0:
|
||||
list_item_all = []
|
||||
for i in list_item:
|
||||
list_item_all.append(i.tourl())
|
||||
|
||||
_context = [{"title": config.get_localized_string(60430) % _filter.language, "action": "delete_from_context", "channel": "filtertools", "to_channel": item.channel}]
|
||||
|
||||
if _filter.quality_allowed:
|
||||
msg_quality_allowed = " y calidad %s" % _filter.quality_allowed
|
||||
else:
|
||||
msg_quality_allowed = ""
|
||||
|
||||
msg_lang = ' %s' % first_lang.upper()
|
||||
if second_lang and second_lang != 'No':
|
||||
msg_lang = 's %s ni %s' % (first_lang.upper(), second_lang.upper())
|
||||
|
||||
new_itemlist.append(Item(channel=__channel__, action="no_filter", list_item_all=list_item_all,
|
||||
show=item.show,
|
||||
title=config.get_localized_string(60432) % (_filter.language, msg_quality_allowed),
|
||||
context=_context))
|
||||
|
||||
else:
|
||||
for item in list_item:
|
||||
item.list_language = list_language
|
||||
if list_quality:
|
||||
item.list_quality = list_quality
|
||||
item.context = context(item)
|
||||
new_itemlist = list_item
|
||||
|
||||
return new_itemlist
|
||||
|
||||
|
||||
def no_filter(item):
|
||||
"""
|
||||
Muestra los enlaces sin filtrar
|
||||
|
||||
@param item: item
|
||||
@type item: Item
|
||||
@return: lista de enlaces
|
||||
@rtype: list[Item]
|
||||
"""
|
||||
logger.info()
|
||||
|
||||
itemlist = []
|
||||
for i in item.list_item_all:
|
||||
itemlist.append(Item().fromurl(i))
|
||||
|
||||
return itemlist
|
||||
|
||||
|
||||
def mainlist(channel, list_language, list_quality):
|
||||
"""
|
||||
Shows a list of the leaked series
|
||||
|
||||
@param channel: channel name to get filtered series
|
||||
@type channel: str
|
||||
@param list_language: channel language list
|
||||
@type list_language: list[str]
|
||||
@param list_quality: channel quality list
|
||||
@type list_quality: list[str]
|
||||
@return: Item list
|
||||
@rtype: list[Item]
|
||||
"""
|
||||
logger.info()
|
||||
itemlist = []
|
||||
dict_series = jsontools.get_node_from_file(channel, TAG_TVSHOW_FILTER)
|
||||
|
||||
idx = 0
|
||||
for tvshow in sorted(dict_series):
|
||||
|
||||
if idx % 2 == 0:
|
||||
if dict_series[tvshow][TAG_ACTIVE]:
|
||||
tag_color = COLOR.get("striped_even_active", "auto")
|
||||
else:
|
||||
tag_color = COLOR.get("striped_even_inactive", "auto")
|
||||
else:
|
||||
if dict_series[tvshow][TAG_ACTIVE]:
|
||||
tag_color = COLOR.get("striped_odd_active", "auto")
|
||||
else:
|
||||
tag_color = COLOR.get("striped_odd_inactive", "auto")
|
||||
|
||||
idx += 1
|
||||
name = dict_series.get(tvshow, {}).get(TAG_NAME, tvshow)
|
||||
activo = config.get_localized_string(60433)
|
||||
if dict_series[tvshow][TAG_ACTIVE]:
|
||||
activo = ""
|
||||
title = config.get_localized_string(60434) % (tag_color, name, activo)
|
||||
|
||||
itemlist.append(Item(channel=__channel__, action="config_item", title=title, show=name,
|
||||
list_language=list_language, list_quality=list_quality, from_channel=channel))
|
||||
|
||||
if len(itemlist) == 0:
|
||||
itemlist.append(Item(channel=channel, action="mainlist", title=config.get_localized_string(60435)))
|
||||
|
||||
return itemlist
|
||||
|
||||
|
||||
def config_item(item):
|
||||
"""
|
||||
displays a filtered series for your setup
|
||||
|
||||
@param item: item
|
||||
@type item: Item
|
||||
"""
|
||||
logger.info()
|
||||
logger.info("item %s" % item.tostring())
|
||||
|
||||
# WE GET THE JSON DATA
|
||||
dict_series = jsontools.get_node_from_file(item.from_channel, TAG_TVSHOW_FILTER)
|
||||
|
||||
tvshow = item.show.lower().strip()
|
||||
default_lang = ''
|
||||
|
||||
channel_parameters = channeltools.get_channel_parameters(item.from_channel)
|
||||
list_language = channel_parameters["filter_languages"]
|
||||
try:
|
||||
if channel_parameters["filter_languages"] != '' and len(list_language) > 0:
|
||||
default_lang = list_language[1]
|
||||
except:
|
||||
pass
|
||||
|
||||
if default_lang == '':
|
||||
platformtools.dialog_notification("FilterTools", "There are no defined languages")
|
||||
return
|
||||
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))
|
||||
|
||||
active = True
|
||||
custom_button = {'visible': False}
|
||||
allow_option = False
|
||||
if item.show.lower().strip() in dict_series:
|
||||
allow_option = True
|
||||
active = dict_series.get(item.show.lower().strip(), {}).get(TAG_ACTIVE, False)
|
||||
custom_button = {'label': config.get_localized_string(60437), 'function': 'delete', 'visible': True, 'close': True}
|
||||
|
||||
list_controls = []
|
||||
|
||||
if allow_option:
|
||||
active_control = {
|
||||
"id": "active",
|
||||
"type": "bool",
|
||||
"label": config.get_localized_string(60438),
|
||||
"color": "",
|
||||
"default": active,
|
||||
"enabled": allow_option,
|
||||
"visible": allow_option,
|
||||
}
|
||||
list_controls.append(active_control)
|
||||
|
||||
language_option = {
|
||||
"id": "language",
|
||||
"type": "list",
|
||||
"label": config.get_localized_string(60439),
|
||||
# "color": "0xFFee66CC",
|
||||
"default": item.list_language.index(lang_selected),
|
||||
"enabled": True,
|
||||
"visible": True,
|
||||
"lvalues": item.list_language
|
||||
}
|
||||
list_controls.append(language_option)
|
||||
|
||||
if item.list_quality:
|
||||
list_controls_calidad = [
|
||||
{
|
||||
"id": "textoCalidad",
|
||||
"type": "label",
|
||||
"label": "Calidad permitida",
|
||||
"color": "0xffC6C384",
|
||||
"enabled": True,
|
||||
"visible": True,
|
||||
},
|
||||
]
|
||||
for element in sorted(item.list_quality, key=str.lower):
|
||||
list_controls_calidad.append({
|
||||
"id": element,
|
||||
"type": "bool",
|
||||
"label": element,
|
||||
"default": (False, True)[element.lower() in list_quality],
|
||||
"enabled": True,
|
||||
"visible": True,
|
||||
})
|
||||
|
||||
# we concatenate list_controls with list_controls_quality
|
||||
list_controls.extend(list_controls_calidad)
|
||||
|
||||
title = config.get_localized_string(60441) % (COLOR.get("selected", "auto"), item.show)
|
||||
|
||||
platformtools.show_channel_settings(list_controls=list_controls, callback='save', item=item,
|
||||
caption=title, custom_button=custom_button)
|
||||
|
||||
|
||||
def delete(item, dict_values):
|
||||
logger.info()
|
||||
|
||||
if item:
|
||||
dict_series = jsontools.get_node_from_file(item.from_channel, TAG_TVSHOW_FILTER)
|
||||
tvshow = item.show.strip().lower()
|
||||
|
||||
heading = config.get_localized_string(60442)
|
||||
line1 = config.get_localized_string(60443) % (COLOR.get("selected", "auto"), item.show.strip())
|
||||
|
||||
if platformtools.dialog_yesno(heading, line1) == 1:
|
||||
lang_selected = dict_series.get(tvshow, {}).get(TAG_LANGUAGE, "")
|
||||
dict_series.pop(tvshow, None)
|
||||
|
||||
result, json_data = jsontools.update_node(dict_series, item.from_channel, TAG_TVSHOW_FILTER)
|
||||
|
||||
sound = False
|
||||
if result:
|
||||
message = config.get_localized_string(60444)
|
||||
else:
|
||||
message = config.get_localized_string(60445)
|
||||
sound = True
|
||||
|
||||
heading = "%s [%s]" % (item.show.strip(), lang_selected)
|
||||
platformtools.dialog_notification(heading, message, sound=sound)
|
||||
|
||||
if item.action in ["findvideos", "play"]:
|
||||
platformtools.itemlist_refresh()
|
||||
|
||||
|
||||
def save(item, dict_data_saved):
|
||||
"""
|
||||
Save the configured values in the window
|
||||
|
||||
@param item: item
|
||||
@type item: Item
|
||||
@param dict_data_saved: dictionary with saved data
|
||||
@type dict_data_saved: dict
|
||||
"""
|
||||
logger.info()
|
||||
|
||||
if item and dict_data_saved:
|
||||
logger.debug('item: %s\ndatos: %s' % (item.tostring(), dict_data_saved))
|
||||
|
||||
if item.from_channel == "videolibrary":
|
||||
item.from_channel = item.contentChannel
|
||||
dict_series = jsontools.get_node_from_file(item.from_channel, TAG_TVSHOW_FILTER)
|
||||
tvshow = item.show.strip().lower()
|
||||
|
||||
logger.info("Data is updated")
|
||||
|
||||
list_quality = []
|
||||
for _id, value in list(dict_data_saved.items()):
|
||||
if _id in item.list_quality and value:
|
||||
list_quality.append(_id.lower())
|
||||
|
||||
lang_selected = item.list_language[dict_data_saved[TAG_LANGUAGE]]
|
||||
dict_filter = {TAG_NAME: item.show, TAG_ACTIVE: dict_data_saved.get(TAG_ACTIVE, True),
|
||||
TAG_LANGUAGE: lang_selected, TAG_QUALITY_ALLOWED: list_quality}
|
||||
dict_series[tvshow] = dict_filter
|
||||
|
||||
result, json_data = jsontools.update_node(dict_series, item.from_channel, TAG_TVSHOW_FILTER)
|
||||
|
||||
sound = False
|
||||
if result:
|
||||
message = config.get_localized_string(60446)
|
||||
else:
|
||||
message = config.get_localized_string(70593)
|
||||
sound = True
|
||||
|
||||
heading = "%s [%s]" % (item.show.strip(), lang_selected)
|
||||
platformtools.dialog_notification(heading, message, sound=sound)
|
||||
|
||||
if item.from_action in ["findvideos", "play"]:
|
||||
platformtools.itemlist_refresh()
|
||||
|
||||
|
||||
def save_from_context(item):
|
||||
"""
|
||||
Save the filter through the context menu
|
||||
|
||||
@param item: item
|
||||
@type item: item
|
||||
"""
|
||||
logger.info()
|
||||
|
||||
dict_series = jsontools.get_node_from_file(item.from_channel, TAG_TVSHOW_FILTER)
|
||||
tvshow = item.show.strip().lower()
|
||||
|
||||
dict_filter = {TAG_NAME: item.show, TAG_ACTIVE: True, TAG_LANGUAGE: item.language, TAG_QUALITY_ALLOWED: []}
|
||||
dict_series[tvshow] = dict_filter
|
||||
|
||||
result, json_data = jsontools.update_node(dict_series, item.from_channel, TAG_TVSHOW_FILTER)
|
||||
|
||||
sound = False
|
||||
if result:
|
||||
message = "SAVED FILTER"
|
||||
else:
|
||||
message = "Error saving to disk"
|
||||
sound = True
|
||||
|
||||
heading = "%s [%s]" % (item.show.strip(), item.language)
|
||||
platformtools.dialog_notification(heading, message, sound=sound)
|
||||
|
||||
if item.from_action in ["findvideos", "play"]:
|
||||
platformtools.itemlist_refresh()
|
||||
|
||||
|
||||
def delete_from_context(item):
|
||||
"""
|
||||
Delete the filter through the context menu
|
||||
|
||||
@param item: item
|
||||
@type item: item
|
||||
"""
|
||||
logger.info()
|
||||
|
||||
# We come from get_links and no result has been obtained, in context menu and we delete
|
||||
if item.to_channel != "":
|
||||
item.from_channel = item.to_channel
|
||||
|
||||
dict_series = jsontools.get_node_from_file(item.from_channel, TAG_TVSHOW_FILTER)
|
||||
tvshow = item.show.strip().lower()
|
||||
|
||||
lang_selected = dict_series.get(tvshow, {}).get(TAG_LANGUAGE, "")
|
||||
dict_series.pop(tvshow, None)
|
||||
|
||||
result, json_data = jsontools.update_node(dict_series, item.from_channel, TAG_TVSHOW_FILTER)
|
||||
|
||||
sound = False
|
||||
if result:
|
||||
message = "FILTER REMOVED"
|
||||
else:
|
||||
message = "Error saving to disk"
|
||||
sound = True
|
||||
|
||||
heading = "%s [%s]" % (item.show.strip(), lang_selected)
|
||||
platformtools.dialog_notification(heading, message, sound=sound)
|
||||
|
||||
if item.from_action in ["findvideos", "play", "no_filter"]: # 'no_filter' es el mismo caso que L#601
|
||||
platformtools.itemlist_refresh()
|
||||
+1
-1
@@ -284,7 +284,7 @@ def downloadpage(url, **opt):
|
||||
CF = True
|
||||
|
||||
if config.get_setting('resolver_dns') and not opt.get('use_requests', False):
|
||||
from specials import resolverdns
|
||||
from core import resolverdns
|
||||
session.mount('https://', resolverdns.CipherSuiteAdapter(domain, CF))
|
||||
|
||||
req_headers = default_headers.copy()
|
||||
|
||||
@@ -0,0 +1,151 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import os, sys, ssl
|
||||
PY3 = False
|
||||
if sys.version_info[0] >= 3: PY3 = True; unicode = str; unichr = chr; long = int
|
||||
if PY3:
|
||||
import urllib.parse as urlparse
|
||||
import _ssl
|
||||
DEFAULT_CIPHERS = _ssl._DEFAULT_CIPHERS
|
||||
else:
|
||||
import urlparse
|
||||
DEFAULT_CIPHERS = ssl._DEFAULT_CIPHERS
|
||||
|
||||
from lib.requests_toolbelt.adapters import host_header_ssl
|
||||
from lib import doh
|
||||
from platformcode import logger, config
|
||||
import requests
|
||||
from core import scrapertools
|
||||
|
||||
try:
|
||||
import _sqlite3 as sql
|
||||
except:
|
||||
import sqlite3 as sql
|
||||
|
||||
db = os.path.join(config.get_data_path(), 'kod_db.sqlite')
|
||||
if 'PROTOCOL_TLS' in ssl.__dict__:
|
||||
protocol = ssl.PROTOCOL_TLS
|
||||
elif 'PROTOCOL_SSLv23' in ssl.__dict__:
|
||||
protocol = ssl.PROTOCOL_SSLv23
|
||||
else:
|
||||
protocol = ssl.PROTOCOL_SSLv3
|
||||
|
||||
|
||||
class CustomContext(ssl.SSLContext):
|
||||
def __init__(self, protocol, hostname, *args, **kwargs):
|
||||
self.hostname = hostname
|
||||
if PY3:
|
||||
super(CustomContext, self).__init__()
|
||||
else:
|
||||
super(CustomContext, self).__init__(protocol)
|
||||
self.verify_mode = ssl.CERT_NONE
|
||||
|
||||
def wrap_socket(self, *args, **kwargs):
|
||||
kwargs['server_hostname'] = self.hostname
|
||||
self.verify_mode = ssl.CERT_NONE
|
||||
return super(CustomContext, self).wrap_socket(*args, **kwargs)
|
||||
|
||||
|
||||
class CipherSuiteAdapter(host_header_ssl.HostHeaderSSLAdapter):
|
||||
|
||||
def __init__(self, domain, CF=False, *args, **kwargs):
|
||||
self.conn = sql.connect(db)
|
||||
self.cur = self.conn.cursor()
|
||||
self.ssl_context = CustomContext(protocol, domain)
|
||||
self.CF = CF # if cloudscrape is in action
|
||||
self.cipherSuite = kwargs.pop('cipherSuite', DEFAULT_CIPHERS)
|
||||
|
||||
super(CipherSuiteAdapter, self).__init__(**kwargs)
|
||||
|
||||
def flushDns(self, request, domain, **kwargs):
|
||||
self.cur.execute('delete from dnscache where domain=?', (domain,))
|
||||
self.conn.commit()
|
||||
return self.send(request, flushedDns=True, **kwargs)
|
||||
|
||||
def getIp(self, domain):
|
||||
ip = None
|
||||
try:
|
||||
self.cur.execute('select ip from dnscache where domain=?', (domain,))
|
||||
ip = self.cur.fetchall()[0][0]
|
||||
logger.info('Cache DNS: ' + domain + ' = ' + str(ip))
|
||||
except:
|
||||
pass
|
||||
if not ip: # not cached
|
||||
try:
|
||||
ip = doh.query(domain)[0]
|
||||
logger.info('Query DoH: ' + domain + ' = ' + str(ip))
|
||||
self.writeToCache(domain, ip)
|
||||
except Exception:
|
||||
logger.error('Failed to resolve hostname, fallback to normal dns')
|
||||
import traceback
|
||||
logger.error(traceback.print_exc())
|
||||
return ip
|
||||
|
||||
def writeToCache(self, domain, ip):
|
||||
try:
|
||||
self.cur.execute('insert into dnscache values(?,?)', (domain, ip))
|
||||
except:
|
||||
self.cur.execute("""CREATE TABLE IF NOT EXISTS dnscache(
|
||||
"domain" TEXT NOT NULL UNIQUE,
|
||||
"ip" TEXT NOT NULL,
|
||||
PRIMARY KEY("domain")
|
||||
);""")
|
||||
self.conn.commit()
|
||||
|
||||
def init_poolmanager(self, *args, **kwargs):
|
||||
kwargs['ssl_context'] = self.ssl_context
|
||||
return super(CipherSuiteAdapter, self).init_poolmanager(*args, **kwargs)
|
||||
|
||||
def proxy_manager_for(self, *args, **kwargs):
|
||||
kwargs['ssl_context'] = self.ssl_context
|
||||
return super(CipherSuiteAdapter, self).proxy_manager_for(*args, **kwargs)
|
||||
|
||||
def send(self, request, flushedDns=False, **kwargs):
|
||||
try:
|
||||
parse = urlparse.urlparse(request.url)
|
||||
except:
|
||||
raise requests.exceptions.InvalidURL
|
||||
if parse.netloc:
|
||||
domain = parse.netloc
|
||||
else:
|
||||
raise requests.exceptions.URLRequired
|
||||
if not scrapertools.find_single_match(domain, '\d+\.\d+\.\d+\.\d+'):
|
||||
ip = self.getIp(domain)
|
||||
else:
|
||||
ip = None
|
||||
if ip:
|
||||
self.ssl_context = CustomContext(protocol, domain)
|
||||
if self.CF:
|
||||
self.ssl_context.options |= (ssl.OP_NO_SSLv2 | ssl.OP_NO_SSLv3 | ssl.OP_NO_TLSv1 | ssl.OP_NO_TLSv1_1)
|
||||
self.ssl_context.set_ciphers(self.cipherSuite)
|
||||
self.init_poolmanager(self._pool_connections, self._pool_maxsize, block=self._pool_block)
|
||||
realUrl = request.url
|
||||
|
||||
if request.headers:
|
||||
request.headers["Host"] = domain
|
||||
else:
|
||||
request.headers = {"Host": domain}
|
||||
ret = None
|
||||
tryFlush = False
|
||||
|
||||
parse = list(parse)
|
||||
parse[1] = ip
|
||||
request.url = urlparse.urlunparse(parse)
|
||||
try:
|
||||
ret = super(CipherSuiteAdapter, self).send(request, **kwargs)
|
||||
except Exception as e:
|
||||
logger.info('Request for ' + domain + ' with ip ' + ip + ' failed')
|
||||
logger.info(e)
|
||||
# if 'SSLError' in str(e):
|
||||
# # disabilito
|
||||
# config.set_setting("resolver_dns", False)
|
||||
# request.url = realUrl
|
||||
# ret = super(CipherSuiteAdapter, self).send(request, **kwargs)
|
||||
# else:
|
||||
tryFlush = True
|
||||
if tryFlush and not flushedDns: # re-request ips and update cache
|
||||
logger.info('Flushing dns cache for ' + domain)
|
||||
return self.flushDns(request, domain, **kwargs)
|
||||
ret.url = realUrl
|
||||
else:
|
||||
ret = super(host_header_ssl.HostHeaderSSLAdapter, self).send(request, **kwargs)
|
||||
return ret
|
||||
@@ -485,6 +485,9 @@ def get_server_parameters(server):
|
||||
# Debriders
|
||||
elif filetools.isfile(filetools.join(config.get_runtime_path(), "servers", "debriders", server + ".json")):
|
||||
path = filetools.join(config.get_runtime_path(), "servers", "debriders", server + ".json")
|
||||
else:
|
||||
from core.support import dbg
|
||||
dbg()
|
||||
|
||||
# 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))
|
||||
|
||||
+3
-4
@@ -17,13 +17,12 @@ else:
|
||||
from urllib import urlencode
|
||||
|
||||
from time import time
|
||||
from core import httptools, scrapertools, servertools, tmdb, channeltools
|
||||
from core import httptools, scrapertools, servertools, tmdb, channeltools, autoplay
|
||||
from core.item import Item
|
||||
from lib import unshortenit
|
||||
from platformcode import config
|
||||
from platformcode.logger import info
|
||||
from platformcode import logger
|
||||
from specials import autoplay
|
||||
|
||||
|
||||
def hdpass_get_servers(item):
|
||||
@@ -510,7 +509,7 @@ def scrape(func):
|
||||
tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True)
|
||||
|
||||
if anime:
|
||||
from specials import autorenumber
|
||||
from platformcode import autorenumber
|
||||
if function == 'episodios' or item.action == 'episodios': autorenumber.renumber(itemlist, item, 'bold')
|
||||
else: autorenumber.renumber(itemlist)
|
||||
# if anime and autorenumber.check(item) == False and len(itemlist)>0 and not scrapertools.find_single_match(itemlist[0].title, r'(\d+.\d+)'):
|
||||
@@ -1229,7 +1228,7 @@ def filterLang(item, itemlist):
|
||||
# import channeltools
|
||||
list_language = channeltools.get_lang(item.channel)
|
||||
if len(list_language) > 1:
|
||||
from specials import filtertools
|
||||
from core import filtertools
|
||||
itemlist = filtertools.get_links(itemlist, item, list_language)
|
||||
return itemlist
|
||||
|
||||
|
||||
@@ -254,7 +254,7 @@ def add_renumber_options(item, head_nfo, path):
|
||||
return ret
|
||||
|
||||
def check_renumber_options(item):
|
||||
from specials.autorenumber import load, write
|
||||
from core.autorenumber import load, write
|
||||
for key in item.channel_prefs:
|
||||
if 'TVSHOW_AUTORENUMBER' in item.channel_prefs[key]:
|
||||
item.channel = key
|
||||
@@ -1073,7 +1073,7 @@ def add_tvshow(item, channel=None):
|
||||
# Get the episode list
|
||||
itemlist = getattr(channel, item.action)(item)
|
||||
if itemlist and not scrapertools.find_single_match(itemlist[0].title, r'(\d+x\d+)'):
|
||||
from specials.autorenumber import select_type, renumber, check
|
||||
from core.autorenumber import select_type, renumber, check
|
||||
if not check(item):
|
||||
action = item.action
|
||||
select_type(item)
|
||||
|
||||
Reference in New Issue
Block a user