aggiunta possibilità di ricercare informazioni sugli episodi e migliorato render_items
This commit is contained in:
@@ -214,7 +214,8 @@ def episodios(item):
|
||||
url=host + '/watch/' + str(episodes['title_id']),
|
||||
episodeid= '?e=' + str(it['id'])))
|
||||
|
||||
|
||||
if config.get_setting('episode_info') and not support.stackCheck(['add_tvshow', 'get_newest']):
|
||||
support.tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True)
|
||||
support.check_trakt(itemlist)
|
||||
support.videolibrary(itemlist, item)
|
||||
support.download(itemlist, item)
|
||||
|
||||
@@ -604,7 +604,9 @@ def scrape(func):
|
||||
if function == 'episodios': autorenumber.start(itemlist, item)
|
||||
else: autorenumber.start(itemlist)
|
||||
|
||||
if action != 'play' and 'patronMenu' not in args and not disabletmdb and function != 'episodios' and item.contentType in ['movie', 'tvshow', 'episode', 'undefined']:
|
||||
if action != 'play' and 'patronMenu' not in args and 'patronGenreMenu' not in args \
|
||||
and not stackCheck(['add_tvshow', 'get_newest']) and (function not in ['episodes', 'mainlist'] \
|
||||
or (function in ['episodes'] and config.getSetting('episode_info'))):
|
||||
tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True)
|
||||
|
||||
if not group and not args.get('groupExplode') and ((pagination and len(matches) <= pag * pagination) or not pagination): # next page with pagination
|
||||
@@ -1627,3 +1629,11 @@ def check_trakt(itemlist):
|
||||
trakt_tools.trakt_check(itemlist)
|
||||
return itemlist
|
||||
|
||||
|
||||
def stackCheck(values):
|
||||
stacks = [s[3] for s in inspect.stack()]
|
||||
logger.debug('STAKS', stacks)
|
||||
if type(values) == str:
|
||||
return values in stacks
|
||||
else:
|
||||
return any(v in values for v in stacks)
|
||||
15
core/tmdb.py
15
core/tmdb.py
@@ -470,10 +470,9 @@ def find_and_set_infoLabels(item):
|
||||
item.infoLabels['year'] = year[1:-1]
|
||||
|
||||
if not item.infoLabels.get("tmdb_id") or not item.infoLabels.get("tmdb_id")[0].isdigit():
|
||||
if not item.infoLabels.get("imdb_id"):
|
||||
otmdb_global = Tmdb(searched_text=scrapertools.unescape(title), search_type=search_type, year=item.infoLabels['year'])
|
||||
else:
|
||||
otmdb_global = Tmdb(external_id=item.infoLabels.get("imdb_id"), external_source="imdb_id", search_type=search_type)
|
||||
if item.infoLabels.get("imdb_id"): otmdb_global = Tmdb(external_id=item.infoLabels.get("imdb_id"), external_source="imdb_id", search_type=search_type)
|
||||
else: otmdb_global = Tmdb(searched_text=scrapertools.unescape(title), search_type=search_type, year=item.infoLabels['year'])
|
||||
|
||||
elif not otmdb_global or str(otmdb_global.result.get("id")) != item.infoLabels['tmdb_id']:
|
||||
otmdb_global = Tmdb(id_Tmdb=item.infoLabels['tmdb_id'], search_type=search_type, search_language=def_lang)
|
||||
|
||||
@@ -536,10 +535,7 @@ def get_nfo(item, search_groups=False):
|
||||
info_nfo = 'https://www.themoviedb.org/tv/{}/episode_group/{}'.format(item.infoLabels['tmdb_id'], Id)
|
||||
return info_nfo + '\n'
|
||||
else: return
|
||||
# from core.support import dbg;dbg()
|
||||
# if "season" in item.infoLabels and "episode" in item.infoLabels:
|
||||
# info_nfo = "https://www.themoviedb.org/tv/{}/season/{}/episode/{}" .format(item.infoLabels['tmdb_id'], item.contentSeason, item.contentEpisodeNumber)
|
||||
# else:
|
||||
|
||||
info_nfo = ', '.join(item.infoLabels['url_scraper'])
|
||||
|
||||
return info_nfo + '\n'
|
||||
@@ -643,10 +639,11 @@ class ResultDictDefault(dict):
|
||||
|
||||
def __missing__(self, key):
|
||||
"""
|
||||
default values in case the requested key does not exist
|
||||
default values in case the requested key does not exist
|
||||
"""
|
||||
if key in ['genre_ids', 'genre', 'genres']:
|
||||
return list()
|
||||
|
||||
elif key == 'images_posters':
|
||||
posters = dict()
|
||||
if 'images' in list(super(ResultDictDefault, self).keys()) and 'posters' in super(ResultDictDefault, self).__getitem__('images'):
|
||||
|
||||
@@ -10,9 +10,12 @@ import sys
|
||||
if sys.version_info[0] >= 3:
|
||||
PY3 = True
|
||||
import urllib.parse as urllib
|
||||
from concurrent import futures
|
||||
else:
|
||||
PY3 = False
|
||||
import urllib
|
||||
from concurrent_py2 import futures
|
||||
|
||||
|
||||
import os, xbmc, xbmcgui, xbmcplugin
|
||||
from past.utils import old_div
|
||||
@@ -310,33 +313,31 @@ def render_items(itemlist, parent_item):
|
||||
"""
|
||||
Function used to render itemlist on kodi
|
||||
"""
|
||||
|
||||
# if it's not a list, do nothing
|
||||
if not isinstance(itemlist, list):
|
||||
return
|
||||
|
||||
logger.debug('START render_items')
|
||||
# save_view_mode()
|
||||
logger.debug('START renderItems')
|
||||
thumb_type = config.get_setting('video_thumbnail_type')
|
||||
from platformcode import shortcuts
|
||||
# from core import httptools
|
||||
_handle = int(sys.argv[1])
|
||||
default_fanart = config.get_fanart()
|
||||
def_context_commands = shortcuts.context()
|
||||
|
||||
# if there's no item, add "no elements" item
|
||||
if not len(itemlist):
|
||||
itemlist.append(Item(title=config.get_localized_string(60347), thumbnail=get_thumb('nofolder.png')))
|
||||
from core.support import thumb
|
||||
itemlist.append(Item(title=config.get_localized_string(60347), thumbnail=thumb('nofolder')))
|
||||
|
||||
dirItems = []
|
||||
|
||||
for n, item in enumerate(itemlist):
|
||||
# item.itemlistPosition = n + 1
|
||||
def setItem(n, item, parent_item):
|
||||
item.itemlistPosition = n
|
||||
item_url = item.tourl()
|
||||
|
||||
if item.category == "":
|
||||
item.category = parent_item.category
|
||||
if not item.title:
|
||||
item.title = ''
|
||||
# If there is no action or it is findvideos / play, folder = False because no listing will be returned
|
||||
if item.action in ['play', 'findvideos', '']:
|
||||
item.folder = False
|
||||
@@ -346,13 +347,33 @@ def render_items(itemlist, parent_item):
|
||||
item.thumbnail = config.get_online_server_thumb(item.server)
|
||||
|
||||
icon_image = "DefaultFolder.png" if item.folder else "DefaultVideo.png"
|
||||
listitem = xbmcgui.ListItem(item.title)
|
||||
listitem.setArt({'icon': icon_image, 'thumb': item.thumbnail, 'poster': item.thumbnail,
|
||||
'fanart': item.fanart if item.fanart else default_fanart})
|
||||
|
||||
title = item.title
|
||||
|
||||
|
||||
listitem = xbmcgui.ListItem(title)
|
||||
art = {'icon': icon_image, 'thumb': item.thumbnail, 'poster': item.thumbnail, 'fanart': item.fanart if item.fanart else default_fanart}
|
||||
if item.infoLabels.get('landscape'): art['landscape'] = item.infoLabels['landscape']
|
||||
if item.infoLabels.get('clearlogo'): art['clearlogo'] = item.infoLabels['clearlogo']
|
||||
if item.infoLabels.get('clearart'): art['clearart'] = item.infoLabels['clearart']
|
||||
if item.infoLabels.get('banner'): art['banner'] = item.infoLabels['banner']
|
||||
if item.infoLabels.get('disc'): art['disc'] = item.infoLabels['disc']
|
||||
listitem.setProperty('ResumeTime', str(get_played_time(item)))
|
||||
|
||||
listitem.setArt(art)
|
||||
|
||||
if config.get_setting("player_mode") == 1 and item.action == "play" and not item.nfo:
|
||||
listitem.setProperty('IsPlayable', 'true')
|
||||
|
||||
if item.infoLabels.get('castandrole'):
|
||||
try:
|
||||
cast = [{'name':c[0], 'role':c[1], 'thumbnail':c[2], 'order':c[3]} for c in item.infoLabels.get("castandrole", [])]
|
||||
cast.sort(key=lambda c: c['order'])
|
||||
listitem.setCast(cast)
|
||||
del item.infoLabels['castandrole']
|
||||
except:
|
||||
pass
|
||||
|
||||
set_infolabels(listitem, item)
|
||||
|
||||
# context menu
|
||||
@@ -361,12 +382,30 @@ def render_items(itemlist, parent_item):
|
||||
else:
|
||||
context_commands = def_context_commands
|
||||
listitem.addContextMenuItems(context_commands)
|
||||
return item, item_url, listitem
|
||||
|
||||
dirItems.append(('%s?%s' % (sys.argv[0], item_url), listitem, item.folder))
|
||||
# For Debug
|
||||
# from core.support import dbg;dbg()
|
||||
# r_list = [setItem(i, item, parent_item) for i, item in enumerate(itemlist)]
|
||||
|
||||
set_view_mode(itemlist[0], parent_item)
|
||||
r_list = []
|
||||
|
||||
with futures.ThreadPoolExecutor() as executor:
|
||||
searchList = [executor.submit(setItem, i, item, parent_item) for i, item in enumerate(itemlist)]
|
||||
for res in futures.as_completed(searchList):
|
||||
r_list.append(res.result())
|
||||
r_list.sort(key=lambda it: it[0].itemlistPosition)
|
||||
|
||||
|
||||
# from core.support import dbg;dbg()
|
||||
for item, item_url, listitem in r_list:
|
||||
dirItems.append(('{}?{}'.format(sys.argv[0], item_url), listitem, item.folder, len(r_list)))
|
||||
xbmcplugin.addDirectoryItems(_handle, dirItems)
|
||||
|
||||
if parent_item.sorted:
|
||||
if parent_item.sorted == 'year': xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_DATE)
|
||||
elif parent_item.sorted == 'name':xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_TITLE_IGNORE_THE)
|
||||
|
||||
if parent_item.list_type == '':
|
||||
breadcrumb = parent_item.category #.capitalize()
|
||||
else:
|
||||
@@ -379,11 +418,11 @@ def render_items(itemlist, parent_item):
|
||||
breadcrumb = config.get_localized_string(70693)
|
||||
|
||||
xbmcplugin.setPluginCategory(handle=_handle, category=breadcrumb)
|
||||
|
||||
set_view_mode(itemlist[0], parent_item)
|
||||
|
||||
xbmcplugin.endOfDirectory(_handle, succeeded=True, updateListing=False, cacheToDisc=True)
|
||||
|
||||
logger.debug('END render_items')
|
||||
from core import db; db.close()
|
||||
logger.debug('END renderItems')
|
||||
|
||||
|
||||
def viewmodeMonitor():
|
||||
@@ -498,33 +537,23 @@ def set_infolabels(listitem, item, player=False):
|
||||
@type item: item
|
||||
"""
|
||||
|
||||
infoLabels_dict = {'aired': 'aired', 'album': 'album', 'artist': 'artist', 'cast': 'cast',
|
||||
'castandrole': 'castandrole', 'tmdb_id': 'code', 'code': 'code', 'country': 'country',
|
||||
'credits': 'credits', 'release_date': 'dateadded', 'dateadded': 'dateadded', 'dbid': 'dbid',
|
||||
'director': 'director', 'duration': 'duration', 'episode': 'episode',
|
||||
'episodio_sinopsis': 'episodeguide', 'episodio_air_date': 'None', 'episodio_imagen': 'None',
|
||||
'episodio_titulo': 'title', 'episodio_vote_average': 'rating', 'episodio_vote_count': 'votes',
|
||||
'fanart': 'None', 'genre': 'genre', 'homepage': 'None', 'imdb_id': 'imdbnumber',
|
||||
'imdbnumber': 'imdbnumber', 'in_production': 'None', 'last_air_date': 'lastplayed',
|
||||
'mediatype': 'mediatype', 'mpaa': 'mpaa', 'number_of_episodes': 'None',
|
||||
'number_of_seasons': 'None', 'original_language': 'None', 'originaltitle': 'originaltitle',
|
||||
'overlay': 'overlay', 'poster_path': 'path', 'popularity': 'None', 'playcount': 'playcount',
|
||||
'plot': 'plot', 'plotoutline': 'plotoutline', 'premiered': 'premiered', 'quality': 'None',
|
||||
'rating': 'rating', 'season': 'season', 'set': 'set', 'setid': 'setid',
|
||||
'setoverview': 'setoverview', 'showlink': 'showlink', 'sortepisode': 'sortepisode',
|
||||
'sortseason': 'sortseason', 'sorttitle': 'sorttitle', 'status': 'status', 'studio': 'studio',
|
||||
'tag': 'tag', 'tagline': 'tagline', 'temporada_air_date': 'None', 'temporada_nombre': 'None',
|
||||
'temporada_num_episodios': 'None', 'temporada_poster': 'None', 'title': 'title',
|
||||
'top250': 'top250', 'tracknumber': 'tracknumber', 'trailer': 'trailer', 'thumbnail': 'None',
|
||||
'tvdb_id': 'None', 'tvshowtitle': 'tvshowtitle', 'type': 'None', 'userrating': 'userrating',
|
||||
'url_scraper': 'None', 'votes': 'votes', 'writer': 'writer', 'year': 'year'}
|
||||
infoLabels_dict = {'aired': 'aired', 'album': 'album', 'artist': 'artist', 'cast': 'cast', 'castandrole': 'castandrole',
|
||||
'tmdb_id': 'code', 'code': 'code', 'country': 'country', 'credits': 'credits', 'release_date': 'dateadded',
|
||||
'dateadded': 'dateadded', 'dbid': 'dbid', 'director': 'director', 'duration': 'duration', 'episode': 'episode',
|
||||
'episode_plot': 'episodeguide', 'episode_title': 'title', 'episode_vote_average': 'rating', 'episode_vote_count': 'votes',
|
||||
'genre': 'genre', 'imdb_id': 'imdbnumber', 'imdbnumber': 'imdbnumber', 'last_air_date': 'lastplayed', 'mediatype': 'mediatype',
|
||||
'mpaa': 'mpaa', 'originaltitle': 'originaltitle', 'overlay': 'overlay', 'poster_path': 'path', 'playcount': 'playcount',
|
||||
'plot': 'plot', 'plotoutline': 'plotoutline', 'premiered': 'premiered', 'rating': 'rating', 'season': 'season', 'set': 'set',
|
||||
'setid': 'setid', 'setoverview': 'setoverview', 'showlink': 'showlink', 'sortepisode': 'sortepisode', 'sortseason': 'sortseason',
|
||||
'sorttitle': 'sorttitle', 'status': 'status', 'studio': 'studio', 'tag': 'tag', 'tagline': 'tagline', 'title': 'title',
|
||||
'top250': 'top250', 'tracknumber': 'tracknumber', 'trailer': 'trailer', 'tvshowtitle': 'tvshowtitle', 'userrating': 'userrating',
|
||||
'votes': 'votes', 'writer': 'writer', 'year': 'year'}
|
||||
# if item.infoLabels:
|
||||
try:
|
||||
infoLabels_kodi = {infoLabels_dict[label_tag]: item.infoLabels[label_tag] for label_tag, label_value in list(item.infoLabels.items()) if infoLabels_dict[label_tag] != 'None'}
|
||||
infoLabels_kodi = {infoLabels_dict[label_tag]: label_value for label_tag, label_value in list(item.infoLabels.items()) if label_tag in infoLabels_dict}
|
||||
listitem.setInfo("video", infoLabels_kodi)
|
||||
except:
|
||||
listitem.setInfo("video", item.infoLabels)
|
||||
# logger.error(item.infoLabels)
|
||||
|
||||
|
||||
def set_context_commands(item, item_url, parent_item, **kwargs):
|
||||
@@ -1480,7 +1509,7 @@ def play_torrent(item, xlistitem, mediaurl):
|
||||
else:
|
||||
import xbmcaddon
|
||||
addon = xbmcaddon.Addon(id='plugin.video.elementum')
|
||||
if addon.getSetting('download_storage') == '0':
|
||||
if addon.get_setting('download_storage') == '0':
|
||||
addon.setSetting('download_storage', '1')
|
||||
xbmc.sleep(3000)
|
||||
xbmc.executebuiltin("PlayMedia(" + torrent_options[selection][1] % mediaurl + ")")
|
||||
@@ -1618,7 +1647,7 @@ def get_played_time(item):
|
||||
import traceback
|
||||
logger.error(traceback.format_exc())
|
||||
del db['viewed'][ID]
|
||||
db.close()
|
||||
# db.close()
|
||||
return played_time
|
||||
|
||||
|
||||
|
||||
@@ -92,6 +92,7 @@
|
||||
<setting id="tmdb_active" default="true" visible="false"/>
|
||||
<!-- <setting id="tmdb_threads" type="slider" option="int" range="5,5,30" label="70155" default="20"/>-->
|
||||
<setting id="tmdb_plus_info" type="bool" label="70156" default="false"/>
|
||||
<setting id="episode_info" type="bool" label="60292" default="false"/>
|
||||
<setting id="tmdb_cache" type="bool" label="70157" default="true"/>
|
||||
<setting id="tmdb_cache_expire" type="select" lvalues="70158|70159|70160|70161|70170" label="70162" enable="eq(-1,true)" default="4"/>
|
||||
<setting id="tmdb_clean_db_cache" type="action" label="70163" action="RunPlugin(plugin://plugin.video.kod/?ew0KICAgICJhY3Rpb24iOiAic2NyaXB0Ig0KfQ==)" />
|
||||
|
||||
Reference in New Issue
Block a user