Update platformtools.py
This commit is contained in:
@@ -16,31 +16,21 @@ import config
|
|||||||
import xbmc
|
import xbmc
|
||||||
import xbmcgui
|
import xbmcgui
|
||||||
import xbmcplugin
|
import xbmcplugin
|
||||||
from core.item import Item
|
|
||||||
from core import scrapertools
|
|
||||||
from core import httptools
|
|
||||||
from core import jsontools
|
|
||||||
from platformcode import logger
|
|
||||||
from channelselector import get_thumb
|
from channelselector import get_thumb
|
||||||
from core import trakt_tools
|
from core import trakt_tools
|
||||||
|
from core.item import Item
|
||||||
|
from platformcode import logger
|
||||||
|
|
||||||
|
|
||||||
class XBMCPlayer( xbmc.Player ):
|
class XBMCPlayer(xbmc.Player):
|
||||||
|
|
||||||
def __init__( self, *args ):
|
def __init__(self, *args):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def onPlaybackEnded(self):
|
|
||||||
logger.info()
|
|
||||||
from time import sleep
|
|
||||||
sleep(20)
|
|
||||||
for mediatype in ['movies', 'shows']:
|
|
||||||
trakt_data = trakt_tools.get_trakt_watched('tmdb', mediatype, True)
|
|
||||||
trakt_tools.update_trakt_data(mediatype, trakt_data)
|
|
||||||
|
|
||||||
|
|
||||||
xbmc_player = XBMCPlayer()
|
xbmc_player = XBMCPlayer()
|
||||||
|
|
||||||
|
|
||||||
def dialog_ok(heading, line1, line2="", line3=""):
|
def dialog_ok(heading, line1, line2="", line3=""):
|
||||||
dialog = xbmcgui.Dialog()
|
dialog = xbmcgui.Dialog()
|
||||||
return dialog.ok(heading, line1, line2, line3)
|
return dialog.ok(heading, line1, line2, line3)
|
||||||
@@ -116,7 +106,6 @@ def render_items(itemlist, parent_item):
|
|||||||
"""
|
"""
|
||||||
# Si el itemlist no es un list salimos
|
# Si el itemlist no es un list salimos
|
||||||
if not type(itemlist) == list:
|
if not type(itemlist) == list:
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
if parent_item.start:
|
if parent_item.start:
|
||||||
@@ -176,7 +165,6 @@ def render_items(itemlist, parent_item):
|
|||||||
listitem.setThumbnailImage(item.thumbnail)
|
listitem.setThumbnailImage(item.thumbnail)
|
||||||
listitem.setProperty('fanart_image', fanart)
|
listitem.setProperty('fanart_image', fanart)
|
||||||
|
|
||||||
|
|
||||||
# No need it, use fanart instead
|
# No need it, use fanart instead
|
||||||
# xbmcplugin.setPluginFanart(int(sys.argv[1]), os.path.join(config.get_runtime_path(), "fanart.jpg"))
|
# xbmcplugin.setPluginFanart(int(sys.argv[1]), os.path.join(config.get_runtime_path(), "fanart.jpg"))
|
||||||
|
|
||||||
@@ -226,12 +214,11 @@ def render_items(itemlist, parent_item):
|
|||||||
if config.get_setting("forceview"):
|
if config.get_setting("forceview"):
|
||||||
viewmode_id = get_viewmode_id(parent_item)
|
viewmode_id = get_viewmode_id(parent_item)
|
||||||
xbmc.executebuiltin("Container.SetViewMode(%s)" % viewmode_id)
|
xbmc.executebuiltin("Container.SetViewMode(%s)" % viewmode_id)
|
||||||
if parent_item.mode in ['silent', 'get_cached', 'set_cache','finish']:
|
if parent_item.mode in ['silent', 'get_cached', 'set_cache', 'finish']:
|
||||||
xbmc.executebuiltin("Container.SetViewMode(500)")
|
xbmc.executebuiltin("Container.SetViewMode(500)")
|
||||||
|
|
||||||
|
|
||||||
def get_viewmode_id(parent_item):
|
def get_viewmode_id(parent_item):
|
||||||
|
|
||||||
# viewmode_json habria q guardarlo en un archivo y crear un metodo para q el user fije sus preferencias en:
|
# viewmode_json habria q guardarlo en un archivo y crear un metodo para q el user fije sus preferencias en:
|
||||||
# user_files, user_movies, user_tvshows, user_season y user_episodes.
|
# user_files, user_movies, user_tvshows, user_season y user_episodes.
|
||||||
viewmode_json = {'skin.confluence': {'default_files': 50,
|
viewmode_json = {'skin.confluence': {'default_files': 50,
|
||||||
@@ -388,7 +375,7 @@ def set_context_commands(item, parent_item):
|
|||||||
"XBMC.RunScript(script.extendedinfo,info=seasoninfo,%s)" % param))
|
"XBMC.RunScript(script.extendedinfo,info=seasoninfo,%s)" % param))
|
||||||
|
|
||||||
elif item.contentType == "tvshow" and (item.infoLabels['tmdb_id'] or item.infoLabels['tvdb_id'] or
|
elif item.contentType == "tvshow" and (item.infoLabels['tmdb_id'] or item.infoLabels['tvdb_id'] or
|
||||||
item.infoLabels['imdb_id'] or item.contentSerieName):
|
item.infoLabels['imdb_id'] or item.contentSerieName):
|
||||||
param = "id =%s,tvdb_id=%s,imdb_id=%s,name=%s" \
|
param = "id =%s,tvdb_id=%s,imdb_id=%s,name=%s" \
|
||||||
% (item.infoLabels['tmdb_id'], item.infoLabels['tvdb_id'], item.infoLabels['imdb_id'],
|
% (item.infoLabels['tmdb_id'], item.infoLabels['tvdb_id'], item.infoLabels['imdb_id'],
|
||||||
item.contentSerieName)
|
item.contentSerieName)
|
||||||
@@ -396,14 +383,14 @@ def set_context_commands(item, parent_item):
|
|||||||
"XBMC.RunScript(script.extendedinfo,info=extendedtvinfo,%s)" % param))
|
"XBMC.RunScript(script.extendedinfo,info=extendedtvinfo,%s)" % param))
|
||||||
|
|
||||||
elif item.contentType == "movie" and (item.infoLabels['tmdb_id'] or item.infoLabels['imdb_id'] or
|
elif item.contentType == "movie" and (item.infoLabels['tmdb_id'] or item.infoLabels['imdb_id'] or
|
||||||
item.contentTitle):
|
item.contentTitle):
|
||||||
param = "id =%s,imdb_id=%s,name=%s" \
|
param = "id =%s,imdb_id=%s,name=%s" \
|
||||||
% (item.infoLabels['tmdb_id'], item.infoLabels['imdb_id'], item.contentTitle)
|
% (item.infoLabels['tmdb_id'], item.infoLabels['imdb_id'], item.contentTitle)
|
||||||
context_commands.append(("ExtendedInfo",
|
context_commands.append(("ExtendedInfo",
|
||||||
"XBMC.RunScript(script.extendedinfo,info=extendedinfo,%s)" % param))
|
"XBMC.RunScript(script.extendedinfo,info=extendedinfo,%s)" % param))
|
||||||
|
|
||||||
# InfoPlus
|
# InfoPlus
|
||||||
if config.get_setting("infoplus") == True:
|
if config.get_setting("infoplus"):
|
||||||
if item.infoLabels['tmdb_id'] or item.infoLabels['imdb_id'] or item.infoLabels['tvdb_id'] or \
|
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:
|
(item.contentTitle and item.infoLabels["year"]) or item.contentSerieName:
|
||||||
context_commands.append(("InfoPlus", "XBMC.RunPlugin(%s?%s)" % (sys.argv[0], item.clone(
|
context_commands.append(("InfoPlus", "XBMC.RunPlugin(%s?%s)" % (sys.argv[0], item.clone(
|
||||||
@@ -423,11 +410,11 @@ def set_context_commands(item, parent_item):
|
|||||||
(sys.argv[0], item.clone(channel="favorites", action="addFavourite",
|
(sys.argv[0], item.clone(channel="favorites", action="addFavourite",
|
||||||
from_channel=item.channel,
|
from_channel=item.channel,
|
||||||
from_action=item.action).tourl())))
|
from_action=item.action).tourl())))
|
||||||
#Buscar en otros canales
|
# Buscar en otros canales
|
||||||
if item.contentType in ['movie','tvshow']and item.channel != 'search':
|
if item.contentType in ['movie', 'tvshow'] and item.channel != 'search':
|
||||||
# Buscar en otros canales
|
# Buscar en otros canales
|
||||||
if item.contentSerieName!='':
|
if item.contentSerieName != '':
|
||||||
item.wanted=item.contentSerieName
|
item.wanted = item.contentSerieName
|
||||||
else:
|
else:
|
||||||
item.wanted = item.contentTitle
|
item.wanted = item.contentTitle
|
||||||
context_commands.append(("[COLOR yellow]Buscar en otros canales[/COLOR]",
|
context_commands.append(("[COLOR yellow]Buscar en otros canales[/COLOR]",
|
||||||
@@ -437,14 +424,14 @@ def set_context_commands(item, parent_item):
|
|||||||
from_channel=item.channel,
|
from_channel=item.channel,
|
||||||
|
|
||||||
contextual=True).tourl())))
|
contextual=True).tourl())))
|
||||||
#Definir como Pagina de inicio
|
# Definir como Pagina de inicio
|
||||||
if config.get_setting('start_page'):
|
if config.get_setting('start_page'):
|
||||||
if item.action not in ['findvideos', 'play']:
|
if item.action not in ['findvideos', 'play']:
|
||||||
context_commands.insert(0, ("[COLOR 0xffccff00]Definir como pagina de inicio[/COLOR]",
|
context_commands.insert(0, ("[COLOR 0xffccff00]Definir como pagina de inicio[/COLOR]",
|
||||||
"XBMC.RunPlugin(%s?%s)" % (
|
"XBMC.RunPlugin(%s?%s)" % (
|
||||||
sys.argv[0], Item(channel='side_menu',
|
sys.argv[0], Item(channel='side_menu',
|
||||||
action="set_custom_start",
|
action="set_custom_start",
|
||||||
parent=item.tourl()).tourl())))
|
parent=item.tourl()).tourl())))
|
||||||
|
|
||||||
if item.channel != "videolibrary":
|
if item.channel != "videolibrary":
|
||||||
# Añadir Serie a la videoteca
|
# Añadir Serie a la videoteca
|
||||||
@@ -505,21 +492,17 @@ def set_context_commands(item, parent_item):
|
|||||||
context_commands.append(("Super Favourites Menu",
|
context_commands.append(("Super Favourites Menu",
|
||||||
"XBMC.RunScript(special://home/addons/plugin.program.super.favourites/LaunchSFMenu.py)"))
|
"XBMC.RunScript(special://home/addons/plugin.program.super.favourites/LaunchSFMenu.py)"))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
context_commands = sorted(context_commands, key=lambda comand: comand[0])
|
context_commands = sorted(context_commands, key=lambda comand: comand[0])
|
||||||
# Menu Rapido
|
# Menu Rapido
|
||||||
context_commands.insert(0,("[COLOR 0xffccff00]<Menú Rápido>[/COLOR]",
|
context_commands.insert(0, ("[COLOR 0xffccff00]<Menú Rápido>[/COLOR]",
|
||||||
"XBMC.Container.Update (%s?%s)" % (sys.argv[0], Item(channel='side_menu',
|
"XBMC.Container.Update (%s?%s)" % (sys.argv[0], Item(channel='side_menu',
|
||||||
action="open_menu",
|
action="open_menu",
|
||||||
parent=parent_item.tourl()).tourl(
|
parent=parent_item.tourl()).tourl(
|
||||||
|
|
||||||
))))
|
))))
|
||||||
return context_commands
|
return context_commands
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def is_playing():
|
def is_playing():
|
||||||
return xbmc_player.isPlaying()
|
return xbmc_player.isPlaying()
|
||||||
|
|
||||||
@@ -600,10 +583,7 @@ def play_video(item, strm=False, force_direct=False, autoplay=False):
|
|||||||
set_player(item, xlistitem, mediaurl, view, strm)
|
set_player(item, xlistitem, mediaurl, view, strm)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def stop_video():
|
def stop_video():
|
||||||
from time import sleep
|
|
||||||
xbmc_player.stop()
|
xbmc_player.stop()
|
||||||
|
|
||||||
|
|
||||||
@@ -787,7 +767,7 @@ def set_opcion(item, seleccion, opciones, video_urls):
|
|||||||
listitem = xbmcgui.ListItem(item.title)
|
listitem = xbmcgui.ListItem(item.title)
|
||||||
|
|
||||||
if config.get_platform(True)['num_version'] >= 16.0:
|
if config.get_platform(True)['num_version'] >= 16.0:
|
||||||
listitem.setArt({'icon':"DefaultVideo.png", 'thumb': item.thumbnail})
|
listitem.setArt({'icon': "DefaultVideo.png", 'thumb': item.thumbnail})
|
||||||
else:
|
else:
|
||||||
listitem.setIconImage("DefaultVideo.png")
|
listitem.setIconImage("DefaultVideo.png")
|
||||||
listitem.setThumbnailImage(item.thumbnail)
|
listitem.setThumbnailImage(item.thumbnail)
|
||||||
@@ -816,20 +796,6 @@ def set_opcion(item, seleccion, opciones, video_urls):
|
|||||||
favorites.addFavourite(item)
|
favorites.addFavourite(item)
|
||||||
salir = True
|
salir = True
|
||||||
|
|
||||||
# "Añadir a videoteca":
|
|
||||||
elif opciones[seleccion] == config.get_localized_string(30161):
|
|
||||||
titulo = item.fulltitle
|
|
||||||
if titulo == "":
|
|
||||||
titulo = item.title
|
|
||||||
|
|
||||||
new_item = item.clone(title=titulo, action="play_from_library", category="Cine",
|
|
||||||
fulltitle=item.fulltitle, channel=item.channel)
|
|
||||||
|
|
||||||
from core import videolibrarytools
|
|
||||||
videolibrarytools.add_movie(new_item)
|
|
||||||
|
|
||||||
salir = True
|
|
||||||
|
|
||||||
# "Buscar Trailer":
|
# "Buscar Trailer":
|
||||||
elif opciones[seleccion] == config.get_localized_string(30162):
|
elif opciones[seleccion] == config.get_localized_string(30162):
|
||||||
config.set_setting("subtitulo", False)
|
config.set_setting("subtitulo", False)
|
||||||
@@ -911,11 +877,11 @@ def set_player(item, xlistitem, mediaurl, view, strm):
|
|||||||
playlist.add(mediaurl, xlistitem)
|
playlist.add(mediaurl, xlistitem)
|
||||||
|
|
||||||
# Reproduce
|
# Reproduce
|
||||||
#xbmc_player = xbmc_player
|
# xbmc_player = xbmc_player
|
||||||
xbmc_player.play(playlist, xlistitem)
|
xbmc_player.play(playlist, xlistitem)
|
||||||
while xbmc_player.isPlaying():
|
if config.get_setting('trakt_sync'):
|
||||||
xbmc.sleep(200)
|
trakt_tools.wait_for_update_trakt()
|
||||||
xbmc_player.onPlaybackEnded()
|
|
||||||
# elif config.get_setting("player_mode") == 1 or item.isPlayable:
|
# elif config.get_setting("player_mode") == 1 or item.isPlayable:
|
||||||
elif config.get_setting("player_mode") == 1:
|
elif config.get_setting("player_mode") == 1:
|
||||||
logger.info("mediaurl :" + mediaurl)
|
logger.info("mediaurl :" + mediaurl)
|
||||||
@@ -1067,7 +1033,7 @@ def play_torrent(item, xlistitem, mediaurl):
|
|||||||
playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
|
playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
|
||||||
playlist.clear()
|
playlist.clear()
|
||||||
playlist.add(videourl, xlistitem)
|
playlist.add(videourl, xlistitem)
|
||||||
#xbmc_player = xbmc_player
|
# xbmc_player = xbmc_player
|
||||||
xbmc_player.play(playlist)
|
xbmc_player.play(playlist)
|
||||||
|
|
||||||
# Marcamos como reproducido para que no se vuelva a iniciar
|
# Marcamos como reproducido para que no se vuelva a iniciar
|
||||||
|
|||||||
Reference in New Issue
Block a user