Autorenumber con TMDB
This commit is contained in:
+8
-1
@@ -3,7 +3,7 @@
|
|||||||
# from future import standard_library
|
# from future import standard_library
|
||||||
# standard_library.install_aliases()
|
# standard_library.install_aliases()
|
||||||
# from builtins import str
|
# from builtins import str
|
||||||
import sys
|
import sys, requests
|
||||||
PY3 = False
|
PY3 = False
|
||||||
if sys.version_info[0] >= 3: PY3 = True; unicode = str; unichr = chr; long = int
|
if sys.version_info[0] >= 3: PY3 = True; unicode = str; unichr = chr; long = int
|
||||||
|
|
||||||
@@ -1430,6 +1430,13 @@ class Tmdb(object):
|
|||||||
|
|
||||||
return ret_dic
|
return ret_dic
|
||||||
|
|
||||||
|
def get_list_episodes(self):
|
||||||
|
# from core.support import dbg;dbg()
|
||||||
|
url = 'https://api.themoviedb.org/3/tv/{id}?api_key=a1ab8b8669da03637a4b98fa39c39228&language={lang}'.format(id=self.busqueda_id, lang=self.busqueda_idioma)
|
||||||
|
# url = 'https://api.themoviedb.org/3/tv/{id}/episode_groups?api_key=a1ab8b8669da03637a4b98fa39c39228&language={lang}'.format(id=_id, lang=self.busqueda_idioma)
|
||||||
|
results = requests.get(url).json()['seasons']
|
||||||
|
return results if 'Error' not in results else {}
|
||||||
|
|
||||||
def get_videos(self):
|
def get_videos(self):
|
||||||
"""
|
"""
|
||||||
:return: Returns an ordered list (language / resolution / type) of Dict objects in which each of its elements corresponds to a trailer, teaser or clip from youtube.
|
:return: Returns an ordered list (language / resolution / type) of Dict objects in which each of its elements corresponds to a trailer, teaser or clip from youtube.
|
||||||
|
|||||||
+134
-196
@@ -5,23 +5,21 @@
|
|||||||
|
|
||||||
|
|
||||||
import xbmc, xbmcgui, re, base64, inspect, sys
|
import xbmc, xbmcgui, re, base64, inspect, sys
|
||||||
from core import jsontools, tvdb, scrapertools, filetools
|
from core import jsontools, tmdb, scrapertools, filetools
|
||||||
from core.item import Item
|
from core.item import Item
|
||||||
from core.support import typo, match, dbg, Item
|
from core.support import typo, match, dbg, Item
|
||||||
from platformcode import config, platformtools, logger
|
from platformcode import config, platformtools, logger
|
||||||
PY3 = True if sys.version_info[0] >= 3 else False
|
PY3 = True if sys.version_info[0] >= 3 else False
|
||||||
|
|
||||||
# Json Var
|
# Json Var
|
||||||
TVSHOW_RENUMERATE = "TVSHOW_AUTORENUMBER"
|
RENUMBER = 'TVSHOW_AUTORENUMBER'
|
||||||
ID = "ID"
|
ID = 'id'
|
||||||
SEASON = "Season"
|
SEASONSDICT = 'seasons'
|
||||||
EPISODE = "Episode"
|
SEASON = 'season'
|
||||||
SPECIAL = "Special"
|
EPISODE = 'episode'
|
||||||
MODE = "Mode"
|
EPISODES = 'episodes'
|
||||||
EPLIST = "EpList"
|
SPECIALEPISODES = 'specials'
|
||||||
CHECK = "ReCheck"
|
MANUALMODE = 'manual'
|
||||||
SPLIST = "SpList"
|
|
||||||
TYPE = "Type"
|
|
||||||
|
|
||||||
# helper Functions
|
# helper Functions
|
||||||
def check(item):
|
def check(item):
|
||||||
@@ -41,21 +39,15 @@ def filename(item):
|
|||||||
|
|
||||||
def load(item):
|
def load(item):
|
||||||
logger.debug()
|
logger.debug()
|
||||||
try:
|
try: json = jsontools.load(open(filename(item), "r").read())[RENUMBER]
|
||||||
json_file = open(filename(item), "r").read()
|
except: json = {}
|
||||||
json = jsontools.load(json_file)[TVSHOW_RENUMERATE]
|
|
||||||
|
|
||||||
except:
|
|
||||||
json = {}
|
|
||||||
|
|
||||||
return json
|
return json
|
||||||
|
|
||||||
|
|
||||||
def write(item, json):
|
def write(item, json):
|
||||||
logger.debug()
|
logger.debug()
|
||||||
json_file = open(filename(item), "r").read()
|
js = jsontools.load(open(filename(item), "r").read())
|
||||||
js = jsontools.load(json_file)
|
js[RENUMBER] = json
|
||||||
js[TVSHOW_RENUMERATE] = json
|
|
||||||
with open(filename(item), "w") as file:
|
with open(filename(item), "w") as file:
|
||||||
file.write(jsontools.dump(js))
|
file.write(jsontools.dump(js))
|
||||||
file.close()
|
file.close()
|
||||||
@@ -69,15 +61,6 @@ def b64(json, mode = 'encode'):
|
|||||||
ret = jsontools.load(base64.b64decode(json))
|
ret = jsontools.load(base64.b64decode(json))
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def RepresentsInt(s):
|
|
||||||
# Controllo Numro Stagione
|
|
||||||
logger.debug()
|
|
||||||
try:
|
|
||||||
int(s)
|
|
||||||
return True
|
|
||||||
except ValueError:
|
|
||||||
return False
|
|
||||||
|
|
||||||
def find_episodes(item):
|
def find_episodes(item):
|
||||||
logger.debug()
|
logger.debug()
|
||||||
ch = __import__('channels.' + item.channel, fromlist=["channels.%s" % item.channel])
|
ch = __import__('channels.' + item.channel, fromlist=["channels.%s" % item.channel])
|
||||||
@@ -88,6 +71,15 @@ def busy(state):
|
|||||||
if state: xbmc.executebuiltin('ActivateWindow(busydialognocancel)')
|
if state: xbmc.executebuiltin('ActivateWindow(busydialognocancel)')
|
||||||
else: xbmc.executebuiltin('Dialog.Close(busydialognocancel)')
|
else: xbmc.executebuiltin('Dialog.Close(busydialognocancel)')
|
||||||
|
|
||||||
|
def RepresentsInt(s):
|
||||||
|
# Controllo Numro Stagione
|
||||||
|
logger.debug()
|
||||||
|
try:
|
||||||
|
int(s)
|
||||||
|
return True
|
||||||
|
except ValueError:
|
||||||
|
return False
|
||||||
|
|
||||||
# Main
|
# Main
|
||||||
def start(itemlist, item=None):
|
def start(itemlist, item=None):
|
||||||
if not itemlist: return
|
if not itemlist: return
|
||||||
@@ -106,48 +98,44 @@ class autorenumber():
|
|||||||
def __init__(self, itemlist, item=None):
|
def __init__(self, itemlist, item=None):
|
||||||
self.item = item
|
self.item = item
|
||||||
self.itemlist = itemlist
|
self.itemlist = itemlist
|
||||||
|
self.renumberdict = load(self.itemlist[0]) if self.itemlist else load(item) if item else {}
|
||||||
|
self.selectspecials = False
|
||||||
|
self.manual = False
|
||||||
self.auto = False
|
self.auto = False
|
||||||
self.dictSeries = load(self.itemlist[0]) if self.itemlist else load(item) if item else {}
|
|
||||||
self.Episodes = {}
|
|
||||||
self.sp = False
|
|
||||||
if self.item:
|
if self.item:
|
||||||
self.auto = config.get_setting('autorenumber', item.channel)
|
self.auto = config.get_setting('autorenumber', item.channel)
|
||||||
self.title = self.item.fulltitle.strip()
|
self.title = self.item.fulltitle.strip()
|
||||||
if match(self.itemlist[0].title, patron=r'[Ss]?(\d+)(?:x|_|\s+)[Ee]?[Pp]?(\d+)').match:
|
if match(self.itemlist[0].title, patron=r'[Ss]?(\d+)(?:x|_|\s+)[Ee]?[Pp]?(\d+)').match:
|
||||||
item.exit = True
|
item.exit = True
|
||||||
return
|
return
|
||||||
elif self.item.channel in self.item.channel_prefs and TVSHOW_RENUMERATE in self.item.channel_prefs[item.channel] and self.title not in self.dictSeries:
|
elif self.item.channel in self.item.channel_prefs and RENUMBER in self.item.channel_prefs[item.channel] and self.title not in self.renumberdict:
|
||||||
from core.videolibrarytools import check_renumber_options
|
from core.videolibrarytools import check_renumber_options
|
||||||
from specials.videolibrary import update_videolibrary
|
from specials.videolibrary import update_videolibrary
|
||||||
check_renumber_options(self.item)
|
check_renumber_options(self.item)
|
||||||
update_videolibrary(self.item)
|
update_videolibrary(self.item)
|
||||||
if self.title in self.dictSeries and ID in self.dictSeries[self.title] and self.dictSeries[self.title][ID] != '0':
|
self.series = self.renumberdict.get(self.title,{})
|
||||||
self.id = self.dictSeries[self.title][ID]
|
self.id = self.series.get(ID, 0)
|
||||||
self.Episodes = b64(self.dictSeries[self.title][EPISODE], 'decode') if EPISODE in self.dictSeries[self.title] else {}
|
self.episodes = self.series.get(EPISODES,{})
|
||||||
self.Season = self.dictSeries[self.title][SEASON]
|
self.seasonsdict = self.series.get(SEASONSDICT,{})
|
||||||
self.Mode = self.dictSeries[self.title].get(MODE, False)
|
self.season = self.series.get(SEASON, -1)
|
||||||
self.Type = self.dictSeries[self.title].get(TYPE, False)
|
self.episode = self.series.get(EPISODE, -1)
|
||||||
if self.item.renumber:
|
self.manual = self.series.get(MANUALMODE, False)
|
||||||
self.config()
|
self.specials = self.series.get(SPECIALEPISODES, {})
|
||||||
else:
|
if self.id and self.episodes and self.season >= 0 and self.episode >= 0:
|
||||||
self.renumber()
|
if self.item.renumber: self.config()
|
||||||
|
else:self.renumber()
|
||||||
elif self.auto or self.item.renumber:
|
elif self.auto or self.item.renumber:
|
||||||
self.Episodes = {}
|
self.episodes = {}
|
||||||
self.config()
|
self.config()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
for item in self.itemlist:
|
for item in self.itemlist:
|
||||||
item.context = [{"title": typo(config.get_localized_string(70585), 'bold'),
|
item.context = [{"title": typo(config.get_localized_string(70585), 'bold'),
|
||||||
"action": "start",
|
"action": "start",
|
||||||
"channel": "autorenumber",
|
"channel": "autorenumber",
|
||||||
"from_channel": item.channel,
|
"from_channel": item.channel,
|
||||||
"from_action": item.action}]
|
"from_action": item.action}]
|
||||||
|
|
||||||
def config(self):
|
def config(self):
|
||||||
self.id = ''
|
|
||||||
if self.title in self.dictSeries:
|
|
||||||
self.id = self.dictSeries[self.title].get(ID,'')
|
|
||||||
|
|
||||||
# Pulizia del Titolo
|
# Pulizia del Titolo
|
||||||
if any( word in self.title.lower() for word in ['specials', 'speciali']):
|
if any( word in self.title.lower() for word in ['specials', 'speciali']):
|
||||||
self.title = re.sub(r'\s*specials|\s*speciali', '', self.title.lower())
|
self.title = re.sub(r'\s*specials|\s*speciali', '', self.title.lower())
|
||||||
@@ -155,184 +143,132 @@ class autorenumber():
|
|||||||
self.item.contentSerieName = self.title.rstrip('123456789 ')
|
self.item.contentSerieName = self.title.rstrip('123456789 ')
|
||||||
|
|
||||||
while not self.item.exit:
|
while not self.item.exit:
|
||||||
tvdb.find_and_set_infoLabels(self.item)
|
self.item.infoLabels['tmdb_id'] = ''
|
||||||
if self.item.infoLabels['tvdb_id']: self.item.exit = True
|
self.item.infoLabels['year'] = '-'
|
||||||
else: self.item = platformtools.dialog_info(self.item, 'tvdb')
|
self.item.contentType ='tvshow'
|
||||||
|
tmdb.find_and_set_infoLabels(self.item)
|
||||||
|
if self.item.infoLabels['tmdb_id']: self.item.exit = True
|
||||||
|
else: self.item = platformtools.dialog_info(self.item, 'tmdb')
|
||||||
|
|
||||||
# Rinumerazione Automatica
|
# Rinumerazione Automatica
|
||||||
if (not self.id and self.auto) or self.item.renumber:
|
if (not self.id and self.auto) or self.item.renumber:
|
||||||
self.id = self.item.infoLabels['tvdb_id'] if 'tvdb_id' in self.item.infoLabels else ''
|
self.id = self.item.infoLabels['tmdb_id'] if 'tmdb_id' in self.item.infoLabels else 0
|
||||||
if self.id:
|
if self.id:
|
||||||
self.dictRenumber = {ID: self.id}
|
self.series = {ID: self.id}
|
||||||
self.dictSeries[self.title] = self.dictRenumber
|
self.renumberdict[self.title] = self.series
|
||||||
if any(word in self.title.lower() for word in ['specials', 'speciali']): season = '0'
|
if any(word in self.title.lower() for word in ['specials', 'speciali']): season = 0
|
||||||
elif RepresentsInt(self.title.split()[-1]): season = self.title.split()[-1]
|
elif RepresentsInt(self.title.split()[-1]): season = int(self.title.split()[-1])
|
||||||
else: season = '1'
|
else: season = 1
|
||||||
self.Season = self.dictRenumber[SEASON] = season
|
self.season = self.series[SEASON] = season
|
||||||
|
self.episode = 1
|
||||||
self.renumber()
|
self.renumber()
|
||||||
|
|
||||||
|
|
||||||
def renumber(self):
|
def renumber(self):
|
||||||
if not self.item.renumber and self.itemlist:
|
if not self.item.renumber and self.itemlist:
|
||||||
if '|' in self.Season:
|
|
||||||
season = int(self.Season.split('|')[0])
|
|
||||||
addNumber = int(self.Season.split('|')[-1]) - 1
|
|
||||||
else:
|
|
||||||
season = int(self.Season)
|
|
||||||
addNumber = 0
|
|
||||||
for item in self.itemlist:
|
for item in self.itemlist:
|
||||||
if not match(item.title, patron=r'[Ss]?(\d+)(?:x|_|\s+)[Ee]?[Pp]?(\d+)').match:
|
if not match(item.title, patron=r'[Ss]?(\d+)(?:x|_|\s+)[Ee]?[Pp]?(\d+)').match:
|
||||||
number = match(item.title, patron=r'(\d+)').match.lstrip('0')
|
number = match(item.title, patron=r'(\d+)').match.lstrip('0')
|
||||||
if number:
|
if number:
|
||||||
if number in self.Episodes:
|
if not number in self.episodes: self.makelist()
|
||||||
if season > 0: item.title = typo(self.Episodes[number] + ' - ', 'bold') + item.title
|
item.title = '{} - {}'.format(typo(self.episodes[number], 'bold'), item.title)
|
||||||
else: item.title = typo('0x%s - ' % str(int(number) + addNumber), 'bold') + item.title
|
|
||||||
else:
|
|
||||||
self.makelist()
|
|
||||||
if season > 0: item.title = typo(self.Episodes[number] + ' - ', 'bold') + item.title
|
|
||||||
else: item.title = typo('0x%s - ' % str(int(number) + addNumber), 'bold') + item.title
|
|
||||||
else:
|
else:
|
||||||
self.makelist()
|
self.makelist()
|
||||||
|
|
||||||
|
|
||||||
def makelist(self):
|
def makelist(self):
|
||||||
FirstOfSeason= 0
|
self.epdict = {}
|
||||||
self.EpList = b64(self.dictSeries[self.title][EPLIST], 'decode') if EPLIST in self.dictSeries[self.title] else []
|
|
||||||
self.Pages = self.dictSeries[self.title].get(CHECK, [1])
|
|
||||||
self.Mode = self.dictSeries[self.title].get(MODE, False)
|
|
||||||
self.Type = self.dictSeries[self.title].get(TYPE, False)
|
|
||||||
Specials = {}
|
|
||||||
Seasons = {}
|
|
||||||
|
|
||||||
if '|' in self.Season:
|
|
||||||
ep = int(self.Season.split('|')[-1])
|
|
||||||
Season = int(self.Season.split('|')[0])
|
|
||||||
else:
|
|
||||||
Season = int(self.Season)
|
|
||||||
ep = 1
|
|
||||||
|
|
||||||
busy(True)
|
busy(True)
|
||||||
itemlist = find_episodes(self.item)
|
itemlist = find_episodes(self.item)
|
||||||
busy(False)
|
busy(False)
|
||||||
|
|
||||||
if self.item.renumber:
|
if self.item.renumber or self.manual:
|
||||||
self.s = Season
|
self.item.renumber = False
|
||||||
self.e = 1
|
self.season, self.episode, self.manual, self.specials, Manual, Exit = SelectreNumeration(self, itemlist)
|
||||||
Season, Episode, self.Mode, Specials, Seasons, Exit = SelectreNumeration(self, itemlist)
|
if Exit:
|
||||||
if Exit: return
|
self.item.exit = True
|
||||||
if ep != 1: self.Season = '%s|%s' % (Season, Episode)
|
return
|
||||||
else: self.Season = str(Season)
|
if self.manual:
|
||||||
|
self.episodes = Manual
|
||||||
elif self.Episodes and not self.Mode:
|
|
||||||
self.s = Season
|
|
||||||
self.e = ep
|
|
||||||
self.sp = True
|
|
||||||
Season, Episode, self.Mode, Specials, Seasons, Exit = SelectreNumeration(self, itemlist)
|
|
||||||
|
|
||||||
if self.Mode:
|
|
||||||
if not Seasons:
|
|
||||||
self.s = 1
|
|
||||||
self.e = 1
|
|
||||||
Season, Episode, self.Mode, Specials, Seasons, Exit = SelectreNumeration(self, itemlist, True)
|
|
||||||
self.Episodes = Seasons
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# Ricava Informazioni da TVDB
|
seasons = tmdb.Tmdb(id_Tmdb=self.id).get_list_episodes()
|
||||||
checkpages = []
|
count = 0
|
||||||
exist = True
|
for season in seasons:
|
||||||
Page = self.Pages[-1]
|
s = season['season_number']
|
||||||
Episode = ep
|
c = season['episode_count']
|
||||||
|
self.seasonsdict[str(s)] = c
|
||||||
|
if s > 0:
|
||||||
|
for e in range(1, c + 1):
|
||||||
|
count += 1
|
||||||
|
self.epdict[count] = '{}x{:02d}'.format(s,e)
|
||||||
|
# dbg()
|
||||||
|
firstep = 0
|
||||||
|
if self.season > 1:
|
||||||
|
for c in range(1, self.season):
|
||||||
|
firstep += self.seasonsdict[str(c)]
|
||||||
|
firstep += self.episode - 1
|
||||||
|
count = 0
|
||||||
|
if self.epdict:
|
||||||
|
for item in itemlist:
|
||||||
|
if not match(re.sub(r'\[[^\]]+\]','',item.title), patron=r'[Ss]?(\d+)(?:x|_|\s+)[Ee]?[Pp]?(\d+)').match:
|
||||||
|
# Otiene Numerazione Episodi
|
||||||
|
scraped_ep = match(re.sub(r'\[[^\]]+\]','',item.title), patron=r'(\d+)').match
|
||||||
|
if scraped_ep:
|
||||||
|
episode = int(scraped_ep)
|
||||||
|
if episode == 0:
|
||||||
|
self.episodes[str(episode)] = '0x01'
|
||||||
|
elif str(episode) in self.specials:
|
||||||
|
self.episodes[str(episode)] = self.specials[str(episode)]
|
||||||
|
count += 1
|
||||||
|
elif episode - count + firstep in self.epdict:
|
||||||
|
self.episodes[str(episode)] = self.epdict[episode - count + firstep]
|
||||||
|
else:
|
||||||
|
self.episodes[str(episode)] = '0x{:02d}'.format(count + 1)
|
||||||
|
count += 1
|
||||||
|
|
||||||
|
if self.episodes: self.renumberdict[self.title][EPISODES] = self.episodes
|
||||||
|
self.renumberdict[self.title][MANUALMODE] = self.manual
|
||||||
|
self.renumberdict[self.title][SEASON] = self.season
|
||||||
|
self.renumberdict[self.title][EPISODE] = self.episode
|
||||||
|
self.renumberdict[self.title][SPECIALEPISODES] = self.specials
|
||||||
|
self.renumberdict[self.title][SEASONSDICT] = self.seasonsdict
|
||||||
|
write(self.item, self.renumberdict)
|
||||||
|
# if self.auto: self.renumber()
|
||||||
|
|
||||||
while exist:
|
|
||||||
data = tvdb.Tvdb(tvdb_id=self.id).get_list_episodes(self.id, Page)
|
|
||||||
if data:
|
|
||||||
for episode in data['data']:
|
|
||||||
if episode['firstAired'] and [episode['firstAired'], episode['airedSeason'], episode['airedEpisodeNumber']] not in self.EpList:
|
|
||||||
self.EpList.append([episode['firstAired'], episode['airedSeason'], episode['airedEpisodeNumber']])
|
|
||||||
Page += 1
|
|
||||||
else:
|
|
||||||
if Page not in checkpages:
|
|
||||||
checkpages.append(Page -1)
|
|
||||||
exist = False
|
|
||||||
self.Pages = [checkpages[-1]]
|
|
||||||
self.EpList.sort()
|
|
||||||
|
|
||||||
# Crea Dizionari per la Rinumerazione
|
|
||||||
if self.EpList:
|
|
||||||
self.specials = []
|
|
||||||
self.regular = {}
|
|
||||||
self.complete = {}
|
|
||||||
allep = 1
|
|
||||||
specialep = 0
|
|
||||||
|
|
||||||
for episode in self.EpList:
|
|
||||||
self.complete[allep] = [str(episode[1]) + 'x' + str(episode[2]), episode[0]]
|
|
||||||
if episode[1] == 0:
|
|
||||||
self.specials.append(allep)
|
|
||||||
specialep = specialep + 1
|
|
||||||
else:
|
|
||||||
self.regular[ep] = [str(episode[1]) + 'x' + str(episode[2]), str(episode[0]), allep - 1]
|
|
||||||
ep = ep + 1
|
|
||||||
allep = allep + 1
|
|
||||||
|
|
||||||
if Season > 1:
|
|
||||||
for numbers, data in self.regular.items():
|
|
||||||
if data[0] == str(Season) + 'x1':
|
|
||||||
FirstOfSeason = numbers - 1
|
|
||||||
else: FirstOfSeason = Episode - 1
|
|
||||||
|
|
||||||
addiction = 0
|
|
||||||
for item in itemlist:
|
|
||||||
if not match(re.sub(r'\[[^\]]+\]','',item.title), patron=r'[Ss]?(\d+)(?:x|_|\s+)[Ee]?[Pp]?(\d+)').match:
|
|
||||||
# Otiene Numerazione Episodi
|
|
||||||
scraped_ep = match(re.sub(r'\[[^\]]+\]','',item.title), patron=r'(\d+)').match
|
|
||||||
if scraped_ep:
|
|
||||||
episode = int(scraped_ep)
|
|
||||||
number = episode + FirstOfSeason - addiction
|
|
||||||
if episode == 0:
|
|
||||||
self.Episodes[str(episode)] = str(self.complete[self.regular[FirstOfSeason+1][2]][0])
|
|
||||||
elif episode in Specials:
|
|
||||||
self.Episodes[str(episode)] = Specials[episode]
|
|
||||||
addiction += 1
|
|
||||||
elif number <= len(self.regular) and number in self.regular:
|
|
||||||
self.Episodes[str(episode)] = str(self.regular[number][0])
|
|
||||||
else:
|
|
||||||
try: self.Episodes[str(episode)] = str(self.complete[self.regular[number+2][2]][0])
|
|
||||||
except: self.Episodes[str(episode)] = '0x0'
|
|
||||||
|
|
||||||
if self.Episodes: self.dictSeries[self.title][EPISODE] = b64(jsontools.dump(self.Episodes))
|
|
||||||
self.dictSeries[self.title][EPLIST] = b64(jsontools.dump(self.EpList))
|
|
||||||
self.dictSeries[self.title][MODE] = self.Mode
|
|
||||||
self.dictSeries[self.title][SEASON] = self.Season
|
|
||||||
self.dictSeries[self.title][CHECK] = self.Pages
|
|
||||||
write(self.item, self.dictSeries)
|
|
||||||
|
|
||||||
if self.auto: self.renumber()
|
|
||||||
|
|
||||||
|
|
||||||
def SelectreNumeration(opt, itemlist, manual=False):
|
def SelectreNumeration(opt, itemlist, manual=False):
|
||||||
class SelectreNumerationWindow(xbmcgui.WindowXMLDialog):
|
class SelectreNumerationWindow(xbmcgui.WindowXMLDialog):
|
||||||
def start(self, opt):
|
def start(self, opt):
|
||||||
self.episodes = opt.Episodes if opt.Episodes else {}
|
self.episodes = opt.episodes if opt.episodes else {}
|
||||||
self.dictSeries = opt.dictSeries
|
self.renumberdict = opt.renumberdict
|
||||||
self.item = opt.item
|
self.item = opt.item
|
||||||
self.title = opt.title
|
self.title = opt.title
|
||||||
self.season = opt.s
|
self.season = opt.season
|
||||||
self.episode = opt.e
|
self.episode = opt.episode
|
||||||
self.mode = opt.Mode
|
self.manual = opt.manual
|
||||||
self.sp = opt.sp
|
self.sp = opt.selectspecials
|
||||||
self.manual = opt.manual
|
self.manual = opt.manual
|
||||||
self.offset = 0
|
self.offset = 0
|
||||||
self.Exit = False
|
self.Exit = False
|
||||||
|
|
||||||
self.itemlist = opt.itemlist
|
self.itemlist = opt.itemlist
|
||||||
self.count = 1
|
self.count = 1
|
||||||
self.specials = {}
|
self.specials = opt.specials
|
||||||
self.items = []
|
self.items = []
|
||||||
self.selected = []
|
self.selected = []
|
||||||
self.seasons = {}
|
self.seasons = {}
|
||||||
|
self.seasonsdict = opt.seasonsdict
|
||||||
|
|
||||||
self.doModal()
|
self.doModal()
|
||||||
return self.season, self.episode, self.mode, self.specials, self.seasons, self.Exit
|
return self.season, self.episode, self.manual, self.specials, self.seasons, self.Exit
|
||||||
|
|
||||||
def onInit(self):
|
def onInit(self):
|
||||||
# Compatibility with Kodi 18
|
# Compatibility with Kodi 18
|
||||||
@@ -349,7 +285,7 @@ def SelectreNumeration(opt, itemlist, manual=False):
|
|||||||
if fanart: self.getControl(MBACKGROUND).setImage(fanart)
|
if fanart: self.getControl(MBACKGROUND).setImage(fanart)
|
||||||
self.getControl(INFO).setLabel(typo(config.get_localized_string(70822) + self.title, 'bold'))
|
self.getControl(INFO).setLabel(typo(config.get_localized_string(70822) + self.title, 'bold'))
|
||||||
|
|
||||||
self.mode = True
|
self.manual = True
|
||||||
|
|
||||||
se = '1'
|
se = '1'
|
||||||
ep = '1'
|
ep = '1'
|
||||||
@@ -434,17 +370,19 @@ def SelectreNumeration(opt, itemlist, manual=False):
|
|||||||
self.setFocusId(focus - 1)
|
self.setFocusId(focus - 1)
|
||||||
elif action in [UP]:
|
elif action in [UP]:
|
||||||
if focus in [S]:
|
if focus in [S]:
|
||||||
s += 1
|
if str(s + 1) in self.seasonsdict:
|
||||||
self.getControl(S).setLabel(str(s))
|
s += 1
|
||||||
|
self.getControl(S).setLabel(str(s))
|
||||||
elif focus in [E]:
|
elif focus in [E]:
|
||||||
e += 1
|
if self.seasonsdict[str(s)] > e:
|
||||||
self.getControl(E).setLabel(str(e))
|
e += 1
|
||||||
|
self.getControl(E).setLabel(str(e))
|
||||||
elif action in [DOWN]:
|
elif action in [DOWN]:
|
||||||
if focus in [S]:
|
if focus in [S]:
|
||||||
if s > 0: s -= 1
|
if str(s - 1) in self.seasonsdict: s -= 1
|
||||||
self.getControl(S).setLabel(str(s))
|
self.getControl(S).setLabel(str(s))
|
||||||
elif focus in [E]:
|
elif focus in [E]:
|
||||||
if e > 0: e -= 1
|
if e > 1: e -= 1
|
||||||
self.getControl(E).setLabel(str(e))
|
self.getControl(E).setLabel(str(e))
|
||||||
# MANUAL
|
# MANUAL
|
||||||
if focus in [MS, ME]:
|
if focus in [MS, ME]:
|
||||||
@@ -508,7 +446,7 @@ def SelectreNumeration(opt, itemlist, manual=False):
|
|||||||
# OPEN MANUAL
|
# OPEN MANUAL
|
||||||
elif control_id in [M]:
|
elif control_id in [M]:
|
||||||
self.getControl(INFO).setLabel(typo(config.get_localized_string(70823) + self.title, 'bold'))
|
self.getControl(INFO).setLabel(typo(config.get_localized_string(70823) + self.title, 'bold'))
|
||||||
self.mode = True
|
self.manual = True
|
||||||
if self.episodes:
|
if self.episodes:
|
||||||
items = []
|
items = []
|
||||||
se = '1'
|
se = '1'
|
||||||
@@ -539,8 +477,8 @@ def SelectreNumeration(opt, itemlist, manual=False):
|
|||||||
# DELETE
|
# DELETE
|
||||||
if control_id in [D]:
|
if control_id in [D]:
|
||||||
self.Exit = True
|
self.Exit = True
|
||||||
self.dictSeries.pop(self.title)
|
self.renumberdict.pop(self.title)
|
||||||
write(self.item, self.dictSeries)
|
write(self.item, self.renumberdict)
|
||||||
self.close()
|
self.close()
|
||||||
|
|
||||||
## SPECIAL SECTION
|
## SPECIAL SECTION
|
||||||
@@ -548,7 +486,7 @@ def SelectreNumeration(opt, itemlist, manual=False):
|
|||||||
p1 = self.getControl(SELECTED).getSelectedPosition()
|
p1 = self.getControl(SELECTED).getSelectedPosition()
|
||||||
if control_id in [LIST]:
|
if control_id in [LIST]:
|
||||||
item = self.getControl(LIST).getSelectedItem()
|
item = self.getControl(LIST).getSelectedItem()
|
||||||
it = xbmcgui.ListItem(str(len(self.selected) + 1))
|
it = xbmcgui.ListItem(str(len(self.selected) + len(self.specials) + 1))
|
||||||
it.setProperty('title', item.getLabel())
|
it.setProperty('title', item.getLabel())
|
||||||
self.selected.append(it)
|
self.selected.append(it)
|
||||||
index = self.getControl(SELECTED).getSelectedPosition()
|
index = self.getControl(SELECTED).getSelectedPosition()
|
||||||
@@ -754,4 +692,4 @@ DOWN = 4
|
|||||||
EXIT = 10
|
EXIT = 10
|
||||||
BACKSPACE = 92
|
BACKSPACE = 92
|
||||||
|
|
||||||
path = config.get_runtime_path()
|
path = config.get_runtime_path()
|
||||||
Reference in New Issue
Block a user