Nuova Rinumerazione Automatica
This commit is contained in:
@@ -57,6 +57,22 @@
|
||||
"enabled": true,
|
||||
"visible": true,
|
||||
"lvalues": ["Non filtrare", "IT"]
|
||||
},
|
||||
{
|
||||
"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)"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ def mainlist(item):
|
||||
|
||||
autoplay.init(item.channel, list_servers, list_quality)
|
||||
autoplay.show_option(item.channel, itemlist)
|
||||
support.channel_config(item, itemlist)
|
||||
|
||||
return itemlist
|
||||
|
||||
|
||||
@@ -65,6 +65,22 @@
|
||||
"enabled": true,
|
||||
"visible": true,
|
||||
"lvalues": ["Non filtrare","IT"]
|
||||
},
|
||||
{
|
||||
"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)"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -65,6 +65,22 @@
|
||||
"enabled": true,
|
||||
"visible": true,
|
||||
"lvalues": ["No filtrar","Italiano"]
|
||||
}
|
||||
},
|
||||
{
|
||||
"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)"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -278,7 +278,7 @@ def episodios(item):
|
||||
thumbnail=item.thumbnail,
|
||||
number=scrapedtitle))
|
||||
|
||||
autorenumber.renumber(itemlist, item,'bold')
|
||||
autorenumber.renumber(itemlist, item, 'bold')
|
||||
support.videolibrary(itemlist, item)
|
||||
return itemlist
|
||||
|
||||
|
||||
@@ -31,6 +31,22 @@
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"visible": true
|
||||
},
|
||||
{
|
||||
"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)"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -69,7 +69,8 @@ def newest(categoria):
|
||||
|
||||
def peliculas(item):
|
||||
itemlist = scrape(item, r'Lingua[^<]+<br>\s*<a href="(?:Lista episodi )?([^"]+)" title="(?:Lista episodi )?(.*?)(?: \(([0-9]+)\))?(?: Streaming)?">', ['url', 'title', 'year'], action='episodios', patron_block='<input type="submit" value="Vai!" class="blueButton">(.*?)<div class="footer">', patronNext='<li class="currentPage">[^>]+><li[^<]+<a href="([^"]+)">')
|
||||
return renumber(itemlist)
|
||||
renumber(itemlist)
|
||||
return itemlist
|
||||
|
||||
|
||||
def last(item):
|
||||
@@ -94,7 +95,8 @@ def categorie(item):
|
||||
|
||||
def episodios(item):
|
||||
itemlist = scrape(item, r'<li><a href="([^"]+)"[^<]+<b>(.*?)<\/b>[^>]+>([^<]+)<\/i>', ['url','title','title2'], patron_block='<div class="seasonEp">(.*?)<div class="footer">')
|
||||
return renumber(itemlist, item, 'bold')
|
||||
renumber(itemlist, item, 'bold')
|
||||
return itemlist
|
||||
|
||||
def findvideos(item):
|
||||
log()
|
||||
|
||||
@@ -58,6 +58,22 @@
|
||||
"enabled": true,
|
||||
"visible": true,
|
||||
"lvalues": ["Non filtrare","IT"]
|
||||
}
|
||||
},
|
||||
{
|
||||
"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)"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -136,7 +136,8 @@ def peliculas(item):
|
||||
else:
|
||||
patron = r'<div class="media3">[^>]+><a href="([^"]+)"><img[^s]+src="([^"]+)"[^>]+><\/a><[^>]+><a[^<]+><p>([^<]+) \(([^\)]+)[^<]+<\/p>.*?<p>\s*([a-zA-Z-0-9]+)\s*<\/p>'
|
||||
itemlist = support.scrape(item, patron, ['url', 'thumb', 'title', 'year', 'quality'], headers, action=action, patronNext='<a class="nextpostslink" rel="next" href="([^"]+)">')
|
||||
return autorenumber.renumber(itemlist) if item.args == 'anime' else itemlist
|
||||
if item.args == 'anime': autorenumber.renumber(itemlist)
|
||||
return itemlist
|
||||
|
||||
|
||||
def episodios(item):
|
||||
|
||||
@@ -93,6 +93,14 @@ msgctxt "#30021"
|
||||
msgid "Number of links to check"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "#30022"
|
||||
msgid "YES"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "#30023"
|
||||
msgid "NO"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "#30043"
|
||||
msgid "Force view mode:"
|
||||
msgstr ""
|
||||
@@ -5035,7 +5043,7 @@ msgid "Do you want to update Quasar to avoid errors?"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "#70585"
|
||||
msgid "[B]Renumbering[/B] (beta)"
|
||||
msgid "Renumbering"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "#70586"
|
||||
@@ -5454,11 +5462,11 @@ msgid "Enter the number of the starting season"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "#70687"
|
||||
msgid "Enter the number of the starting episode"
|
||||
msgid "Special Episodes"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "#70688"
|
||||
msgid "Episode 0 is a special episode, enter the number of this episode (0 to skip it)"
|
||||
msgid "Are there special episodes in the series \n(Episode 0 Excluded)?"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "#70689"
|
||||
@@ -5543,4 +5551,16 @@ msgstr ""
|
||||
|
||||
msgctxt "#70711"
|
||||
msgid "Ops! There's been a problem during saving your setting"
|
||||
msgstr ""
|
||||
msgstr ""
|
||||
|
||||
msgctxt "#70712"
|
||||
msgid "Enable Automatic Renumbering"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "#70713"
|
||||
msgid "There is not enough information on TVDB for renumbering"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "#70714"
|
||||
msgid "Modify "
|
||||
msgstr " "
|
||||
@@ -93,6 +93,14 @@ msgctxt "#30021"
|
||||
msgid "Number of links to check"
|
||||
msgstr "Numero di link da verificare"
|
||||
|
||||
msgctxt "#30022"
|
||||
msgid "YES"
|
||||
msgstr "SÌ"
|
||||
|
||||
msgctxt "#30023"
|
||||
msgid "NO"
|
||||
msgstr "NO"
|
||||
|
||||
msgctxt "#30043"
|
||||
msgid "Force view mode:"
|
||||
msgstr "Forza modalità di visualizzazione:"
|
||||
@@ -5034,8 +5042,8 @@ msgid "Do you want to update Quasar to avoid errors?"
|
||||
msgstr "Vuoi aggiornare Quasar per evitare errori?"
|
||||
|
||||
msgctxt "#70585"
|
||||
msgid "[B]Renumbering[/B] (beta)"
|
||||
msgstr "[B]Rinumerazione[/B] (beta)"
|
||||
msgid "Renumbering"
|
||||
msgstr "Rinumerazione"
|
||||
|
||||
msgctxt "#70586"
|
||||
msgid "Set up series number..."
|
||||
@@ -5453,12 +5461,12 @@ msgid "Enter the number of the starting season"
|
||||
msgstr "Inserisci il numero della stagione di partenza"
|
||||
|
||||
msgctxt "#70687"
|
||||
msgid "Enter the number of the starting episode"
|
||||
msgstr "Inserisci il numero dell'episodio di partenza"
|
||||
msgid "Special Episodes"
|
||||
msgstr "Episodi Speciali"
|
||||
|
||||
msgctxt "#70688"
|
||||
msgid "Episode 0 is a special episode, enter the number of this episode (0 to skip it)"
|
||||
msgstr "L'episodio 0 è un episodio speciale, inserisci il numero di questo episodio (0 per saltare)"
|
||||
msgid "Are there special episodes in the series \n(Episode 0 Excluded)?"
|
||||
msgstr "Sono presenti episodi speciali nella serie \n(Episodio 0 Escluso)?"
|
||||
|
||||
msgctxt "#70689"
|
||||
msgid "Enable Download"
|
||||
@@ -5542,4 +5550,16 @@ msgstr "Le nuove impostazioni sono state salvate"
|
||||
|
||||
msgctxt "#70710"
|
||||
msgid "Ops! There's been a problem during saving your setting"
|
||||
msgstr "Ops! C'è stato un problema durante il salvataggio delle impostazioni"
|
||||
msgstr "Ops! C'è stato un problema durante il salvataggio delle impostazioni"
|
||||
|
||||
msgctxt "#70712"
|
||||
msgid "Enable Automatic Renumbering"
|
||||
msgstr "Abilita Rinumerazione Automatica"
|
||||
|
||||
msgctxt "#70713"
|
||||
msgid "There is not enough information on TVDB for renumbering"
|
||||
msgstr "Non ci sono Abbastanza informazioni su TVDB per la Rinumerazione"
|
||||
|
||||
msgctxt "#70714"
|
||||
msgid "Modify "
|
||||
msgstr "Modifica "
|
||||
@@ -3,20 +3,42 @@
|
||||
# autorenumber - Rinomina Automaticamente gli Episodi
|
||||
# --------------------------------------------------------------------------------
|
||||
|
||||
try:
|
||||
import xbmcgui
|
||||
except:
|
||||
xbmcgui = None
|
||||
'''
|
||||
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": "Abilita Rinumerazione Automatica",
|
||||
"default": false,
|
||||
"enabled": true,
|
||||
"visible": true
|
||||
},
|
||||
{
|
||||
"id": "autorenumber_mode",
|
||||
"type": "bool",
|
||||
"label": "Sono presenti episodi speciali nella serie (Episodio 0 Escluso)?",
|
||||
"default": false,
|
||||
"enabled": true,
|
||||
"visible": "eq(-1,true)"
|
||||
}
|
||||
'''
|
||||
|
||||
import re, base64, json
|
||||
from core import jsontools, tvdb, scrapertoolsV2
|
||||
from core.support import typo, log
|
||||
from platformcode import config
|
||||
from platformcode import platformtools
|
||||
# from datetime import datetime
|
||||
from platformcode import config, platformtools
|
||||
from platformcode.config import get_setting
|
||||
|
||||
TAG_TVSHOW_RENUMERATE = "TVSHOW_AUTORENUMBER"
|
||||
TAG_ID = "ID"
|
||||
TAG_SEASON = "Season"
|
||||
TAG_EPISODE = "Episode"
|
||||
TAG_MODE = "Mode"
|
||||
|
||||
__channel__ = "autorenumber"
|
||||
|
||||
def access():
|
||||
@@ -28,150 +50,260 @@ def access():
|
||||
return allow
|
||||
|
||||
|
||||
def context():
|
||||
def context(exist):
|
||||
if access():
|
||||
_context = [{"title": config.get_localized_string(70585),
|
||||
"action": "config_item",
|
||||
modify = config.get_localized_string(70714) if exist else ''
|
||||
_context = [{"title": typo(modify + config.get_localized_string(70585), 'bold'),
|
||||
"action": "manual_config_item",
|
||||
"channel": "autorenumber"}]
|
||||
|
||||
return _context
|
||||
|
||||
|
||||
def config_item(item):
|
||||
def manual_config_item(item):
|
||||
# Configurazione Semi Automatica, utile in caso la numerazione automatica fallisca
|
||||
|
||||
log(item)
|
||||
tvdb.find_and_set_infoLabels(item)
|
||||
data = []
|
||||
item.channel = item.from_channel
|
||||
dict_series = jsontools.get_node_from_file(item.channel, TAG_TVSHOW_RENUMERATE)
|
||||
title = item.show
|
||||
count = 0
|
||||
|
||||
# Trova l'ID dellla serie
|
||||
while not item.infoLabels['tvdb_id']:
|
||||
try:
|
||||
item.show = platformtools.dialog_input(default=item.show, heading=config.get_localized_string(30112))
|
||||
tvdb.find_and_set_infoLabels(item)
|
||||
count = count + 1
|
||||
except:
|
||||
heading = config.get_localized_string(70704)
|
||||
item.infoLabels['tvdb_id'] = platformtools.dialog_numeric(0, heading)
|
||||
data.append(item.infoLabels['tvdb_id'])
|
||||
if item.infoLabels['tvdb_id'] != '':
|
||||
write_data(item.from_channel, title, item.infoLabels['tvdb_id'])
|
||||
|
||||
|
||||
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)
|
||||
season = platformtools.dialog_numeric(0, heading, '0')
|
||||
dict_renumerate[TAG_SEASON] = season
|
||||
elif RepresentsInt(title.split()[-1]):
|
||||
heading = config.get_localized_string(70686)
|
||||
season = platformtools.dialog_numeric(0, heading, title.split()[-1])
|
||||
dict_renumerate[TAG_SEASON] = season
|
||||
else:
|
||||
heading = config.get_localized_string(70686)
|
||||
season = platformtools.dialog_numeric(0, heading, '1')
|
||||
dict_renumerate[TAG_SEASON] = season
|
||||
# Richede se ci sono speciali nella stagione
|
||||
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 == 0: dict_renumerate[TAG_MODE] = False
|
||||
else: dict_renumerate[TAG_MODE] = True
|
||||
# Imposta la voce Episode
|
||||
dict_renumerate[TAG_EPISODE] = []
|
||||
# Scrive nel json
|
||||
jsontools.update_node(dict_series, item.channel, TAG_TVSHOW_RENUMERATE)[0]
|
||||
|
||||
else:
|
||||
message = config.get_localized_string(60444)
|
||||
heading = item.show.strip()
|
||||
platformtools.dialog_notification(heading, message)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def write_data(channel, show, ID):
|
||||
def config_item(item, itemlist=[], typography='', active=False):
|
||||
# Configurazione Automatica, Tenta la numerazione Automatica degli episodi
|
||||
log()
|
||||
dict_series = jsontools.get_node_from_file(channel, TAG_TVSHOW_RENUMERATE)
|
||||
tvshow = show.strip()
|
||||
title = item.fulltitle
|
||||
|
||||
if ID:
|
||||
dict_renumerate = {TAG_ID: ID}
|
||||
dict_series[tvshow] = dict_renumerate
|
||||
else:
|
||||
dict_series.pop(tvshow, None)
|
||||
|
||||
# Cerca di individuare la serie dal titolo
|
||||
if any( word in show.lower() for word in ['special', 'specials', 'speciali', 'speciale'] ):
|
||||
heading = config.get_localized_string(70686)
|
||||
season = platformtools.dialog_numeric(0, heading, '0')
|
||||
dict_renumerate[TAG_SEASON] = season
|
||||
elif RepresentsInt(show.split()[-1]):
|
||||
heading = config.get_localized_string(70686)
|
||||
season = platformtools.dialog_numeric(0, heading, show.split()[-1])
|
||||
dict_renumerate[TAG_SEASON] = season
|
||||
else: dict_renumerate[TAG_SEASON] = '1'
|
||||
dict_series = jsontools.get_node_from_file(item.channel, TAG_TVSHOW_RENUMERATE)
|
||||
try:
|
||||
ID = dict_series[item.show.rstrip()][TAG_ID]
|
||||
except:
|
||||
ID = ''
|
||||
|
||||
|
||||
result = jsontools.update_node(dict_series, channel, TAG_TVSHOW_RENUMERATE)[0]
|
||||
# Pulizia del Titolo
|
||||
if any( word in title.lower() for word in ['specials', 'speciali']):
|
||||
item.show = re.sub(r'\sspecials|\sspeciali', '', item.show.lower())
|
||||
log('ITEM SHOW= ',item.show)
|
||||
tvdb.find_and_set_infoLabels(item)
|
||||
elif not item.infoLabels['tvdb_id']:
|
||||
item.show = title.rstrip('123456789 ')
|
||||
tvdb.find_and_set_infoLabels(item)
|
||||
|
||||
if result:
|
||||
if ID:
|
||||
message = config.get_localized_string(60446)
|
||||
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] = []
|
||||
settings_node = jsontools.get_node_from_file(item.channel, 'settings')
|
||||
dict_renumerate[TAG_MODE] = settings_node['autorenumber_mode']
|
||||
jsontools.update_node(dict_series, item.channel, TAG_TVSHOW_RENUMERATE)[0]
|
||||
return renumber(itemlist, item, typography)
|
||||
else:
|
||||
message = config.get_localized_string(60444)
|
||||
else:
|
||||
message = config.get_localized_string(70593)
|
||||
|
||||
heading = show.strip()
|
||||
platformtools.dialog_notification(heading, message)
|
||||
return itemlist
|
||||
|
||||
else:
|
||||
return renumber(itemlist, item, typography)
|
||||
|
||||
|
||||
def renumber(itemlist, item='', typography=''):
|
||||
log()
|
||||
|
||||
# Seleziona la funzione Adatta, Menu Contestuale o Rinumerazione
|
||||
# import web_pdb; web_pdb.set_trace()
|
||||
if item:
|
||||
settings_node = jsontools.get_node_from_file(item.channel, 'settings')
|
||||
# Controlla se la Serie è già stata rinumerata
|
||||
|
||||
try:
|
||||
dict_series = jsontools.get_node_from_file(item.channel, TAG_TVSHOW_RENUMERATE)
|
||||
ID = dict_series[item.show.rstrip()]['ID']
|
||||
SEASON = dict_series[item.show.rstrip()]['Season']
|
||||
|
||||
page = 1
|
||||
epDict = {}
|
||||
epList = []
|
||||
exist = True
|
||||
item.infoLabels['tvdb_id'] = ID
|
||||
tvdb.set_infoLabels_item(item)
|
||||
ep = 1
|
||||
|
||||
while exist:
|
||||
data = tvdb.otvdb_global.get_list_episodes(ID,page)
|
||||
log(data)
|
||||
if data:
|
||||
for episodes in data['data']:
|
||||
log(episodes)
|
||||
if hasattr(episodes,'absoluteNumber'): ABS = episodes['absoluteNumber']
|
||||
else: ABS = str(ep)
|
||||
epDict[str(ABS)] = [str(episodes['airedSeason']) + 'x' + str(episodes['airedEpisodeNumber']), episodes['firstAired']]
|
||||
epList.append(episodes['firstAired'])
|
||||
ep = ep + 1
|
||||
|
||||
page = page + 1
|
||||
else:
|
||||
exist = False
|
||||
log(epDict)
|
||||
epList.sort()
|
||||
log(epList)
|
||||
TITLE = item.fulltitle.rstrip()
|
||||
ID = dict_series[TITLE][TAG_ID]
|
||||
|
||||
if SEASON:
|
||||
for name, episode in epDict.items():
|
||||
if episode[0] == SEASON + 'x1':
|
||||
ep = int(name)-1
|
||||
else:
|
||||
ep = 0
|
||||
|
||||
if SEASON != '0':
|
||||
for item in itemlist:
|
||||
number = int(scrapertoolsV2.find_single_match(item.title, r'\d+'))
|
||||
episode = str(ep + number)
|
||||
if number == 0:
|
||||
episode = previous(epList, epDict, str(ep + 1))
|
||||
item.title = typo(epDict[episode][0] + ' - ', typography) + item.title
|
||||
else:
|
||||
for item in itemlist:
|
||||
number = scrapertoolsV2.find_single_match(item.title, r'\d+')
|
||||
item.title = typo('0x' + number + ' - ', typography) + item.title
|
||||
|
||||
exist = True
|
||||
except:
|
||||
return itemlist
|
||||
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]
|
||||
return 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 settings_node['autorenumber'] == True:
|
||||
config_item(item, itemlist, typography, True)
|
||||
else:
|
||||
for item in itemlist:
|
||||
try:
|
||||
dict_series = jsontools.get_node_from_file(itemlist[0].channel, TAG_TVSHOW_RENUMERATE)
|
||||
TITLE = item.show.rstrip()
|
||||
ID = dict_series[TITLE][TAG_ID]
|
||||
exist = True
|
||||
except:
|
||||
exist = False
|
||||
if item.contentType != 'movie':
|
||||
if item.context:
|
||||
context2 = item.context
|
||||
item.context = context() + context2
|
||||
item.context = context(exist) + context2
|
||||
else:
|
||||
item.context = context()
|
||||
item.context = context(exist)
|
||||
|
||||
def renumeration (itemlist, item, typography, dict_series, ID, SEASON, EPISODE, MODE, TITLE):
|
||||
# import web_pdb; web_pdb.set_trace()
|
||||
# Se ID è 0 salta la rinumerazione
|
||||
if ID == '0':
|
||||
return itemlist
|
||||
|
||||
# Numerazione per gli Speciali
|
||||
elif SEASON == '0':
|
||||
EpisodeDict = {}
|
||||
for item in itemlist:
|
||||
number = scrapertoolsV2.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:
|
||||
log('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)
|
||||
log(len(EpisodeDict))
|
||||
log(len(itemlist))
|
||||
if len(EpisodeDict) == len(itemlist):
|
||||
for item in itemlist:
|
||||
number = scrapertoolsV2.find_single_match(item.title, r'\d+')
|
||||
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 make_list(itemlist, item, typography, dict_series, ID, SEASON, EPISODE, MODE, TITLE):
|
||||
log('RINUMERAZIONE')
|
||||
page = 1
|
||||
EpDict = {}
|
||||
EpDateList = []
|
||||
EpList = []
|
||||
EpisodeDict = {}
|
||||
exist = True
|
||||
item.infoLabels['tvdb_id'] = ID
|
||||
tvdb.set_infoLabels_item(item)
|
||||
ABS = 0
|
||||
ep = 1
|
||||
|
||||
# Ricava Informazioni da TVDB
|
||||
while exist:
|
||||
data = tvdb.otvdb_global.get_list_episodes(ID,page)
|
||||
log('DATA= ',data)
|
||||
if data: page = page + 1
|
||||
else: exist = False
|
||||
|
||||
if data:
|
||||
for episodes in data['data']:
|
||||
log(episodes)
|
||||
try: ABS = int(episodes['absoluteNumber'])
|
||||
except: ABS = ep
|
||||
EpDict[str(ABS)] = [str(episodes['airedSeason']) + 'x' + str(episodes['airedEpisodeNumber']), episodes['firstAired']]
|
||||
EpDateList.append(episodes['firstAired'])
|
||||
EpList.append([int(ABS), episodes['airedSeason'], episodes['airedEpisodeNumber']])
|
||||
ep = ep + 1
|
||||
EpDateList.sort()
|
||||
EpList.sort()
|
||||
log(EpDateList)
|
||||
log(EpDict)
|
||||
log(EpList)
|
||||
|
||||
# seleziona l'Episodio di partenza
|
||||
if int(SEASON) > 1:
|
||||
for name, episode in EpDict.items():
|
||||
if episode[0] == SEASON + 'x1':
|
||||
ep = int(name)-1
|
||||
else:
|
||||
ep = 0
|
||||
|
||||
# rinumera gli episodi
|
||||
|
||||
for item in itemlist:
|
||||
number = int(scrapertoolsV2.find_single_match(item.title, r'\d+'))
|
||||
episode = ep + number - 1
|
||||
if len(EpList) < episode: return error(itemlist)
|
||||
# Crea una lista di Episodi in base alla modalità di rinumerazione
|
||||
if MODE == False and number != 0:
|
||||
while EpList[episode][1] == 0 or len(EpList) < episode:
|
||||
episode = episode + 1
|
||||
ep = ep + 1
|
||||
elif number == 0:
|
||||
episode = previous(EpDateList, EpDict, ep + 1)
|
||||
|
||||
if config.get_localized_string(30161) not in item.title:
|
||||
EpisodeDict[str(number)] = (str(EpList[episode][1]) + 'x' + str(EpList[episode][2]))
|
||||
item.title = typo(str(EpList[episode][1]) + 'x' + str(EpList[episode][2]) + ' - ', typography) + item.title
|
||||
|
||||
# Scrive sul json
|
||||
EpisodeDict = base64.b64encode(json.dumps(EpisodeDict))
|
||||
dict_series[TITLE][TAG_EPISODE] = EpisodeDict
|
||||
jsontools.update_node(dict_series, item.channel, TAG_TVSHOW_RENUMERATE)[0]
|
||||
|
||||
return itemlist
|
||||
|
||||
|
||||
|
||||
|
||||
def RepresentsInt(s):
|
||||
# Controllo Numro Stagione
|
||||
log()
|
||||
try:
|
||||
int(s)
|
||||
return True
|
||||
@@ -179,10 +311,12 @@ def RepresentsInt(s):
|
||||
return False
|
||||
|
||||
def previous(date_list, Dict, search):
|
||||
log('Start')
|
||||
# Seleziona Eventuale Episodio 0
|
||||
log()
|
||||
P = None
|
||||
result = 0
|
||||
for ep, variants in Dict.items():
|
||||
if variants[1] == Dict[search][1]:
|
||||
if variants[1] == Dict[str(search)][1]:
|
||||
date = variants[1]
|
||||
for index, obj in enumerate(date_list):
|
||||
if obj == date:
|
||||
@@ -191,6 +325,11 @@ def previous(date_list, Dict, search):
|
||||
for name, variants in Dict.items():
|
||||
log(variants[1], ' = ', P)
|
||||
if variants[1] == P:
|
||||
result = name
|
||||
log(result)
|
||||
return result
|
||||
result = int(name)-1
|
||||
return result
|
||||
|
||||
def error(itemlist):
|
||||
message = config.get_localized_string(70713)
|
||||
heading = itemlist[0].fulltitle.strip()
|
||||
platformtools.dialog_notification(heading, message)
|
||||
return itemlist
|
||||
Reference in New Issue
Block a user