Test forza server in finestra pop-up
This commit is contained in:
@@ -233,24 +233,8 @@ def run(item=None):
|
||||
|
||||
# Special action for findvideos, where the plugin looks for known urls
|
||||
elif item.action == "findvideos":
|
||||
from core import servertools
|
||||
if reload:
|
||||
item.autoplay = True
|
||||
platformtools.fakeVideo()
|
||||
|
||||
# First checks if channel has a "findvideos" function
|
||||
if hasattr(channel, 'findvideos'):
|
||||
itemlist = getattr(channel, item.action)(item)
|
||||
|
||||
# If not, uses the generic findvideos function
|
||||
else:
|
||||
logger.debug("No channel 'findvideos' method, " "executing core method")
|
||||
itemlist = servertools.find_video_items(item)
|
||||
|
||||
if config.get_setting("max_links", "videolibrary") != 0:
|
||||
itemlist = limit_itemlist(itemlist)
|
||||
|
||||
platformtools.render_items(itemlist, item)
|
||||
findvideos(item)
|
||||
# platformtools.render_items(itemlist, item)
|
||||
|
||||
# Special action for adding a movie to the library
|
||||
elif item.action == "add_pelicula_to_library":
|
||||
@@ -446,6 +430,37 @@ def limit_itemlist(itemlist):
|
||||
return itemlist
|
||||
|
||||
|
||||
def findvideos(item):
|
||||
logger.debug('Executing channel', item.channel, 'method', item.action)
|
||||
channel = platformtools.channelImport(item.channel)
|
||||
if not channel:
|
||||
logger.debug('Channel', item.channel, 'not exist!')
|
||||
return
|
||||
from core import servertools
|
||||
|
||||
p_dialog = platformtools.dialog_progress_bg(config.get_localized_string(20000), config.get_localized_string(60683))
|
||||
p_dialog.update(0)
|
||||
|
||||
# First checks if channel has a "findvideos" function
|
||||
if hasattr(channel, 'findvideos'):
|
||||
itemlist = getattr(channel, item.action)(item)
|
||||
|
||||
# If not, uses the generic findvideos function
|
||||
else:
|
||||
logger.debug('No channel "findvideos" method, executing core method')
|
||||
itemlist = servertools.find_video_items(item)
|
||||
|
||||
itemlist = limit_itemlist(itemlist)
|
||||
|
||||
p_dialog.update(100)
|
||||
p_dialog.close()
|
||||
|
||||
# If there is only one server play it immediately
|
||||
# if len(itemlist) == 1 or len(itemlist) > 1 and not itemlist[1].server:
|
||||
# play(itemlist[0].clone(no_return=True))
|
||||
# else:
|
||||
platformtools.serverWindow(item, itemlist)
|
||||
|
||||
def play_from_library(item):
|
||||
"""
|
||||
The .strm files when played from kodi, this expects it to be a "playable" file so it cannot contain
|
||||
@@ -458,110 +473,10 @@ def play_from_library(item):
|
||||
@param item: item with information
|
||||
"""
|
||||
|
||||
def get_played_time(item):
|
||||
from core import videolibrarytools
|
||||
|
||||
if item.contentType == 'movie':
|
||||
nfo_path = item.nfo
|
||||
if nfo_path.startswith('\\') or nfo_path.startswith('/'):
|
||||
nfo_path = filetools.join(videolibrarytools.MOVIES_PATH, nfo_path)
|
||||
|
||||
else:
|
||||
nfo_path =item.strm_path.replace('strm','nfo')
|
||||
if nfo_path.startswith('\\') or nfo_path.startswith('/'):
|
||||
nfo_path = filetools.join(videolibrarytools.TVSHOWS_PATH, nfo_path)
|
||||
|
||||
if nfo_path and filetools.isfile(nfo_path):
|
||||
head_nfo, item_nfo = videolibrarytools.read_nfo(nfo_path)
|
||||
sleep(1)
|
||||
played_time = platformtools.get_played_time(item_nfo)
|
||||
|
||||
else: played_time = 0
|
||||
|
||||
return played_time
|
||||
|
||||
import xbmcgui, xbmcplugin, xbmc
|
||||
from time import sleep
|
||||
|
||||
if not item.autoplay and not item.next_ep:
|
||||
platformtools.fakeVideo()
|
||||
item.action = item.next_action if item.next_action else 'findvideos'
|
||||
logger.debug('Executing channel', item.channel, 'method', item.action)
|
||||
if item.action == 'findvideos':
|
||||
item.fakevideo = True
|
||||
return run(item)
|
||||
|
||||
|
||||
itemlist=[]
|
||||
item.fromLibrary = True
|
||||
item.window = True
|
||||
logger.debug()
|
||||
|
||||
# Modify the action (currently the video library needs "findvideos" since this is where the sources are searched
|
||||
item.action = item.next_action if item.next_action else "findvideos"
|
||||
|
||||
if item.contentType == 'movie' or item.contentType != 'movie' and config.get_setting('next_ep') < 3:
|
||||
window_type = config.get_setting("window_type", "videolibrary")
|
||||
else: window_type = 1
|
||||
|
||||
# and launch kodi again
|
||||
if (xbmc.getCondVisibility('Window.IsMedia') and not window_type == 1) or item.action != 'findvideos':
|
||||
xbmc.executebuiltin("Container.Update(" + sys.argv[0] + "?" + item.tourl() + ")")
|
||||
|
||||
else:
|
||||
# Pop-up window
|
||||
from specials import videolibrary
|
||||
from core.channeltools import get_channel_parameters
|
||||
p_dialog = platformtools.dialog_progress_bg(config.get_localized_string(20000), config.get_localized_string(60683))
|
||||
p_dialog.update(0, '')
|
||||
item.play_from = 'window'
|
||||
itemlist = videolibrary.findvideos(item)
|
||||
p_dialog.update(100, ''); sleep(0.5); p_dialog.close()
|
||||
played = False
|
||||
|
||||
# The number of links to show is limited
|
||||
if config.get_setting("max_links", "videolibrary") != 0: itemlist = limit_itemlist(itemlist)
|
||||
# The list of links is slightly "cleaned"
|
||||
if config.get_setting("replace_VD", "videolibrary") == 1: itemlist = reorder_itemlist(itemlist)
|
||||
|
||||
if len(itemlist) > 0:
|
||||
reopen = False
|
||||
|
||||
while not xbmc.Monitor().abortRequested():
|
||||
played = True
|
||||
# if config.get_setting('next_ep') == 3 and xbmc.Player().playnext:
|
||||
# return
|
||||
# The user chooses the mirror
|
||||
if not platformtools.is_playing():
|
||||
if config.get_setting('next_ep') == 3:
|
||||
xbmc.sleep(500)
|
||||
if platformtools.is_playing():
|
||||
return
|
||||
if config.get_setting('autoplay') or reopen:
|
||||
played_time = get_played_time(item)
|
||||
if not played_time and played:
|
||||
return
|
||||
|
||||
options = []
|
||||
selection_implementation = 0
|
||||
for item in itemlist:
|
||||
item.thumbnail = config.get_online_server_thumb(item.server)
|
||||
quality = '[B][' + item.quality + '][/B]' if item.quality else ''
|
||||
if item.server:
|
||||
path = filetools.join(config.get_runtime_path(), 'servers', item.server.lower() + '.json')
|
||||
name = jsontools.load(open(path, "rb").read())['name']
|
||||
if name.startswith('@'): name = config.get_localized_string(int(name.replace('@','')))
|
||||
logger.debug(item)
|
||||
it = xbmcgui.ListItem('\n[B]%s[/B] %s - %s [%s]' % (name, quality, item.contentTitle, get_channel_parameters(item.contentChannel)['title']))
|
||||
it.setArt({'thumb':item.thumbnail})
|
||||
options.append(it)
|
||||
else:
|
||||
selection_implementation += 1
|
||||
# The selection window opens
|
||||
if (item.contentSerieName and item.contentSeason and item.contentEpisodeNumber): head = ("%s - %sx%s | %s" % (item.contentSerieName, item.contentSeason, item.contentEpisodeNumber, config.get_localized_string(30163)))
|
||||
else: head = config.get_localized_string(30163)
|
||||
selection = platformtools.dialog_select(head, options, preselect= -1, useDetails=True)
|
||||
if selection == -1:
|
||||
return
|
||||
else:
|
||||
item = videolibrary.play(itemlist[selection + selection_implementation])[0]
|
||||
platformtools.play_video(item)
|
||||
reopen = True
|
||||
if item.server == 'torrent': return
|
||||
# if (platformtools.is_playing() and item.action) or item.server == 'torrent' or config.get_setting('autoplay'): break
|
||||
|
||||
|
||||
@@ -627,7 +627,7 @@ def set_context_commands(item, item_url, parent_item, **kwargs):
|
||||
# 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), "RunPlugin(%s?%s&%s)" % (sys.argv[0], item_url, urllib.urlencode({'channel': "kodfavorites", 'action': "addFavourite", 'from_channel': item.channel, 'from_action': item.action}))))
|
||||
# Add to kodfavoritos
|
||||
# Add to kodfavoritos
|
||||
if parent_item.channel == 'globalsearch':
|
||||
context_commands.append( (config.get_localized_string(30155), "RunPlugin(%s?%s&%s)" % (sys.argv[0], item_url, urllib.urlencode({'channel': "favorites", 'action': "addFavourite", 'from_channel': item.channel, 'from_action': item.action}))))
|
||||
# Search in other channels
|
||||
@@ -1386,7 +1386,7 @@ def set_player(item, xlistitem, mediaurl, view, strm):
|
||||
logger.info("mediaurl=" + mediaurl)
|
||||
|
||||
if player_mode in [0,1]:
|
||||
prevent_busy(item)
|
||||
prevent_busy()
|
||||
if player_mode in [1]:
|
||||
item.played_time = resume_playback(get_played_time(item))
|
||||
|
||||
@@ -1490,7 +1490,7 @@ def play_torrent(item, xlistitem, mediaurl):
|
||||
selection = 0
|
||||
|
||||
if selection >= 0:
|
||||
prevent_busy(item)
|
||||
prevent_busy()
|
||||
|
||||
mediaurl = urllib.quote_plus(item.url)
|
||||
torr_client = torrent_options[selection][0]
|
||||
@@ -1684,10 +1684,137 @@ def prevent_busy(item=None):
|
||||
xbmc.executebuiltin('Dialog.Close(all,true)')
|
||||
|
||||
|
||||
def fakeVideo():
|
||||
xbmcplugin.setResolvedUrl(int(sys.argv[1]), True,
|
||||
xbmcgui.ListItem(path=os.path.join(config.get_runtime_path(), "resources", "kod.mp4")))
|
||||
sleep = 200
|
||||
while not is_playing():
|
||||
xbmc.sleep(sleep)
|
||||
xbmc.Player().stop()
|
||||
def fakeVideo(sleep = False):
|
||||
mediaurl = os.path.join(config.get_runtime_path(), "resources", "kod.mp4")
|
||||
xbmc.executebuiltin("PlayMedia(" + mediaurl + ")")
|
||||
if sleep:
|
||||
while is_playing():
|
||||
xbmc.sleep(sleep)
|
||||
xbmc.Player().stop()
|
||||
|
||||
|
||||
def channelImport(channelId):
|
||||
from core import filetools
|
||||
ch = ''
|
||||
path = filetools.join(config.get_runtime_path(), '{}', channelId + ".py")
|
||||
if filetools.exists(path.format('channels')): ch = 'channels.{}'.format(channelId)
|
||||
elif filetools.exists(path.format('specials')): ch = 'specials.{}'.format(channelId)
|
||||
elif filetools.exists(path.format('platformcode')): ch = 'platformcode.{}'.format(channelId)
|
||||
elif filetools.exists(path.format('core')): ch = 'core.{}'.format(channelId)
|
||||
if ch:
|
||||
channel = __import__(ch, None, None, [ch])
|
||||
else:
|
||||
logger.info('Channel {} not Exist'.format(channelId))
|
||||
channel = None
|
||||
return channel
|
||||
|
||||
def serverWindow(item, itemlist):
|
||||
LEFT = 1
|
||||
RIGHT = 2
|
||||
UP = 3
|
||||
DOWN = 4
|
||||
ENTER = 7
|
||||
EXIT = 10
|
||||
BACKSPACE = 92
|
||||
|
||||
class ServerWindow(xbmcgui.WindowXMLDialog):
|
||||
def start(self, item, itemlist):
|
||||
self.itemlist = itemlist
|
||||
self.item = item
|
||||
self.servers = []
|
||||
items = []
|
||||
self.selection = -1
|
||||
self.actions = {}
|
||||
for videoitem in self.itemlist:
|
||||
videoitem.thumbnail = config.get_online_server_thumb(videoitem.server)
|
||||
quality = ' [' + videoitem.quality + ']' if videoitem.quality else ''
|
||||
if videoitem.server:
|
||||
color = scrapertools.find_single_match(videoitem.alive, r'(FF[^\]]+)')
|
||||
it = xbmcgui.ListItem('{}{}'.format(videoitem.serverName, quality))
|
||||
|
||||
# format Title
|
||||
if videoitem.contentSeason and videoitem.contentEpisodeNumber:
|
||||
title = '{}x{:02d}. {}'.format(videoitem.contentSeason, videoitem.contentEpisodeNumber, videoitem.contentTitle)
|
||||
elif videoitem.contentEpisodeNumber:
|
||||
title = '{:02d}. {}'.format(videoitem.contentEpisodeNumber, videoitem.contentTitle)
|
||||
else:
|
||||
title = videoitem.title
|
||||
|
||||
it.setProperties({'name': title, 'channel': videoitem.ch_name, 'color': color if color else 'FF0082C2'})
|
||||
it.setArt({'poster':videoitem.contentThumbnail, 'thumb':videoitem.thumbnail, 'fanart':videoitem.contentFanart})
|
||||
self.servers.append(it)
|
||||
items.append(videoitem)
|
||||
else:
|
||||
it = xbmcgui.ListItem(videoitem.title)
|
||||
if 'library' in videoitem.action:
|
||||
self.actions['videolibrary'] = videoitem
|
||||
if 'download' in videoitem.action:
|
||||
self.actions['download'] = videoitem
|
||||
|
||||
self.itemlist = items
|
||||
self.doModal()
|
||||
return self.selection
|
||||
|
||||
def onInit(self):
|
||||
self.SERVERS = self.getControl(100)
|
||||
self.VIDEOLIBRARY = self.getControl(102)
|
||||
self.DOWNLOAD = self.getControl(103)
|
||||
if 'videolibrary' not in self.actions.keys():
|
||||
self.VIDEOLIBRARY.setVisible(False)
|
||||
if 'download' not in self.actions.keys():
|
||||
self.DOWNLOAD.setVisible(False)
|
||||
self.SERVERS.reset()
|
||||
self.SERVERS.addItems(self.servers)
|
||||
self.setFocusId(100)
|
||||
# from core.support import dbg;dbg()
|
||||
|
||||
def onAction(self, action):
|
||||
action = action.getId()
|
||||
focus = self.getFocusId()
|
||||
if action in [UP, DOWN, LEFT, RIGHT] and focus not in [100, 101, 102, 103]:
|
||||
self.setFocusId(100)
|
||||
elif action in [EXIT, BACKSPACE]:
|
||||
self.close()
|
||||
|
||||
def onClick(self, control):
|
||||
if control == 100:
|
||||
self.selection = self.itemlist[self.SERVERS.getSelectedPosition()].clone(window=True)
|
||||
self.close()
|
||||
elif control in [101]:
|
||||
self.close()
|
||||
elif control in [102]:
|
||||
self.run(self.actions['videolibrary'])
|
||||
elif control in [103]:
|
||||
self.run(self.actions['download'])
|
||||
|
||||
def run(self, action):
|
||||
from platformcode.launcher import run
|
||||
run(action)
|
||||
|
||||
|
||||
|
||||
if itemlist:
|
||||
reopen = False
|
||||
while not xbmc.Monitor().abortRequested():
|
||||
played = True
|
||||
if not is_playing():
|
||||
if config.get_setting('next_ep') == 3:
|
||||
xbmc.sleep(500)
|
||||
if is_playing():
|
||||
return
|
||||
if config.get_setting('autoplay') or reopen:
|
||||
played_time = get_played_time(item)
|
||||
if not played_time and played:
|
||||
return
|
||||
|
||||
selection = ServerWindow('Servers.xml', config.get_runtime_path()).start(item, itemlist)
|
||||
|
||||
if selection == -1:
|
||||
if item.fakevideo:
|
||||
return fakeVideo()
|
||||
else: return
|
||||
|
||||
else:
|
||||
from platformcode.launcher import run
|
||||
run(selection)
|
||||
reopen = True
|
||||
|
||||
@@ -97,10 +97,10 @@ def mark_auto_as_watched(item):
|
||||
while platformtools.is_playing():
|
||||
xbmc.sleep(100)
|
||||
|
||||
if not show_server and item.play_from != 'window' and not item.no_return:
|
||||
xbmc.sleep(700)
|
||||
xbmc.executebuiltin('Action(ParentDir)')
|
||||
xbmc.sleep(500)
|
||||
# if not show_server and item.play_from != 'window' and not item.no_return:
|
||||
# xbmc.sleep(200)
|
||||
# xbmc.executebuiltin('Action(close)')
|
||||
# xbmc.sleep(500)
|
||||
|
||||
if next_episode and next_episode.next_ep and config.get_setting('next_ep') < 3:
|
||||
from platformcode.launcher import run
|
||||
@@ -109,6 +109,7 @@ def mark_auto_as_watched(item):
|
||||
# db need to be closed when not used, it will cause freezes
|
||||
from core import db
|
||||
db.close()
|
||||
# from core.support import dbg;dbg()
|
||||
|
||||
# If it is configured to mark as seen
|
||||
if config.get_setting("mark_as_watched", "videolibrary"):
|
||||
|
||||
Reference in New Issue
Block a user