Nuova Rinumerazione Automatica
This commit is contained in:
@@ -57,6 +57,22 @@
|
|||||||
"enabled": true,
|
"enabled": true,
|
||||||
"visible": true,
|
"visible": true,
|
||||||
"lvalues": ["Non filtrare", "IT"]
|
"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.init(item.channel, list_servers, list_quality)
|
||||||
autoplay.show_option(item.channel, itemlist)
|
autoplay.show_option(item.channel, itemlist)
|
||||||
|
support.channel_config(item, itemlist)
|
||||||
|
|
||||||
return itemlist
|
return itemlist
|
||||||
|
|
||||||
|
|||||||
@@ -65,6 +65,22 @@
|
|||||||
"enabled": true,
|
"enabled": true,
|
||||||
"visible": true,
|
"visible": true,
|
||||||
"lvalues": ["Non filtrare","IT"]
|
"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,
|
"enabled": true,
|
||||||
"visible": true,
|
"visible": true,
|
||||||
"lvalues": ["No filtrar","Italiano"]
|
"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,
|
thumbnail=item.thumbnail,
|
||||||
number=scrapedtitle))
|
number=scrapedtitle))
|
||||||
|
|
||||||
autorenumber.renumber(itemlist, item,'bold')
|
autorenumber.renumber(itemlist, item, 'bold')
|
||||||
support.videolibrary(itemlist, item)
|
support.videolibrary(itemlist, item)
|
||||||
return itemlist
|
return itemlist
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,22 @@
|
|||||||
"default": true,
|
"default": true,
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"visible": 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):
|
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="([^"]+)">')
|
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):
|
def last(item):
|
||||||
@@ -94,7 +95,8 @@ def categorie(item):
|
|||||||
|
|
||||||
def episodios(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">')
|
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):
|
def findvideos(item):
|
||||||
log()
|
log()
|
||||||
|
|||||||
@@ -58,6 +58,22 @@
|
|||||||
"enabled": true,
|
"enabled": true,
|
||||||
"visible": true,
|
"visible": true,
|
||||||
"lvalues": ["Non filtrare","IT"]
|
"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:
|
else:
|
||||||
patron = r'<div class="media3">[^>]+><a href="([^"]+)"><img[^s]+src="([^"]+)"[^>]+><\/a><[^>]+><a[^<]+><p>([^<]+) \(([^\)]+)[^<]+<\/p>.*?<p>\s*([a-zA-Z-0-9]+)\s*<\/p>'
|
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="([^"]+)">')
|
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):
|
def episodios(item):
|
||||||
|
|||||||
@@ -93,6 +93,14 @@ msgctxt "#30021"
|
|||||||
msgid "Number of links to check"
|
msgid "Number of links to check"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgctxt "#30022"
|
||||||
|
msgid "YES"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
msgctxt "#30023"
|
||||||
|
msgid "NO"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgctxt "#30043"
|
msgctxt "#30043"
|
||||||
msgid "Force view mode:"
|
msgid "Force view mode:"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -5035,7 +5043,7 @@ msgid "Do you want to update Quasar to avoid errors?"
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgctxt "#70585"
|
msgctxt "#70585"
|
||||||
msgid "[B]Renumbering[/B] (beta)"
|
msgid "Renumbering"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgctxt "#70586"
|
msgctxt "#70586"
|
||||||
@@ -5454,11 +5462,11 @@ msgid "Enter the number of the starting season"
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgctxt "#70687"
|
msgctxt "#70687"
|
||||||
msgid "Enter the number of the starting episode"
|
msgid "Special Episodes"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgctxt "#70688"
|
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 ""
|
msgstr ""
|
||||||
|
|
||||||
msgctxt "#70689"
|
msgctxt "#70689"
|
||||||
@@ -5544,3 +5552,15 @@ msgstr ""
|
|||||||
msgctxt "#70711"
|
msgctxt "#70711"
|
||||||
msgid "Ops! There's been a problem during saving your setting"
|
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"
|
msgid "Number of links to check"
|
||||||
msgstr "Numero di link da verificare"
|
msgstr "Numero di link da verificare"
|
||||||
|
|
||||||
|
msgctxt "#30022"
|
||||||
|
msgid "YES"
|
||||||
|
msgstr "SÌ"
|
||||||
|
|
||||||
|
msgctxt "#30023"
|
||||||
|
msgid "NO"
|
||||||
|
msgstr "NO"
|
||||||
|
|
||||||
msgctxt "#30043"
|
msgctxt "#30043"
|
||||||
msgid "Force view mode:"
|
msgid "Force view mode:"
|
||||||
msgstr "Forza modalità di visualizzazione:"
|
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?"
|
msgstr "Vuoi aggiornare Quasar per evitare errori?"
|
||||||
|
|
||||||
msgctxt "#70585"
|
msgctxt "#70585"
|
||||||
msgid "[B]Renumbering[/B] (beta)"
|
msgid "Renumbering"
|
||||||
msgstr "[B]Rinumerazione[/B] (beta)"
|
msgstr "Rinumerazione"
|
||||||
|
|
||||||
msgctxt "#70586"
|
msgctxt "#70586"
|
||||||
msgid "Set up series number..."
|
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"
|
msgstr "Inserisci il numero della stagione di partenza"
|
||||||
|
|
||||||
msgctxt "#70687"
|
msgctxt "#70687"
|
||||||
msgid "Enter the number of the starting episode"
|
msgid "Special Episodes"
|
||||||
msgstr "Inserisci il numero dell'episodio di partenza"
|
msgstr "Episodi Speciali"
|
||||||
|
|
||||||
msgctxt "#70688"
|
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 "L'episodio 0 è un episodio speciale, inserisci il numero di questo episodio (0 per saltare)"
|
msgstr "Sono presenti episodi speciali nella serie \n(Episodio 0 Escluso)?"
|
||||||
|
|
||||||
msgctxt "#70689"
|
msgctxt "#70689"
|
||||||
msgid "Enable Download"
|
msgid "Enable Download"
|
||||||
@@ -5543,3 +5551,15 @@ msgstr "Le nuove impostazioni sono state salvate"
|
|||||||
msgctxt "#70710"
|
msgctxt "#70710"
|
||||||
msgid "Ops! There's been a problem during saving your setting"
|
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 "
|
||||||
+231
-92
@@ -3,20 +3,42 @@
|
|||||||
# autorenumber - Rinomina Automaticamente gli Episodi
|
# autorenumber - Rinomina Automaticamente gli Episodi
|
||||||
# --------------------------------------------------------------------------------
|
# --------------------------------------------------------------------------------
|
||||||
|
|
||||||
try:
|
'''
|
||||||
import xbmcgui
|
USO:
|
||||||
except:
|
1) utilizzare autorenumber.renumber(itemlist) nelle le funzioni peliculas e similari per aggiungere il menu contestuale
|
||||||
xbmcgui = None
|
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 import jsontools, tvdb, scrapertoolsV2
|
||||||
from core.support import typo, log
|
from core.support import typo, log
|
||||||
from platformcode import config
|
from platformcode import config, platformtools
|
||||||
from platformcode import platformtools
|
from platformcode.config import get_setting
|
||||||
# from datetime import datetime
|
|
||||||
|
|
||||||
TAG_TVSHOW_RENUMERATE = "TVSHOW_AUTORENUMBER"
|
TAG_TVSHOW_RENUMERATE = "TVSHOW_AUTORENUMBER"
|
||||||
TAG_ID = "ID"
|
TAG_ID = "ID"
|
||||||
TAG_SEASON = "Season"
|
TAG_SEASON = "Season"
|
||||||
|
TAG_EPISODE = "Episode"
|
||||||
|
TAG_MODE = "Mode"
|
||||||
|
|
||||||
__channel__ = "autorenumber"
|
__channel__ = "autorenumber"
|
||||||
|
|
||||||
def access():
|
def access():
|
||||||
@@ -28,33 +50,61 @@ def access():
|
|||||||
return allow
|
return allow
|
||||||
|
|
||||||
|
|
||||||
def context():
|
def context(exist):
|
||||||
if access():
|
if access():
|
||||||
_context = [{"title": config.get_localized_string(70585),
|
modify = config.get_localized_string(70714) if exist else ''
|
||||||
"action": "config_item",
|
_context = [{"title": typo(modify + config.get_localized_string(70585), 'bold'),
|
||||||
|
"action": "manual_config_item",
|
||||||
"channel": "autorenumber"}]
|
"channel": "autorenumber"}]
|
||||||
|
|
||||||
return _context
|
return _context
|
||||||
|
|
||||||
|
|
||||||
def config_item(item):
|
def manual_config_item(item):
|
||||||
|
# Configurazione Semi Automatica, utile in caso la numerazione automatica fallisca
|
||||||
|
|
||||||
log(item)
|
log(item)
|
||||||
tvdb.find_and_set_infoLabels(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
|
title = item.show
|
||||||
count = 0
|
|
||||||
|
|
||||||
|
# Trova l'ID dellla serie
|
||||||
while not item.infoLabels['tvdb_id']:
|
while not item.infoLabels['tvdb_id']:
|
||||||
try:
|
try:
|
||||||
item.show = platformtools.dialog_input(default=item.show, heading=config.get_localized_string(30112))
|
item.show = platformtools.dialog_input(default=item.show, heading=config.get_localized_string(30112))
|
||||||
tvdb.find_and_set_infoLabels(item)
|
tvdb.find_and_set_infoLabels(item)
|
||||||
count = count + 1
|
|
||||||
except:
|
except:
|
||||||
heading = config.get_localized_string(70704)
|
heading = config.get_localized_string(70704)
|
||||||
item.infoLabels['tvdb_id'] = platformtools.dialog_numeric(0, heading)
|
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:
|
else:
|
||||||
message = config.get_localized_string(60444)
|
message = config.get_localized_string(60444)
|
||||||
heading = item.show.strip()
|
heading = item.show.strip()
|
||||||
@@ -62,116 +112,198 @@ def config_item(item):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def config_item(item, itemlist=[], typography='', active=False):
|
||||||
|
# Configurazione Automatica, Tenta la numerazione Automatica degli episodi
|
||||||
def write_data(channel, show, ID):
|
|
||||||
log()
|
log()
|
||||||
dict_series = jsontools.get_node_from_file(channel, TAG_TVSHOW_RENUMERATE)
|
title = item.fulltitle
|
||||||
tvshow = show.strip()
|
|
||||||
|
|
||||||
if ID:
|
dict_series = jsontools.get_node_from_file(item.channel, TAG_TVSHOW_RENUMERATE)
|
||||||
|
try:
|
||||||
|
ID = dict_series[item.show.rstrip()][TAG_ID]
|
||||||
|
except:
|
||||||
|
ID = ''
|
||||||
|
|
||||||
|
# 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 not ID and active:
|
||||||
|
if item.infoLabels['tvdb_id']:
|
||||||
|
ID = item.infoLabels['tvdb_id']
|
||||||
dict_renumerate = {TAG_ID: ID}
|
dict_renumerate = {TAG_ID: ID}
|
||||||
dict_series[tvshow] = dict_renumerate
|
dict_series[title] = dict_renumerate
|
||||||
else:
|
# Trova La Stagione
|
||||||
dict_series.pop(tvshow, None)
|
if any( word in title.lower() for word in ['specials', 'speciali']):
|
||||||
|
dict_renumerate[TAG_SEASON] = '0'
|
||||||
# Cerca di individuare la serie dal titolo
|
elif RepresentsInt(title.split()[-1]):
|
||||||
if any( word in show.lower() for word in ['special', 'specials', 'speciali', 'speciale'] ):
|
dict_renumerate[TAG_SEASON] = title.split()[-1]
|
||||||
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'
|
else: dict_renumerate[TAG_SEASON] = '1'
|
||||||
|
dict_renumerate[TAG_EPISODE] = []
|
||||||
|
settings_node = jsontools.get_node_from_file(item.channel, 'settings')
|
||||||
result = jsontools.update_node(dict_series, channel, TAG_TVSHOW_RENUMERATE)[0]
|
dict_renumerate[TAG_MODE] = settings_node['autorenumber_mode']
|
||||||
|
jsontools.update_node(dict_series, item.channel, TAG_TVSHOW_RENUMERATE)[0]
|
||||||
if result:
|
return renumber(itemlist, item, typography)
|
||||||
if ID:
|
|
||||||
message = config.get_localized_string(60446)
|
|
||||||
else:
|
else:
|
||||||
message = config.get_localized_string(60444)
|
return itemlist
|
||||||
|
|
||||||
else:
|
else:
|
||||||
message = config.get_localized_string(70593)
|
return renumber(itemlist, item, typography)
|
||||||
|
|
||||||
heading = show.strip()
|
|
||||||
platformtools.dialog_notification(heading, message)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def 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:
|
if item:
|
||||||
|
settings_node = jsontools.get_node_from_file(item.channel, 'settings')
|
||||||
|
# Controlla se la Serie è già stata rinumerata
|
||||||
|
|
||||||
try:
|
try:
|
||||||
dict_series = jsontools.get_node_from_file(item.channel, TAG_TVSHOW_RENUMERATE)
|
dict_series = jsontools.get_node_from_file(item.channel, TAG_TVSHOW_RENUMERATE)
|
||||||
ID = dict_series[item.show.rstrip()]['ID']
|
TITLE = item.fulltitle.rstrip()
|
||||||
SEASON = dict_series[item.show.rstrip()]['Season']
|
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]
|
||||||
|
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(exist) + context2
|
||||||
|
else:
|
||||||
|
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
|
page = 1
|
||||||
epDict = {}
|
EpDict = {}
|
||||||
epList = []
|
EpDateList = []
|
||||||
|
EpList = []
|
||||||
|
EpisodeDict = {}
|
||||||
exist = True
|
exist = True
|
||||||
item.infoLabels['tvdb_id'] = ID
|
item.infoLabels['tvdb_id'] = ID
|
||||||
tvdb.set_infoLabels_item(item)
|
tvdb.set_infoLabels_item(item)
|
||||||
|
ABS = 0
|
||||||
ep = 1
|
ep = 1
|
||||||
|
|
||||||
|
# Ricava Informazioni da TVDB
|
||||||
while exist:
|
while exist:
|
||||||
data = tvdb.otvdb_global.get_list_episodes(ID,page)
|
data = tvdb.otvdb_global.get_list_episodes(ID,page)
|
||||||
log(data)
|
log('DATA= ',data)
|
||||||
|
if data: page = page + 1
|
||||||
|
else: exist = False
|
||||||
|
|
||||||
if data:
|
if data:
|
||||||
for episodes in data['data']:
|
for episodes in data['data']:
|
||||||
log(episodes)
|
log(episodes)
|
||||||
if hasattr(episodes,'absoluteNumber'): ABS = episodes['absoluteNumber']
|
try: ABS = int(episodes['absoluteNumber'])
|
||||||
else: ABS = str(ep)
|
except: ABS = ep
|
||||||
epDict[str(ABS)] = [str(episodes['airedSeason']) + 'x' + str(episodes['airedEpisodeNumber']), episodes['firstAired']]
|
EpDict[str(ABS)] = [str(episodes['airedSeason']) + 'x' + str(episodes['airedEpisodeNumber']), episodes['firstAired']]
|
||||||
epList.append(episodes['firstAired'])
|
EpDateList.append(episodes['firstAired'])
|
||||||
|
EpList.append([int(ABS), episodes['airedSeason'], episodes['airedEpisodeNumber']])
|
||||||
ep = ep + 1
|
ep = ep + 1
|
||||||
|
EpDateList.sort()
|
||||||
|
EpList.sort()
|
||||||
|
log(EpDateList)
|
||||||
|
log(EpDict)
|
||||||
|
log(EpList)
|
||||||
|
|
||||||
page = page + 1
|
# seleziona l'Episodio di partenza
|
||||||
else:
|
if int(SEASON) > 1:
|
||||||
exist = False
|
for name, episode in EpDict.items():
|
||||||
log(epDict)
|
|
||||||
epList.sort()
|
|
||||||
log(epList)
|
|
||||||
|
|
||||||
if SEASON:
|
|
||||||
for name, episode in epDict.items():
|
|
||||||
if episode[0] == SEASON + 'x1':
|
if episode[0] == SEASON + 'x1':
|
||||||
ep = int(name)-1
|
ep = int(name)-1
|
||||||
else:
|
else:
|
||||||
ep = 0
|
ep = 0
|
||||||
|
|
||||||
if SEASON != '0':
|
# rinumera gli episodi
|
||||||
|
|
||||||
for item in itemlist:
|
for item in itemlist:
|
||||||
number = int(scrapertoolsV2.find_single_match(item.title, r'\d+'))
|
number = int(scrapertoolsV2.find_single_match(item.title, r'\d+'))
|
||||||
episode = str(ep + number)
|
episode = ep + number - 1
|
||||||
if number == 0:
|
if len(EpList) < episode: return error(itemlist)
|
||||||
episode = previous(epList, epDict, str(ep + 1))
|
# Crea una lista di Episodi in base alla modalità di rinumerazione
|
||||||
item.title = typo(epDict[episode][0] + ' - ', typography) + item.title
|
if MODE == False and number != 0:
|
||||||
else:
|
while EpList[episode][1] == 0 or len(EpList) < episode:
|
||||||
for item in itemlist:
|
episode = episode + 1
|
||||||
number = scrapertoolsV2.find_single_match(item.title, r'\d+')
|
ep = ep + 1
|
||||||
item.title = typo('0x' + number + ' - ', typography) + item.title
|
elif number == 0:
|
||||||
|
episode = previous(EpDateList, EpDict, ep + 1)
|
||||||
|
|
||||||
except:
|
if config.get_localized_string(30161) not in item.title:
|
||||||
return itemlist
|
EpisodeDict[str(number)] = (str(EpList[episode][1]) + 'x' + str(EpList[episode][2]))
|
||||||
else:
|
item.title = typo(str(EpList[episode][1]) + 'x' + str(EpList[episode][2]) + ' - ', typography) + item.title
|
||||||
for item in itemlist:
|
|
||||||
if item.contentType != 'movie':
|
# Scrive sul json
|
||||||
if item.context:
|
EpisodeDict = base64.b64encode(json.dumps(EpisodeDict))
|
||||||
context2 = item.context
|
dict_series[TITLE][TAG_EPISODE] = EpisodeDict
|
||||||
item.context = context() + context2
|
jsontools.update_node(dict_series, item.channel, TAG_TVSHOW_RENUMERATE)[0]
|
||||||
else:
|
|
||||||
item.context = context()
|
|
||||||
|
|
||||||
return itemlist
|
return itemlist
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def RepresentsInt(s):
|
def RepresentsInt(s):
|
||||||
|
# Controllo Numro Stagione
|
||||||
|
log()
|
||||||
try:
|
try:
|
||||||
int(s)
|
int(s)
|
||||||
return True
|
return True
|
||||||
@@ -179,10 +311,12 @@ def RepresentsInt(s):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def previous(date_list, Dict, search):
|
def previous(date_list, Dict, search):
|
||||||
log('Start')
|
# Seleziona Eventuale Episodio 0
|
||||||
|
log()
|
||||||
P = None
|
P = None
|
||||||
|
result = 0
|
||||||
for ep, variants in Dict.items():
|
for ep, variants in Dict.items():
|
||||||
if variants[1] == Dict[search][1]:
|
if variants[1] == Dict[str(search)][1]:
|
||||||
date = variants[1]
|
date = variants[1]
|
||||||
for index, obj in enumerate(date_list):
|
for index, obj in enumerate(date_list):
|
||||||
if obj == date:
|
if obj == date:
|
||||||
@@ -191,6 +325,11 @@ def previous(date_list, Dict, search):
|
|||||||
for name, variants in Dict.items():
|
for name, variants in Dict.items():
|
||||||
log(variants[1], ' = ', P)
|
log(variants[1], ' = ', P)
|
||||||
if variants[1] == P:
|
if variants[1] == P:
|
||||||
result = name
|
result = int(name)-1
|
||||||
log(result)
|
|
||||||
return result
|
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