Aggiunta Rinumerazione Manuale

This commit is contained in:
Alhaziel
2019-10-02 20:18:27 +02:00
parent ac7304623f
commit 2e37cae1db
5 changed files with 158 additions and 46 deletions

View File

@@ -323,7 +323,7 @@ def scrape(func):
itemlist = []
args = func(*args)
log('STACK= ',inspect.stack()[1][3])
# log('STACK= ',inspect.stack()[1][3])
item = args['item']
@@ -345,7 +345,8 @@ def scrape(func):
typeActionDict = args['type_action_dict'] if 'type_action_dict' in args else {}
typeContentDict = args['type_content_dict'] if 'type_content_dict' in args else {}
debug = args['debug'] if 'debug' in args else False
if 'pagination' in args and inspect.stack()[1][3] not in ['add_tvshow', 'get_episodes']: pagination = args['pagination'] if args['pagination'] else 20
log('STACK= ', inspect.stack()[1][3])
if 'pagination' in args and inspect.stack()[1][3] not in ['add_tvshow', 'get_episodes', 'update', 'manual_renumeration']: pagination = args['pagination'] if args['pagination'] else 20
else: pagination = ''
lang = args['deflang'] if 'deflang' in args else ''
pag = item.page if item.page else 1 # pagination
@@ -772,7 +773,7 @@ def download(itemlist, item, typography='', function_level=1, function=''):
if itemlist and item.contentChannel != 'videolibrary':
itemlist.append(
Item(channel='downloads',
fromchannel=item.channel,
from_channel=item.channel,
title=title,
fulltitle=item.fulltitle,
show=item.fulltitle,
@@ -786,7 +787,7 @@ def download(itemlist, item, typography='', function_level=1, function=''):
if fromaction == 'episodios':
itemlist.append(
Item(channel='downloads',
fromchannel=item.channel,
from_channel=item.channel,
title=typo(config.get_localized_string(60357),typography),
fulltitle=item.fulltitle,
show=item.fulltitle,

View File

@@ -5636,3 +5636,27 @@ msgstr ""
msgctxt "#70729"
msgid "Always add the highest quality"
msgstr ""
msgctxt "#70730"
msgid ""
msgstr "Seleziona il metodo di rinumerazione"
msgctxt "#70731"
msgid ""
msgstr "Semi-Automatico"
msgctxt "#70732"
msgid ""
msgstr "Manuale"
msgctxt "#70733"
msgid ""
msgstr "Digita il numero della Serie"
msgctxt "#70734"
msgid ""
msgstr "Seleziona gli Episodi della Serie %s"
msgctxt "#70735"
msgid ""
msgstr "Numero dell'Episodio Speciale"

View File

@@ -5636,3 +5636,27 @@ msgstr "Includi in Ricerca Globale"
msgctxt "#70729"
msgid "Always add the highest quality"
msgstr "Aggiungi sempre la qualità più alta"
msgctxt "#70730"
msgid "Select the renumbering method"
msgstr "Seleziona il metodo di rinumerazione"
msgctxt "#70731"
msgid "Semi-Automatic"
msgstr "Semi-Automatico"
msgctxt "#70732"
msgid "Manual"
msgstr "Manuale"
msgctxt "#70733"
msgid "Enter the Series number"
msgstr "Digita il numero della Serie"
msgctxt "#70734"
msgid "Select Series %s Episodes"
msgstr "Seleziona gli Episodi della Serie %s"
msgctxt "#70735"
msgid "%s Special Episode Number"
msgstr "Numero dell'Episodio Speciale"

View File

@@ -46,6 +46,8 @@ TAG_SPECIAL = "Special"
TAG_MODE = "Mode"
TAG_EPLIST = "EpList"
TAG_CHECK = "ReCheck"
TAG_SPLIST = "SpList"
TAG_TYPE = "Type"
__channel__ = "autorenumber"
@@ -61,11 +63,77 @@ 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": "semiautomatic_config_item",
"action": "select_type",
"channel": "autorenumber",}]
return _context
def select_type(item):
select = platformtools.dialog_select(config.get_localized_string(70730),[config.get_localized_string(70731), config.get_localized_string(70732)])
if select == 0: semiautomatic_config_item(item)
else: manual_renumeration(item)
def manual_renumeration(item):
log()
_list = []
EpisodeDict = {}
item.channel = item.from_channel
title = item.show if item.show else item.fulltitle
dict_series = jsontools.get_node_from_file(item.channel, TAG_TVSHOW_RENUMERATE)
dict_series[title] = {}
dict_series[title][TAG_TYPE] = 'manual'
jsontools.update_node(dict_series, item.channel, TAG_TVSHOW_RENUMERATE)[0]
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
channel = __import__('channels.' + item.channel, fromlist=["channels.%s" % item.channel])
itemlist = channel.episodios(item)
for item in itemlist:
Title = re.sub(r'\d+x\d+ - ', '', item.title)
if item.action == 'findvideos':
_list.append(Title)
count = 1
while len(_list) > 0:
season = platformtools.dialog_numeric(0, config.get_localized_string(70733))
selected = platformtools.dialog_multiselect(config.get_localized_string(70734) % season, _list)
if selected == None: break
for select in selected:
ep = scrapertoolsV2.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[ep] = '%sx%s' %(season, episode.zfill(2))
else:
EpisodeDict[ep] = '%sx%s' %(season, str(count).zfill(2))
count += 1
for select in reversed(selected):
del _list[select]
if len(_list) == 0:
EpisodeDict = base64.b64encode(json.dumps(EpisodeDict))
dict_series[title][TAG_EPISODE] = EpisodeDict
else:
dict_series[title] = {}
jsontools.update_node(dict_series, item.channel, TAG_TVSHOW_RENUMERATE)[0]
xbmc.executebuiltin("Container.Refresh")
def semiautomatic_config_item(item):
log()
# Configurazione Semi Automatica, utile in caso la numerazione automatica fallisca
@@ -75,7 +143,7 @@ def semiautomatic_config_item(item):
dict_series = jsontools.get_node_from_file(item.channel, TAG_TVSHOW_RENUMERATE)
title = item.show
# Trova l'ID dellla serie
# 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
@@ -119,6 +187,7 @@ def semiautomatic_config_item(item):
else: stop = True
dict_renumerate[TAG_MODE] = False
dict_renumerate[TAG_TYPE] = 'auto'
# Imposta la voce Episode
dict_renumerate[TAG_EPISODE] = ''
# Scrive nel json
@@ -173,62 +242,55 @@ def config_item(item, itemlist=[], typography='', active=False):
def renumber(itemlist, item='', typography=''):
log()
# dbg()
if 'fromchannel' in item:
item.channel = item.fromchannel if item.fromchannel else item.channel
# Carica Impostazioni
settings_node = jsontools.get_node_from_file(itemlist[0].channel, 'settings')
try: dict_series = jsontools.get_node_from_file(itemlist[0].channel, TAG_TVSHOW_RENUMERATE)
except: dict_series = {}
# Seleziona la funzione Adatta, Menu Contestuale o Rinumerazione
if item:
settings_node = jsontools.get_node_from_file(item.channel, 'settings')
if 'from_channel' in item:
item.channel = item.from_channel if item.from_channel else item.channel
# Controlla se la Serie è già stata rinumerata
TITLE = item.fulltitle.rstrip() if item.fulltitle else item.contentTitle
if dict_series[TITLE].has_key(TAG_TYPE):
TYPE = dict_series[TITLE][TAG_TYPE]
else:
TYPE = 'auto'
dict_series[TITLE][TAG_TYPE] = TYPE
jsontools.update_node(dict_series, item.channel, TAG_TVSHOW_RENUMERATE)[0]
try:
dict_series = jsontools.get_node_from_file(item.channel, TAG_TVSHOW_RENUMERATE)
TITLE = item.fulltitle.rstrip() if item.fulltitle else item.contentTitle
if TYPE == 'manual':
return itemlist
elif dict_series.has_key(TITLE) and dict_series[TITLE].has_key(TAG_ID):
ID = dict_series[TITLE][TAG_ID]
exist = True
except:
exist = False
if exist:
ID = dict_series[TITLE][TAG_ID]
SEASON = dict_series[TITLE][TAG_SEASON]
EPISODE = dict_series[TITLE][TAG_EPISODE]
MODE = dict_series[TITLE][TAG_MODE]
if dict_series[TITLE].has_key(TAG_SEASON): SEASON = dict_series[TITLE][TAG_SEASON]
else: SEASON = ''
if dict_series[TITLE].has_key(TAG_MODE): MODE = dict_series[TITLE][TAG_MODE]
else: MODE = False
renumeration(itemlist, item, typography, dict_series, ID, SEASON, EPISODE, MODE, TITLE)
else:
# se non è stata rinumerata controlla se è attiva la rinumerazione automatica
if 'autorenumber' not in settings_node: return itemlist
if 'autorenumber' not in settings_node:
return itemlist
if settings_node['autorenumber'] == True:
config_item(item, itemlist, typography, True)
# if exist:
# menu_title= config.get_localized_string(70714) + config.get_localized_string(70585)
# else:
# menu_title= config.get_localized_string(70585)
# from core.item import Item
# from channelselector import thumb
# itemlist.append(
# Item(channel='autorenumber',
# from_channel=item.channel,
# action = 'semiautomatic_config_item',
# contentType=item.contentType,
# title=typo(menu_title, 'color kod bold'),
# fulltitle= item.fulltitle,
# show= item.show,
# url=item.url,
# args=item.args,
# thumbnail=thumb()))
else:
for item in itemlist:
try:
dict_series = jsontools.get_node_from_file(itemlist[0].channel, TAG_TVSHOW_RENUMERATE)
TITLE = item.show.rstrip()
TITLE = item.show.rstrip()
if dict_series.has_key(TITLE) and dict_series[TITLE].has_key(TAG_ID):
ID = dict_series[TITLE][TAG_ID]
exist = True
except:
else:
exist = False
if item.contentType != 'movie':
if item.context:
context2 = item.context
@@ -239,6 +301,7 @@ def renumber(itemlist, item='', typography=''):
item.context = context(exist)
def renumeration (itemlist, item, typography, dict_series, ID, SEASON, EPISODE, MODE, TITLE):
# Se ID è 0 salta la rinumerazione
if ID == '0':
return itemlist

View File

@@ -814,7 +814,7 @@ def save_download(item):
del item.from_action
del item.from_channel
item.contentChannel = item.fromchannel if item.fromchannel else item.channel
item.contentChannel = item.from_channel if item.from_channel else item.channel
item.contentAction = item.fromaction if item.fromaction else item.action
if item.contentType in ["tvshow", "episode", "season"]: