Fix Vari e Pulizia
This commit is contained in:
@@ -6,24 +6,18 @@
|
||||
# version 2.0
|
||||
# ------------------------------------------------------------
|
||||
|
||||
from __future__ import division
|
||||
from __future__ import absolute_import
|
||||
from past.utils import old_div
|
||||
import sys
|
||||
PY3 = False
|
||||
if sys.version_info[0] >= 3: PY3 = True; unicode = str; unichr = chr; long = int
|
||||
|
||||
if PY3:
|
||||
if sys.version_info[0] >= 3:
|
||||
import urllib.parse as urllib
|
||||
else:
|
||||
import urllib
|
||||
|
||||
import os, xbmc, xbmcgui, xbmcplugin
|
||||
|
||||
from past.utils import old_div
|
||||
from channelselector import get_thumb
|
||||
from core import channeltools, trakt_tools, scrapertools
|
||||
from core import trakt_tools, scrapertools
|
||||
from core.item import Item
|
||||
from platformcode import logger, config, unify
|
||||
from platformcode import logger, config
|
||||
|
||||
addon = config.__settings__
|
||||
addon_icon = os.path.join( addon.getAddonInfo( "path" ), "logo.png" )
|
||||
@@ -293,255 +287,6 @@ def set_view_mode(item, parent_item):
|
||||
logger.info('TYPE: ' + Type + ' - ' + 'CONTENT: ' + content)
|
||||
|
||||
|
||||
# def render_items_old(itemlist, parent_item):
|
||||
# """
|
||||
# Function responsible for displaying the itemlist in kodi, the itemlist and the item it comes from are passed as parameters
|
||||
# @type itemlist: list
|
||||
# @param itemlist: list of elements to show
|
||||
|
||||
# @type parent_item: item
|
||||
# @param parent_item: parent element
|
||||
# """
|
||||
# logger.info('START render_items')
|
||||
# from core import httptools
|
||||
|
||||
# # If the itemlist is not a list we leave
|
||||
# if not isinstance(itemlist, list):
|
||||
# return
|
||||
|
||||
# if parent_item.start:
|
||||
# menu_icon = get_thumb('menu.png')
|
||||
# menu = Item(channel="channelselector", action="getmainlist", viewmode="movie", thumbnail=menu_icon, title='Menu')
|
||||
# itemlist.insert(0, menu)
|
||||
|
||||
# # If there is no item, we show a notice
|
||||
# if not len(itemlist):
|
||||
# itemlist.append(Item(title=config.get_localized_string(60347), thumbnail=get_thumb('nofolder.png')))
|
||||
|
||||
# genre = False
|
||||
# if 'nero' in parent_item.title:
|
||||
# genre = True
|
||||
# anime = False
|
||||
# if 'anime' in channeltools.get_channel_parameters(parent_item.channel)['categories']:
|
||||
# anime = True
|
||||
# # try:
|
||||
# # force_unify = channeltools.get_channel_parameters(parent_item.channel)['force_unify']
|
||||
# # except:
|
||||
# force_unify = False
|
||||
|
||||
# unify_enabled = False
|
||||
|
||||
# has_extendedinfo = xbmc.getCondVisibility('System.HasAddon(script.extendedinfo)')
|
||||
|
||||
# # Add SuperFavourites to context menu (1.0.53 or higher required)
|
||||
# sf_file_path = xbmc.translatePath("special://home/addons/plugin.program.super.favourites/LaunchSFMenu.py")
|
||||
# check_sf = os.path.exists(sf_file_path)
|
||||
# superfavourites = check_sf and xbmc.getCondVisibility('System.HasAddon("plugin.program.super.favourites")')
|
||||
# # try:
|
||||
# # if channeltools.get_channel_parameters(parent_item.channel)['adult']:
|
||||
# # unify_enabled = False
|
||||
# # except:
|
||||
# # pass
|
||||
# # logger.debug('unify_enabled: %s' % unify_enabled)
|
||||
|
||||
# # We go through the itemlist
|
||||
# for item in itemlist:
|
||||
# # logger.debug(item)
|
||||
# # If the item does not contain a category, we will add the parent item
|
||||
# item_url = item.tourl()
|
||||
# if item.category == "":
|
||||
# item.category = parent_item.category
|
||||
|
||||
# # If title does not exist, we start it as str, to avoid "NoType" mistakes
|
||||
# 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', '']:
|
||||
# item.folder = False
|
||||
|
||||
# # If the item does not contain fanart, we put the one of the parent item
|
||||
# if item.fanart == "":
|
||||
# item.fanart = parent_item.fanart
|
||||
|
||||
# if genre:
|
||||
# valid_genre = True
|
||||
# thumb = get_thumb(item.title, auto=True)
|
||||
# if thumb != '':
|
||||
# item.thumbnail = thumb
|
||||
# valid_genre = True
|
||||
# elif anime:
|
||||
# valid_genre = True
|
||||
# elif (('siguiente' in item.title.lower() and '>' in item.title) or ('pagina:' in item.title.lower())):
|
||||
# item.thumbnail = get_thumb("next.png")
|
||||
# elif 'add' in item.action:
|
||||
# if 'pelicula' in item.action:
|
||||
# item.thumbnail = get_thumb("add_to_videolibrary.png")
|
||||
# elif 'serie' in item.action:
|
||||
# item.thumbnail = get_thumb("add_to_videolibrary.png")
|
||||
|
||||
# if (unify_enabled or force_unify) and parent_item.channel not in ['kodfavourites']:
|
||||
# # Format title with unify
|
||||
# item = unify.title_format(item)
|
||||
# else:
|
||||
# # Format title method old school
|
||||
# if item.text_color:
|
||||
# item.title = '[COLOR %s]%s[/COLOR]' % (item.text_color, item.title)
|
||||
# if item.text_bold:
|
||||
# item.title = '[B]%s[/B]' % item.title
|
||||
# if item.text_italic:
|
||||
# item.title = '[I]%s[/I]' % item.title
|
||||
|
||||
# # Add headers to images if they are on a server with cloudflare
|
||||
# if item.action == 'play':
|
||||
# item.thumbnail = unify.thumbnail_type(item)
|
||||
# else:
|
||||
# item.thumbnail = httptools.get_url_headers(item.thumbnail)
|
||||
# item.fanart = httptools.get_url_headers(item.fanart)
|
||||
|
||||
# # Icon Image for folder and video
|
||||
# if item.folder:
|
||||
# icon_image = "DefaultFolder.png"
|
||||
# else:
|
||||
# icon_image = "DefaultVideo.png"
|
||||
|
||||
# # fanart
|
||||
# if item.fanart:
|
||||
# fanart = item.fanart
|
||||
# else:
|
||||
# fanart = config.get_fanart()
|
||||
|
||||
# # Create listitem
|
||||
# listitem = xbmcgui.ListItem(item.title)
|
||||
|
||||
# # values icon, thumb or poster are skin dependent.. so we set all to avoid problems
|
||||
# # if not exists thumb it's used icon value
|
||||
# if config.get_platform(True)['num_version'] >= 16.0:
|
||||
# listitem.setArt({'icon': icon_image, 'thumb': item.thumbnail, 'poster': item.thumbnail,
|
||||
# 'fanart': fanart})
|
||||
# else:
|
||||
# listitem.setIconImage(icon_image)
|
||||
# listitem.setThumbnailImage(item.thumbnail)
|
||||
# listitem.setProperty('fanart_image', fanart)
|
||||
|
||||
# # No need it, use fanart instead
|
||||
# # xbmcplugin.setPluginFanart(int(sys.argv[1]), os.path.join(config.get_runtime_path(), "fanart.jpg"))
|
||||
|
||||
# # This option is to be able to use the xbmcplugin.setResolvedUrl()
|
||||
# # if item.isPlayable == True or (config.get_setting("player_mode") == 1 and item.action == "play"):
|
||||
# if config.get_setting("player_mode") == 1 and item.action == "play":
|
||||
# listitem.setProperty('IsPlayable', 'true')
|
||||
|
||||
# # Add infoLabels
|
||||
# set_infolabels(listitem, item)
|
||||
|
||||
# # Do not drag plot if it is not a movie / series / season / episode
|
||||
# if item.plot and item.contentType not in ['movie', 'tvshow', 'season', 'episode']:
|
||||
# item.__dict__['infoLabels'].pop('plot')
|
||||
|
||||
# # Mount context menu
|
||||
# if parent_item.channel != 'special':
|
||||
# context_commands = set_context_commands(item, item_url, parent_item, has_extendedinfo=has_extendedinfo, superfavourites=superfavourites)
|
||||
# else:
|
||||
# context_commands = []
|
||||
# # Add context menu
|
||||
# if config.get_platform(True)['num_version'] >= 17.0 and parent_item.list_type == '':
|
||||
# listitem.addContextMenuItems(context_commands)
|
||||
# elif parent_item.list_type == '':
|
||||
# listitem.addContextMenuItems(context_commands, replaceItems=True)
|
||||
|
||||
# from specials import shortcuts
|
||||
# context_commands += shortcuts.context()
|
||||
|
||||
# if not item.totalItems:
|
||||
# item.totalItems = 0
|
||||
# xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url='%s?%s' % (sys.argv[0], item_url),
|
||||
# listitem=listitem, isFolder=item.folder,
|
||||
# totalItems=item.totalItems)
|
||||
|
||||
# # Set types of views ...
|
||||
# if config.get_setting("forceview"): # ...force according to the viewcontent
|
||||
# xbmcplugin.setContent(int(sys.argv[1]), parent_item.viewcontent)
|
||||
|
||||
# elif parent_item.channel not in ["channelselector", "", "kodfavourites"]: # ... or according to the channel
|
||||
# xbmcplugin.setContent(int(sys.argv[1]), "movies")
|
||||
|
||||
# elif parent_item.channel == "kodfavourites" and parent_item.action == 'mostrar_perfil':
|
||||
# xbmcplugin.setContent(int(sys.argv[1]), "movies")
|
||||
|
||||
# # set "breadcrumb"
|
||||
# if parent_item.list_type == '':
|
||||
# breadcrumb = parent_item.category.capitalize()
|
||||
# else:
|
||||
# if 'similar' in parent_item.list_type:
|
||||
# if parent_item.contentTitle != '':
|
||||
# breadcrumb = config.get_localized_string(70693) + parent_item.contentTitle
|
||||
# else:
|
||||
# breadcrumb = config.get_localized_string(70693) + parent_item.contentSerieName
|
||||
# else:
|
||||
# breadcrumb = config.get_localized_string(70693)
|
||||
|
||||
# xbmcplugin.setPluginCategory(handle=int(sys.argv[1]), category=breadcrumb)
|
||||
|
||||
# # Do not sort items
|
||||
# xbmcplugin.addSortMethod(handle=int(sys.argv[1]), sortMethod=xbmcplugin.SORT_METHOD_NONE)
|
||||
|
||||
# # We close the directory
|
||||
# xbmcplugin.endOfDirectory(handle=int(sys.argv[1]), succeeded=True)
|
||||
|
||||
# # Fix the view
|
||||
# # if config.get_setting("forceview"):
|
||||
# # viewmode_id = get_viewmode_id(parent_item)
|
||||
# # xbmc.executebuiltin("Container.SetViewMode(%s)" % viewmode_id)
|
||||
# # if parent_item.mode in ['silent', 'get_cached', 'set_cache', 'finish']:
|
||||
# # xbmc.executebuiltin("Container.SetViewMode(500)")
|
||||
|
||||
# logger.info('END render_items')
|
||||
|
||||
|
||||
# def get_viewmode_id(parent_item):
|
||||
# # viewmode_json would have to save it in a file and create a method for the user to set their preferences in:
|
||||
# # user_files, user_movies, user_tvshows, user_season and user_episodes.
|
||||
# viewmode_json = {'skin.confluence': {'default_files': 50,
|
||||
# 'default_movies': 515,
|
||||
# 'default_tvshows': 508,
|
||||
# 'default_seasons': 503,
|
||||
# 'default_episodes': 504,
|
||||
# 'view_list': 50,
|
||||
# 'view_thumbnails': 500,
|
||||
# 'view_movie_with_plot': 503},
|
||||
# 'skin.estuary': {'default_files': 50,
|
||||
# 'default_movies': 54,
|
||||
# 'default_tvshows': 502,
|
||||
# 'default_seasons': 500,
|
||||
# 'default_episodes': 53,
|
||||
# 'view_list': 50,
|
||||
# 'view_thumbnails': 500,
|
||||
# 'view_movie_with_plot': 54}}
|
||||
|
||||
# # If the parent_item had a viewmode set we use that view ...
|
||||
# if parent_item.viewmode == 'movie':
|
||||
# # We replace the old viewmode 'movie' with 'thumbnails'
|
||||
# parent_item.viewmode = 'thumbnails'
|
||||
|
||||
# if parent_item.viewmode in ["list", "movie_with_plot", "thumbnails"]:
|
||||
# view_name = "view_" + parent_item.viewmode
|
||||
|
||||
# '''elif isinstance(parent_item.viewmode, int):
|
||||
# # only for debug
|
||||
# viewName = parent_item.viewmode'''
|
||||
|
||||
# # ...otherwise we put the default view according to the viewcontent
|
||||
# else:
|
||||
# view_name = "default_" + parent_item.viewcontent
|
||||
|
||||
# skin_name = xbmc.getSkinDir()
|
||||
# if skin_name not in viewmode_json:
|
||||
# skin_name = 'skin.confluence'
|
||||
# view_skin = viewmode_json[skin_name]
|
||||
# return view_skin.get(view_name, 50)
|
||||
|
||||
|
||||
def set_infolabels(listitem, item, player=False):
|
||||
"""
|
||||
Method to pass the information to the listitem (see tmdb.set_InfoLabels())
|
||||
@@ -582,32 +327,6 @@ def set_infolabels(listitem, item, player=False):
|
||||
listitem.setInfo("video", item.infoLabels)
|
||||
# logger.error(item.infoLabels)
|
||||
|
||||
# if item.infoLabels:
|
||||
# if 'mediatype' not in item.infoLabels:
|
||||
# item.infoLabels['mediatype'] = item.contentType
|
||||
#
|
||||
# try:
|
||||
# for label_tag, label_value in list(item.infoLabels.items()):
|
||||
# try:
|
||||
# # logger.debug(str(label_tag) + ': ' + str(infoLabels_dict[label_tag]))
|
||||
# if infoLabels_dict[label_tag] != 'None':
|
||||
# infoLabels_kodi.update({infoLabels_dict[label_tag]: item.infoLabels[label_tag]})
|
||||
# except:
|
||||
# continue
|
||||
#
|
||||
# listitem.setInfo("video", infoLabels_kodi)
|
||||
#
|
||||
# except:
|
||||
# listitem.setInfo("video", item.infoLabels)
|
||||
# logger.error(item.infoLabels)
|
||||
# logger.error(infoLabels_kodi)
|
||||
#
|
||||
# if player and not item.contentTitle:
|
||||
# listitem.setInfo("video", {"Title": item.title})
|
||||
#
|
||||
# elif not player:
|
||||
# listitem.setInfo("video", {"Title": item.title})
|
||||
|
||||
|
||||
def set_context_commands(item, item_url, parent_item, **kwargs):
|
||||
"""
|
||||
@@ -686,17 +405,12 @@ def set_context_commands(item, item_url, parent_item, **kwargs):
|
||||
# ExtendedInfo: If the addon is installed and a series of conditions are met
|
||||
if kwargs.get('has_extendedinfo') \
|
||||
and config.get_setting("extended_info") == True:
|
||||
if item.contentType == "episode" and item.contentEpisodeNumber and item.contentSeason \
|
||||
and (item.infoLabels['tmdb_id'] or item.contentSerieName):
|
||||
param = "tvshow_id =%s, tvshow=%s, season=%s, episode=%s" \
|
||||
% (item.infoLabels['tmdb_id'], item.contentSerieName, item.contentSeason,
|
||||
item.contentEpisodeNumber)
|
||||
if item.contentType == "episode" and item.contentEpisodeNumber and item.contentSeason and (item.infoLabels['tmdb_id'] or item.contentSerieName):
|
||||
param = "tvshow_id =%s, tvshow=%s, season=%s, episode=%s" % (item.infoLabels['tmdb_id'], item.contentSerieName, item.contentSeason, item.contentEpisodeNumber)
|
||||
context_commands.append(("ExtendedInfo", "XBMC.RunScript(script.extendedinfo,info=extendedepisodeinfo,%s)" % param))
|
||||
|
||||
elif item.contentType == "season" and item.contentSeason \
|
||||
and (item.infoLabels['tmdb_id'] or item.contentSerieName):
|
||||
param = "tvshow_id =%s,tvshow=%s, season=%s" \
|
||||
% (item.infoLabels['tmdb_id'], item.contentSerieName, item.contentSeason)
|
||||
elif item.contentType == "season" and item.contentSeason and (item.infoLabels['tmdb_id'] or item.contentSerieName):
|
||||
param = "tvshow_id =%s,tvshow=%s, season=%s" % (item.infoLabels['tmdb_id'], item.contentSerieName, item.contentSeason)
|
||||
context_commands.append(("ExtendedInfo", "XBMC.RunScript(script.extendedinfo,info=seasoninfo,%s)" % param))
|
||||
|
||||
elif item.contentType == "tvshow" and (item.infoLabels['tmdb_id'] or item.infoLabels['tvdb_id'] or item.infoLabels['imdb_id'] or item.contentSerieName):
|
||||
@@ -705,15 +419,14 @@ def set_context_commands(item, item_url, parent_item, **kwargs):
|
||||
|
||||
elif item.contentType == "movie" and (item.infoLabels['tmdb_id'] or item.infoLabels['imdb_id'] or item.contentTitle):
|
||||
param = "id =%s,imdb_id=%s,name=%s" % (item.infoLabels['tmdb_id'], item.infoLabels['imdb_id'], item.contentTitle)
|
||||
|
||||
context_commands.append(("ExtendedInfo", "XBMC.RunScript(script.extendedinfo,info=extendedinfo,%s)" % param))
|
||||
# InfoPlus
|
||||
|
||||
# InfoPlus
|
||||
if config.get_setting("infoplus"):
|
||||
#if item.infoLabels['tmdb_id'] or item.infoLabels['imdb_id'] or item.infoLabels['tvdb_id'] or \
|
||||
# (item.contentTitle and item.infoLabels["year"]) or item.contentSerieName:
|
||||
if item.infoLabels['tmdb_id'] or item.infoLabels['imdb_id'] or item.infoLabels['tvdb_id']:
|
||||
context_commands.append(("InfoPlus", "XBMC.RunPlugin(%s?%s&%s)" % (sys.argv[0], item_url,
|
||||
'channel=infoplus&action=start&from_channel=' + item.channel)))
|
||||
context_commands.append(("InfoPlus", "XBMC.RunPlugin(%s?%s&%s)" % (sys.argv[0], item_url, 'channel=infoplus&action=start&from_channel=' + item.channel)))
|
||||
|
||||
# Go to the Main Menu (channel.mainlist)
|
||||
if parent_item.channel not in ["news", "channelselector", "downloads"] and item.action != "mainlist":
|
||||
@@ -721,13 +434,6 @@ def set_context_commands(item, item_url, parent_item, **kwargs):
|
||||
context_commands.insert(0, (config.get_localized_string(60349), "XBMC.Container.Refresh (%s?%s)" % (sys.argv[0], Item(channel=item.channel, action="mainlist").tourl())))
|
||||
context_commands.insert(1, (config.get_localized_string(70739), "XBMC.Container.Update (%s?%s)" % (sys.argv[0], Item(action="open_browser", url=item.url).tourl())))
|
||||
|
||||
# Add to Favorites
|
||||
# if num_version_xbmc < 17.0 and \
|
||||
# ((item.channel not in ["favorites", "videolibrary", "help", ""]
|
||||
# or item.action in ["update_videolibrary"]) and parent_item.channel != "favorites"):
|
||||
# context_commands.append((config.get_localized_string(30155), "XBMC.RunPlugin(%s?%s&%s)" %
|
||||
# (sys.argv[0], item_url, 'channel=favorites&action=addFavourite&from_channel=' + item.channel + '&from_action=' + item.action)))
|
||||
|
||||
# Add to kodfavoritos (My links)
|
||||
if item.channel not in ["favorites", "videolibrary", "help", ""] and parent_item.channel != "favorites":
|
||||
context_commands.append( (config.get_localized_string(70557), "XBMC.RunPlugin(%s?%s&%s)" % (sys.argv[0], item_url, urllib.urlencode({'channel': "kodfavorites", 'action': "addFavourite", 'from_channel': item.channel, 'from_action': item.action}))))
|
||||
@@ -748,6 +454,7 @@ def set_context_commands(item, item_url, parent_item, **kwargs):
|
||||
context_commands.append((config.get_localized_string(60350), "XBMC.Container.Update (%s?%s&%s)" % (sys.argv[0], item_url, urllib.urlencode({'channel': 'search', 'action': "from_context", 'from_channel': item.channel, 'contextual': True, 'text': item.wanted}))))
|
||||
|
||||
context_commands.append( (config.get_localized_string(70561), "XBMC.Container.Update (%s?%s&%s)" % (sys.argv[0], item_url, 'channel=search&action=from_context&search_type=list&page=1&list_type=%s/%s/similar' % (mediatype, item.infoLabels['tmdb_id']))))
|
||||
|
||||
# Set as Home Page
|
||||
if config.get_setting('start_page'):
|
||||
if item.action not in ['episodios', 'seasons', 'findvideos', 'play']:
|
||||
@@ -780,11 +487,6 @@ def set_context_commands(item, item_url, parent_item, **kwargs):
|
||||
elif item.contentType == "season":
|
||||
context_commands.append((config.get_localized_string(60357), "XBMC.RunPlugin(%s?%s&%s)" % (sys.argv[0], item_url, 'channel=downloads&action=save_download&download=season&from_channel=' + item.channel + '&from_action=' + item.action)))
|
||||
|
||||
# # Open settings
|
||||
# if parent_item.channel not in ["setting", "news", "search"] and item.action == "play":
|
||||
# context_commands.append((config.get_localized_string(60358), "XBMC.Container.Update(%s?%s)" %
|
||||
# (sys.argv[0], Item(channel="setting", action="mainlist").tourl())))
|
||||
|
||||
# Open settings...
|
||||
if item.action in ["findvideos", 'episodios', 'check', 'new_search'] or "buscar_trailer" in context:
|
||||
context_commands.append((config.get_localized_string(60359), "XBMC.RunPlugin(%s?%s)" % (sys.argv[0], urllib.urlencode({ 'channel': "trailertools", 'action': "buscartrailer", 'search_title': item.contentTitle if item.contentTitle else item.fulltitle, 'contextual': True}))))
|
||||
@@ -792,14 +494,6 @@ def set_context_commands(item, item_url, parent_item, **kwargs):
|
||||
if kwargs.get('superfavourites'):
|
||||
context_commands.append((config.get_localized_string(60361), "XBMC.RunScript(special://home/addons/plugin.program.super.favourites/LaunchSFMenu.py)"))
|
||||
|
||||
# context_commands = sorted(context_commands, key=lambda comand: comand[0])
|
||||
|
||||
# Quick Menu
|
||||
# context_commands.insert(0, (config.get_localized_string(60360),
|
||||
# "XBMC.Container.Update (%s?%s)" % (sys.argv[0], Item(channel='side_menu',
|
||||
# action="open_menu",
|
||||
# parent=parent_item.tourl()).tourl(
|
||||
# ))))
|
||||
if config.dev_mode():
|
||||
context_commands.insert(0, ("item info", "XBMC.Container.Update (%s?%s)" % (sys.argv[0], Item(action="itemInfo", parent=item.tojson()).tourl())))
|
||||
return context_commands
|
||||
@@ -824,7 +518,6 @@ def play_video(item, strm=False, force_direct=False, autoplay=False):
|
||||
|
||||
set_infolabels(xlistitem, item, True)
|
||||
set_player(item, xlistitem, item.url, True, None) # Fix Play From Download Section
|
||||
# xbmc_player.play(item.url, xlistitem)
|
||||
return
|
||||
|
||||
default_action = config.get_setting("default_action")
|
||||
|
||||
Reference in New Issue
Block a user