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']),
|
url=host + '/watch/' + str(episodes['title_id']),
|
||||||
episodeid= '?e=' + str(it['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.check_trakt(itemlist)
|
||||||
support.videolibrary(itemlist, item)
|
support.videolibrary(itemlist, item)
|
||||||
support.download(itemlist, item)
|
support.download(itemlist, item)
|
||||||
|
|||||||
+11
-1
@@ -604,7 +604,9 @@ def scrape(func):
|
|||||||
if function == 'episodios': autorenumber.start(itemlist, item)
|
if function == 'episodios': autorenumber.start(itemlist, item)
|
||||||
else: autorenumber.start(itemlist)
|
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)
|
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
|
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)
|
trakt_tools.trakt_check(itemlist)
|
||||||
return 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)
|
||||||
+6
-9
@@ -470,10 +470,9 @@ def find_and_set_infoLabels(item):
|
|||||||
item.infoLabels['year'] = year[1:-1]
|
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("tmdb_id") or not item.infoLabels.get("tmdb_id")[0].isdigit():
|
||||||
if not item.infoLabels.get("imdb_id"):
|
if item.infoLabels.get("imdb_id"): otmdb_global = Tmdb(external_id=item.infoLabels.get("imdb_id"), external_source="imdb_id", search_type=search_type)
|
||||||
otmdb_global = Tmdb(searched_text=scrapertools.unescape(title), search_type=search_type, year=item.infoLabels['year'])
|
else: 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)
|
|
||||||
elif not otmdb_global or str(otmdb_global.result.get("id")) != item.infoLabels['tmdb_id']:
|
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)
|
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)
|
info_nfo = 'https://www.themoviedb.org/tv/{}/episode_group/{}'.format(item.infoLabels['tmdb_id'], Id)
|
||||||
return info_nfo + '\n'
|
return info_nfo + '\n'
|
||||||
else: return
|
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'])
|
info_nfo = ', '.join(item.infoLabels['url_scraper'])
|
||||||
|
|
||||||
return info_nfo + '\n'
|
return info_nfo + '\n'
|
||||||
@@ -643,10 +639,11 @@ class ResultDictDefault(dict):
|
|||||||
|
|
||||||
def __missing__(self, key):
|
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']:
|
if key in ['genre_ids', 'genre', 'genres']:
|
||||||
return list()
|
return list()
|
||||||
|
|
||||||
elif key == 'images_posters':
|
elif key == 'images_posters':
|
||||||
posters = dict()
|
posters = dict()
|
||||||
if 'images' in list(super(ResultDictDefault, self).keys()) and 'posters' in super(ResultDictDefault, self).__getitem__('images'):
|
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:
|
if sys.version_info[0] >= 3:
|
||||||
PY3 = True
|
PY3 = True
|
||||||
import urllib.parse as urllib
|
import urllib.parse as urllib
|
||||||
|
from concurrent import futures
|
||||||
else:
|
else:
|
||||||
PY3 = False
|
PY3 = False
|
||||||
import urllib
|
import urllib
|
||||||
|
from concurrent_py2 import futures
|
||||||
|
|
||||||
|
|
||||||
import os, xbmc, xbmcgui, xbmcplugin
|
import os, xbmc, xbmcgui, xbmcplugin
|
||||||
from past.utils import old_div
|
from past.utils import old_div
|
||||||
@@ -310,33 +313,31 @@ def render_items(itemlist, parent_item):
|
|||||||
"""
|
"""
|
||||||
Function used to render itemlist on kodi
|
Function used to render itemlist on kodi
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# if it's not a list, do nothing
|
# if it's not a list, do nothing
|
||||||
if not isinstance(itemlist, list):
|
if not isinstance(itemlist, list):
|
||||||
return
|
return
|
||||||
|
|
||||||
logger.debug('START render_items')
|
logger.debug('START renderItems')
|
||||||
# save_view_mode()
|
|
||||||
thumb_type = config.get_setting('video_thumbnail_type')
|
thumb_type = config.get_setting('video_thumbnail_type')
|
||||||
from platformcode import shortcuts
|
from platformcode import shortcuts
|
||||||
# from core import httptools
|
|
||||||
_handle = int(sys.argv[1])
|
_handle = int(sys.argv[1])
|
||||||
default_fanart = config.get_fanart()
|
default_fanart = config.get_fanart()
|
||||||
def_context_commands = shortcuts.context()
|
def_context_commands = shortcuts.context()
|
||||||
|
|
||||||
# if there's no item, add "no elements" item
|
# if there's no item, add "no elements" item
|
||||||
if not len(itemlist):
|
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 = []
|
dirItems = []
|
||||||
|
|
||||||
for n, item in enumerate(itemlist):
|
def setItem(n, item, parent_item):
|
||||||
# item.itemlistPosition = n + 1
|
item.itemlistPosition = n
|
||||||
item_url = item.tourl()
|
item_url = item.tourl()
|
||||||
|
|
||||||
if item.category == "":
|
if item.category == "":
|
||||||
item.category = parent_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 there is no action or it is findvideos / play, folder = False because no listing will be returned
|
||||||
if item.action in ['play', 'findvideos', '']:
|
if item.action in ['play', 'findvideos', '']:
|
||||||
item.folder = False
|
item.folder = False
|
||||||
@@ -346,13 +347,33 @@ def render_items(itemlist, parent_item):
|
|||||||
item.thumbnail = config.get_online_server_thumb(item.server)
|
item.thumbnail = config.get_online_server_thumb(item.server)
|
||||||
|
|
||||||
icon_image = "DefaultFolder.png" if item.folder else "DefaultVideo.png"
|
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,
|
title = item.title
|
||||||
'fanart': item.fanart if item.fanart else default_fanart})
|
|
||||||
|
|
||||||
|
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:
|
if config.get_setting("player_mode") == 1 and item.action == "play" and not item.nfo:
|
||||||
listitem.setProperty('IsPlayable', 'true')
|
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)
|
set_infolabels(listitem, item)
|
||||||
|
|
||||||
# context menu
|
# context menu
|
||||||
@@ -361,12 +382,30 @@ def render_items(itemlist, parent_item):
|
|||||||
else:
|
else:
|
||||||
context_commands = def_context_commands
|
context_commands = def_context_commands
|
||||||
listitem.addContextMenuItems(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)
|
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 == '':
|
if parent_item.list_type == '':
|
||||||
breadcrumb = parent_item.category #.capitalize()
|
breadcrumb = parent_item.category #.capitalize()
|
||||||
else:
|
else:
|
||||||
@@ -379,11 +418,11 @@ def render_items(itemlist, parent_item):
|
|||||||
breadcrumb = config.get_localized_string(70693)
|
breadcrumb = config.get_localized_string(70693)
|
||||||
|
|
||||||
xbmcplugin.setPluginCategory(handle=_handle, category=breadcrumb)
|
xbmcplugin.setPluginCategory(handle=_handle, category=breadcrumb)
|
||||||
|
set_view_mode(itemlist[0], parent_item)
|
||||||
|
|
||||||
xbmcplugin.endOfDirectory(_handle, succeeded=True, updateListing=False, cacheToDisc=True)
|
xbmcplugin.endOfDirectory(_handle, succeeded=True, updateListing=False, cacheToDisc=True)
|
||||||
|
from core import db; db.close()
|
||||||
logger.debug('END render_items')
|
logger.debug('END renderItems')
|
||||||
|
|
||||||
|
|
||||||
def viewmodeMonitor():
|
def viewmodeMonitor():
|
||||||
@@ -498,33 +537,23 @@ def set_infolabels(listitem, item, player=False):
|
|||||||
@type item: item
|
@type item: item
|
||||||
"""
|
"""
|
||||||
|
|
||||||
infoLabels_dict = {'aired': 'aired', 'album': 'album', 'artist': 'artist', 'cast': 'cast',
|
infoLabels_dict = {'aired': 'aired', 'album': 'album', 'artist': 'artist', 'cast': 'cast', 'castandrole': 'castandrole',
|
||||||
'castandrole': 'castandrole', 'tmdb_id': 'code', 'code': 'code', 'country': 'country',
|
'tmdb_id': 'code', 'code': 'code', 'country': 'country', 'credits': 'credits', 'release_date': 'dateadded',
|
||||||
'credits': 'credits', 'release_date': 'dateadded', 'dateadded': 'dateadded', 'dbid': 'dbid',
|
'dateadded': 'dateadded', 'dbid': 'dbid', 'director': 'director', 'duration': 'duration', 'episode': 'episode',
|
||||||
'director': 'director', 'duration': 'duration', 'episode': 'episode',
|
'episode_plot': 'episodeguide', 'episode_title': 'title', 'episode_vote_average': 'rating', 'episode_vote_count': 'votes',
|
||||||
'episodio_sinopsis': 'episodeguide', 'episodio_air_date': 'None', 'episodio_imagen': 'None',
|
'genre': 'genre', 'imdb_id': 'imdbnumber', 'imdbnumber': 'imdbnumber', 'last_air_date': 'lastplayed', 'mediatype': 'mediatype',
|
||||||
'episodio_titulo': 'title', 'episodio_vote_average': 'rating', 'episodio_vote_count': 'votes',
|
'mpaa': 'mpaa', 'originaltitle': 'originaltitle', 'overlay': 'overlay', 'poster_path': 'path', 'playcount': 'playcount',
|
||||||
'fanart': 'None', 'genre': 'genre', 'homepage': 'None', 'imdb_id': 'imdbnumber',
|
'plot': 'plot', 'plotoutline': 'plotoutline', 'premiered': 'premiered', 'rating': 'rating', 'season': 'season', 'set': 'set',
|
||||||
'imdbnumber': 'imdbnumber', 'in_production': 'None', 'last_air_date': 'lastplayed',
|
'setid': 'setid', 'setoverview': 'setoverview', 'showlink': 'showlink', 'sortepisode': 'sortepisode', 'sortseason': 'sortseason',
|
||||||
'mediatype': 'mediatype', 'mpaa': 'mpaa', 'number_of_episodes': 'None',
|
'sorttitle': 'sorttitle', 'status': 'status', 'studio': 'studio', 'tag': 'tag', 'tagline': 'tagline', 'title': 'title',
|
||||||
'number_of_seasons': 'None', 'original_language': 'None', 'originaltitle': 'originaltitle',
|
'top250': 'top250', 'tracknumber': 'tracknumber', 'trailer': 'trailer', 'tvshowtitle': 'tvshowtitle', 'userrating': 'userrating',
|
||||||
'overlay': 'overlay', 'poster_path': 'path', 'popularity': 'None', 'playcount': 'playcount',
|
'votes': 'votes', 'writer': 'writer', 'year': 'year'}
|
||||||
'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'}
|
|
||||||
# if item.infoLabels:
|
# if item.infoLabels:
|
||||||
try:
|
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)
|
listitem.setInfo("video", infoLabels_kodi)
|
||||||
except:
|
except:
|
||||||
listitem.setInfo("video", item.infoLabels)
|
listitem.setInfo("video", item.infoLabels)
|
||||||
# logger.error(item.infoLabels)
|
|
||||||
|
|
||||||
|
|
||||||
def set_context_commands(item, item_url, parent_item, **kwargs):
|
def set_context_commands(item, item_url, parent_item, **kwargs):
|
||||||
@@ -1480,7 +1509,7 @@ def play_torrent(item, xlistitem, mediaurl):
|
|||||||
else:
|
else:
|
||||||
import xbmcaddon
|
import xbmcaddon
|
||||||
addon = xbmcaddon.Addon(id='plugin.video.elementum')
|
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')
|
addon.setSetting('download_storage', '1')
|
||||||
xbmc.sleep(3000)
|
xbmc.sleep(3000)
|
||||||
xbmc.executebuiltin("PlayMedia(" + torrent_options[selection][1] % mediaurl + ")")
|
xbmc.executebuiltin("PlayMedia(" + torrent_options[selection][1] % mediaurl + ")")
|
||||||
@@ -1618,7 +1647,7 @@ def get_played_time(item):
|
|||||||
import traceback
|
import traceback
|
||||||
logger.error(traceback.format_exc())
|
logger.error(traceback.format_exc())
|
||||||
del db['viewed'][ID]
|
del db['viewed'][ID]
|
||||||
db.close()
|
# db.close()
|
||||||
return played_time
|
return played_time
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -92,6 +92,7 @@
|
|||||||
<setting id="tmdb_active" default="true" visible="false"/>
|
<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_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="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" 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_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==)" />
|
<setting id="tmdb_clean_db_cache" type="action" label="70163" action="RunPlugin(plugin://plugin.video.kod/?ew0KICAgICJhY3Rpb24iOiAic2NyaXB0Ig0KfQ==)" />
|
||||||
|
|||||||
Reference in New Issue
Block a user