This commit is contained in:
Alhaziel01
2020-08-19 15:48:49 +02:00
parent e6aba0a0c9
commit 47d7d52bcf
3 changed files with 46 additions and 97 deletions
+3
View File
@@ -919,7 +919,10 @@ class Tmdb(object):
if self.busqueda_tipo == "movie": if self.busqueda_tipo == "movie":
resultado = resultado["movie_results"][0] resultado = resultado["movie_results"][0]
else: else:
if resultado["tv_results"]:
resultado = resultado["tv_results"][0] resultado = resultado["tv_results"][0]
else:
resultado = resultado['tv_episode_results'][0]
self.results = [resultado] self.results = [resultado]
self.total_results = 1 self.total_results = 1
+39 -94
View File
@@ -12,7 +12,7 @@ from future.builtins import object
import urllib.request, urllib.error, urllib.parse import urllib.request, urllib.error, urllib.parse
import re import re, requests
from core import jsontools from core import jsontools
from core import scrapertools from core import scrapertools
@@ -743,6 +743,7 @@ class Tvdb(object):
req = urllib.request.Request(url, headers=DEFAULT_HEADERS) req = urllib.request.Request(url, headers=DEFAULT_HEADERS)
response = urllib.request.urlopen(req) response = urllib.request.urlopen(req)
html = response.read() html = response.read()
logger.log(html)
response.close() response.close()
except Exception as ex: except Exception as ex:
@@ -1021,102 +1022,46 @@ class Tvdb(object):
if not origen: if not origen:
origen = self.result origen = self.result
# todo revisar ret_infoLabels['title'] = origen['seriesName']
# if 'credits' in origen.keys(): ret_infoLabels['tvdb_id'] = origen['id']
# dic_origen_credits = origen['credits'] thumbs = requests.get(HOST + '/series/' + str(origen['id']) + '/images/query?keyType=poster').json()
# origen['credits_cast'] = dic_origen_credits.get('cast', []) if 'data' in thumbs:
# origen['credits_crew'] = dic_origen_credits.get('crew', []) ret_infoLabels['thumbnail'] = HOST_IMAGE + thumbs['data'][0]['fileName']
# del origen['credits'] elif 'poster' in origen and origen['poster']:
ret_infoLabels['thumbnail'] = origen['poster']
items = list(origen.items()) fanarts = requests.get(HOST + '/series/' + str(origen['id']) + '/images/query?keyType=fanart').json()
if 'data' in fanarts:
for k, v in items: ret_infoLabels['fanart'] = HOST_IMAGE + fanarts['data'][0]['fileName']
if not v: elif 'poster' in origen and origen['fanart']:
continue ret_infoLabels['thumbnail'] = origen['fanart']
if 'overview' in origen:
if k == 'overview': ret_infoLabels['plot'] = origen['overview']
ret_infoLabels['plot'] = v if 'duration' in origen and origen['duration']:
ret_infoLabels['duration'] = int(origen['duration']) * 60
elif k == 'runtime': if 'firstAired' in origen and origen['firstAired']:
ret_infoLabels['duration'] = int(v) * 60 ret_infoLabels['year'] = int(origen['firstAired'][:4])
ret_infoLabels['premiered'] = origen['firstAired'].split("-")[2] + "/" + origen['firstAired'].split("-")[1] + "/" + origen['firstAired'].split("-")[0]
elif k == 'firstAired': if 'siteRating' in origen:
ret_infoLabels['year'] = int(v[:4]) ret_infoLabels['rating'] = float(origen['siteRating'])
ret_infoLabels['premiered'] = v.split("-")[2] + "/" + v.split("-")[1] + "/" + v.split("-")[0] if 'siteRatingCount' in origen and origen['siteRating']:
ret_infoLabels['votes'] = origen['siteRatingCount']
# todo revisar if 'status' in origen:
# elif k == 'original_title' or k == 'original_name': ret_infoLabels['status'] = origen['status']
# ret_infoLabels['originaltitle'] = v if 'network' in origen:
ret_infoLabels['studio'] = origen['network']
elif k == 'siteRating': if 'imdbId' in origen:
ret_infoLabels['rating'] = float(v) ret_infoLabels['imdb_id'] = origen['imdbId']
if 'rating' in origen:
elif k == 'siteRatingCount': ret_infoLabels['mpaa'] = origen['rating']
ret_infoLabels['votes'] = v if 'genre' in origen:
for genre in origen['genre']:
elif k == 'status':
# se traduce los estados de una serie
ret_infoLabels['status'] = v
# I am not in favor of putting the chain as a studio but it is how the scraper does it in a generic way
elif k == 'network':
ret_infoLabels['studio'] = v
elif k == 'image_poster':
# obtenemos la primera imagen de la lista
ret_infoLabels['thumbnail'] = HOST_IMAGE + v[0]['fileName']
elif k == 'image_fanart':
# obtenemos la primera imagen de la lista
ret_infoLabels['fanart'] = HOST_IMAGE + v[0]['fileName']
# # no disponemos de la imagen de fondo
# elif k == 'banner':
# ret_infoLabels['fanart'] = HOST_IMAGE + v
elif k == 'id':
ret_infoLabels['tvdb_id'] = v
elif k == 'imdbId':
ret_infoLabels['imdb_id'] = v
# no se muestra
# ret_infoLabels['code'] = v
elif k in "rating":
# we translate the age rating (content rating system)
ret_infoLabels['mpaa'] = v
elif k in "genre":
genre_list = "" genre_list = ""
for index, i in enumerate(v): genre_list += genre + ', '
if index > 0: ret_infoLabels['genre'] = genre_list.rstrip(', ')
genre_list += ", " if 'cast' in origen:
# traducimos los generos
genre_list += i
ret_infoLabels['genre'] = genre_list
elif k == 'seriesName': # or k == 'name' or k == 'title':
# if len(origen.get('aliases', [])) > 0:
# ret_infoLabels['title'] = v + " " + origen.get('aliases', [''])[0]
# else:
# ret_infoLabels['title'] = v
# logger.log("el titulo es %s " % ret_infoLabels['title'])
ret_infoLabels['title'] = v
elif k == 'cast':
dic_aux = dict((name, character) for (name, character) in l_castandrole) dic_aux = dict((name, character) for (name, character) in l_castandrole)
l_castandrole.extend([(p['name'], p['role']) for p in v if p['name'] not in list(dic_aux.keys())]) l_castandrole.extend([(p['name'], p['role']) for p in origen['cast'] if p['name'] not in list(dic_aux.keys())])
else:
logger.debug("Attributes not added: %s=%s" % (k, v))
pass
# Sort the lists and convert them to str if necessary
if l_castandrole:
ret_infoLabels['castandrole'] = l_castandrole ret_infoLabels['castandrole'] = l_castandrole
logger.debug("ret_infoLabels %s" % ret_infoLabels)
return ret_infoLabels return ret_infoLabels
+2 -1
View File
@@ -28,7 +28,8 @@ def mainlist(item):
Item(channel=item.channel, action="list_tvshows",title=config.get_localized_string(60600), Item(channel=item.channel, action="list_tvshows",title=config.get_localized_string(60600),
category=config.get_localized_string(70271), thumbnail=thumb("videolibrary_tvshow"), category=config.get_localized_string(70271), thumbnail=thumb("videolibrary_tvshow"),
context=[{"channel":"videolibrary", "action":"update_videolibrary", "title":config.get_localized_string(70269)}]), context=[{"channel":"videolibrary", "action":"update_videolibrary", "title":config.get_localized_string(70269)}]),
Item(channel='shortcuts', action="SettingOnPosition", title=config.get_localized_string(60542), category=2, setting=1, thumbnail = thumb("setting_0"))] Item(channel='shortcuts', action="SettingOnPosition", title=typo(config.get_localized_string(70287),'bold color kod'),
category=2, setting=1, thumbnail = thumb("setting_0"))]
return itemlist return itemlist