Fix e migliorie Videoteca + Inizio filtraggio risultati

This commit is contained in:
Alhaziel01
2021-05-22 16:49:04 +02:00
parent a4e2278122
commit ba98922a9c
6 changed files with 381 additions and 325 deletions
+83 -83
View File
@@ -84,109 +84,109 @@ def find_and_set_infoLabels(item):
logger.error("Error importing the scraper module %s" % scraper_actual)
def cuadro_completar(item):
logger.debug()
# def cuadro_completar(item):
# logger.debug()
global dict_default
dict_default = {}
# global dict_default
# dict_default = {}
COLOR = ["0xFF65B3DA", "0xFFFFFFFF"]
# We create the list of infoLabel fields
controls = [("title", "text", config.get_localized_string(60230)),
("originaltitle", "text", config.get_localized_string(60231)),
("year", "text", config.get_localized_string(60232)),
("identificadores", "label", config.get_localized_string(60233)),
("tmdb_id", "text", config.get_localized_string(60234)),
("url_tmdb", "text", config.get_localized_string(60235), "+!eq(-1,'')"),
("tvdb_id", "text", config.get_localized_string(60236), "+eq(-7,'Serie')"),
("url_tvdb", "text", config.get_localized_string(60237), "+!eq(-1,'')+eq(-8,'Serie')"),
("imdb_id", "text", config.get_localized_string(60238)),
("otro_id", "text", config.get_localized_string(60239), "+eq(-1,'')"),
("urls", "label", config.get_localized_string(60240)),
("fanart", "text", config.get_localized_string(60241)),
("thumbnail", "text", config.get_localized_string(60242))]
# COLOR = ["0xFF65B3DA", "0xFFFFFFFF"]
# # We create the list of infoLabel fields
# controls = [("title", "text", config.get_localized_string(60230)),
# ("originaltitle", "text", config.get_localized_string(60231)),
# ("year", "text", config.get_localized_string(60232)),
# ("identificadores", "label", config.get_localized_string(60233)),
# ("tmdb_id", "text", config.get_localized_string(60234)),
# ("url_tmdb", "text", config.get_localized_string(60235), "+!eq(-1,'')"),
# ("tvdb_id", "text", config.get_localized_string(60236), "+eq(-7,'Serie')"),
# ("url_tvdb", "text", config.get_localized_string(60237), "+!eq(-1,'')+eq(-8,'Serie')"),
# ("imdb_id", "text", config.get_localized_string(60238)),
# ("otro_id", "text", config.get_localized_string(60239), "+eq(-1,'')"),
# ("urls", "label", config.get_localized_string(60240)),
# ("fanart", "text", config.get_localized_string(60241)),
# ("thumbnail", "text", config.get_localized_string(60242))]
if item.infoLabels["mediatype"] == "movie":
mediatype_default = 0
else:
mediatype_default = 1
# if item.infoLabels["mediatype"] == "movie":
# mediatype_default = 0
# else:
# mediatype_default = 1
listado_controles = [{'id': "mediatype",
'type': "list",
'label': config.get_localized_string(60243),
'color': COLOR[1],
'default': mediatype_default,
'enabled': True,
'visible': True,
'lvalues': [config.get_localized_string(60244), config.get_localized_string(70136)]
}]
# listado_controles = [{'id': "mediatype",
# 'type': "list",
# 'label': config.get_localized_string(60243),
# 'color': COLOR[1],
# 'default': mediatype_default,
# 'enabled': True,
# 'visible': True,
# 'lvalues': [config.get_localized_string(60244), config.get_localized_string(70136)]
# }]
for i, c in enumerate(controls):
color = COLOR[0]
dict_default[c[0]] = item.infoLabels.get(c[0], '')
# for i, c in enumerate(controls):
# color = COLOR[0]
# dict_default[c[0]] = item.infoLabels.get(c[0], '')
enabled = True
# enabled = True
if i > 0 and c[1] != 'label':
color = COLOR[1]
enabled = "!eq(-%s,'')" % i
if len(c) > 3:
enabled += c[3]
# if i > 0 and c[1] != 'label':
# color = COLOR[1]
# enabled = "!eq(-%s,'')" % i
# if len(c) > 3:
# enabled += c[3]
# default for special cases
if c[0] == "url_tmdb" and item.infoLabels["tmdb_id"] and 'tmdb' in item.infoLabels["url_scraper"]:
dict_default[c[0]] = item.infoLabels["url_scraper"]
# # default for special cases
# if c[0] == "url_tmdb" and item.infoLabels["tmdb_id"] and 'tmdb' in item.infoLabels["url_scraper"]:
# dict_default[c[0]] = item.infoLabels["url_scraper"]
elif c[0] == "url_tvdb" and item.infoLabels["tvdb_id"] and 'thetvdb.com' in item.infoLabels["url_scraper"]:
dict_default[c[0]] = item.infoLabels["url_scraper"]
# elif c[0] == "url_tvdb" and item.infoLabels["tvdb_id"] and 'thetvdb.com' in item.infoLabels["url_scraper"]:
# dict_default[c[0]] = item.infoLabels["url_scraper"]
if not dict_default[c[0]] or dict_default[c[0]] == 'None' or dict_default[c[0]] == 0:
dict_default[c[0]] = ''
elif isinstance(dict_default[c[0]], (int, float)) or (not PY3 and isinstance(dict_default[c[0]], (int, float, long))):
# If it is numerical we convert it into str
dict_default[c[0]] = str(dict_default[c[0]])
# if not dict_default[c[0]] or dict_default[c[0]] == 'None' or dict_default[c[0]] == 0:
# dict_default[c[0]] = ''
# elif isinstance(dict_default[c[0]], (int, float)) or (not PY3 and isinstance(dict_default[c[0]], (int, float, long))):
# # If it is numerical we convert it into str
# dict_default[c[0]] = str(dict_default[c[0]])
listado_controles.append({'id': c[0],
'type': c[1],
'label': c[2],
'color': color,
'default': dict_default[c[0]],
'enabled': enabled,
'visible': True})
# listado_controles.append({'id': c[0],
# 'type': c[1],
# 'label': c[2],
# 'color': color,
# 'default': dict_default[c[0]],
# 'enabled': enabled,
# 'visible': True})
# logger.debug(dict_default)
if platformtools.show_channel_settings(list_controls=listado_controles, caption=config.get_localized_string(60246), item=item,
callback="core.scraper.callback_cuadro_completar",
custom_button={"visible": False}):
return True
# # logger.debug(dict_default)
# if platformtools.show_channel_settings(list_controls=listado_controles, caption=config.get_localized_string(60246), item=item,
# callback="core.scraper.callback_cuadro_completar",
# custom_button={"visible": False}):
# return True
else:
return False
# else:
# return False
def callback_cuadro_completar(item, dict_values):
# logger.debug(dict_values)
global dict_default
# def callback_cuadro_completar(item, dict_values):
# # logger.debug(dict_values)
# global dict_default
if dict_values.get("title", None):
# Adapt dict_values to valid infoLabels
dict_values['mediatype'] = ['movie', 'tvshow'][dict_values['mediatype']]
for k, v in list(dict_values.items()):
if k in dict_default and dict_default[k] == dict_values[k]:
del dict_values[k]
# if dict_values.get("title", None):
# # Adapt dict_values to valid infoLabels
# dict_values['mediatype'] = ['movie', 'tvshow'][dict_values['mediatype']]
# for k, v in list(dict_values.items()):
# if k in dict_default and dict_default[k] == dict_values[k]:
# del dict_values[k]
if isinstance(item.infoLabels, InfoLabels):
infoLabels = item.infoLabels
else:
infoLabels = InfoLabels()
# if isinstance(item.infoLabels, InfoLabels):
# infoLabels = item.infoLabels
# else:
# infoLabels = InfoLabels()
infoLabels.update(dict_values)
item.infoLabels = infoLabels
# infoLabels.update(dict_values)
# item.infoLabels = infoLabels
if item.infoLabels['code']:
return True
# if item.infoLabels['code']:
# return True
return False
# return False
def get_nfo(item, search_groups=False):
+8 -1
View File
@@ -309,6 +309,8 @@ def set_infoLabels_item(item, seekTmdb=True, search_language=def_lang):
item.infoLabels['episode_imdb_id'] = episode['episode_imdb_id']
if episode.get('episode_tvdb_id'):
item.infoLabels['episode_tvdb_id'] = episode['episode_tvdb_id']
if episode.get('episode_posters'):
item.infoLabels['posters'] = episode['episode_posters']
return len(item.infoLabels)
@@ -1471,7 +1473,7 @@ class Tmdb(object):
# episode = season["episodes"][chapter - 1]
url = "{}/tv/{}/season/{}/episode/{}?api_key={}&language={}&append_to_response=videos,images,credits,external_ids&include_image_language={},en,null".format(host, self.result["id"], seasonNumber, chapter, api, self.search_language, self.search_language)
episode = self.get_json(url)
# logger.debug('EPISODE', jsontools.dump(episode))
# logger.debug('EPISODE', url)
episodeTitle = episode.get("name", '')
episodeId = episode.get('id', '')
@@ -1485,6 +1487,9 @@ class Tmdb(object):
externalIds = episode.get('external_ids', {})
imdb_id = externalIds.get('imdb_id')
tvdb_id = externalIds.get('tvdb_id')
posters = []
for image in episode['images']['stills']:
posters.append('https://image.tmdb.org/t/p/original' + image['file_path'])
ret_dic["episode_title"] = episodeTitle
ret_dic["episode_plot"] = episodePlot
@@ -1498,6 +1503,8 @@ class Tmdb(object):
ret_dic["episode_air_date"] = date[2] + "/" + date[1] + "/" + date[0]
else:
ret_dic["episode_air_date"] = ""
if posters:
ret_dic['episode_posters'] = posters
ret_dic["episode_crew"] = episodeCrew
if episodeStars:
+15 -6
View File
@@ -413,7 +413,7 @@ def save_tvshow(item, episodelist, silent=False):
if not item.head_nfo:
head_nfo = scraper.get_nfo(item)
if not head_nfo: return 0, 0, -1, ''
# support.dbg()
extra_info = get_fanart_tv(item)
if not item.infoLabels.get('posters'): item.infoLabels['posters'] = []
item.infoLabels['posters'] += extra_info['poster'].get('all',[])
@@ -566,12 +566,14 @@ def save_episodes(item, episodelist, extra_info, host, silent=False):
channels_url = [u.url for u in epchannels[e.channel]]
if e.url not in channels_url:
epchannels[e.channel].append(e)
overwritten += 1
else:
del epchannels[e.channel][channels_url.index(e.url)]
epchannels[e.channel].append(e)
overwritten += 1
else:
epchannels[e.channel] = [e]
overwritten += 1
episode['channels'] = epchannels
@@ -645,11 +647,18 @@ def save_episodes(item, episodelist, extra_info, host, silent=False):
# support.dbg()
# for i, e in enumerate(episodelist):
# item, seasons, episodes, e, inserted, overwritten, failed = save_episode(item, episodes, e)
# if not e.contentLanguage: e.contentLanguage = item.contentLanguage if item.contentLanguage else 'ITA'
# if not e.contentLanguage in item.lang_list: item.lang_list.append(e.contentLanguage)
# if not silent:
# p_dialog.update(int(math.ceil((i + 1) * t)), e.title)
# item, episode, season_episode, lang, I, O, F = save_episode(item, episodes, e)
# inserted += I
# overwritten += O
# failed += F
# if episode:
# episodes[season_episode] = episode
# e = episode['item']
# if not e.contentSeason in current_seasons: current_seasons.append(e.contentSeason)
# if not lang: lang = item.contentLanguage if item.contentLanguage else 'ITA'
# if not lang in item.lang_list: item.lang_list.append(lang)
# if not silent:
# p_dialog.update(int(math.ceil(i * t)), message=e.title)
i = 0
with futures.ThreadPoolExecutor() as executor: