Fix e migliorie Videoteca
This commit is contained in:
+103
-83
@@ -3,12 +3,13 @@
|
||||
# XBMC Launcher (xbmc / kodi)
|
||||
# ------------------------------------------------------------
|
||||
|
||||
from specials import videolibrary
|
||||
import sys, os
|
||||
PY3 = False
|
||||
if sys.version_info[0] >= 3:PY3 = True; unicode = str; unichr = chr; long = int
|
||||
|
||||
from core.item import Item
|
||||
from core import filetools, jsontools
|
||||
from core import filetools, jsontools, videolibrarydb
|
||||
from platformcode import config, logger, platformtools
|
||||
from platformcode.logger import WebErrorException
|
||||
temp_search_file = config.get_temp_file('temp-search')
|
||||
@@ -429,94 +430,113 @@ def play_from_library(item):
|
||||
@param item: item with information
|
||||
"""
|
||||
|
||||
def get_played_time(item):
|
||||
if item.contentType == 'movie': nfo_path = item.nfo
|
||||
else: nfo_path = item.strm_path.replace('strm','nfo')
|
||||
if nfo_path and filetools.isfile(nfo_path):
|
||||
from core import videolibrarytools
|
||||
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
|
||||
# def get_played_time(item):
|
||||
# if item.contentType == 'movie': nfo_path = item.nfo
|
||||
# else: nfo_path = item.strm_path.replace('strm','nfo')
|
||||
# if nfo_path and filetools.isfile(nfo_path):
|
||||
# from core import videolibrarytools
|
||||
# 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
|
||||
|
||||
# from time import sleep
|
||||
|
||||
# logger.debug("item: \n" + item.tostring('\n'))
|
||||
platformtools.prevent_busy(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 = "findvideos"
|
||||
|
||||
window_type = config.get_setting("window_type", "videolibrary") if config.get_setting('next_ep') < 3 and item.contentType != 'movie' else 1
|
||||
|
||||
# and launch kodi again
|
||||
if xbmc.getCondVisibility('Window.IsMedia') and not window_type == 1:
|
||||
xbmc.executebuiltin("Container.Update(" + sys.argv[0] + "?" + item.tourl() + ")")
|
||||
# from core.support import dbg; dbg()
|
||||
import xbmc
|
||||
item.window_type = config.get_setting("window_type", "videolibrary") if config.get_setting('next_ep') < 3 and item.contentType != 'movie' else 1
|
||||
|
||||
if xbmc.getCondVisibility('Window.IsMedia') and not item.window_type == 1:
|
||||
import xbmcgui, xbmcplugin
|
||||
xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, xbmcgui.ListItem(path=os.path.join(config.get_runtime_path(), "resources", "kod.mp4")))
|
||||
xbmc.Player().stop()
|
||||
if item.contentType == 'episode':
|
||||
it = videolibrarydb.videolibrarydb[item.contentType][item.videolibrary_id]['{}x{:02d}'.format(item.infoLabels['season'], item.infoLabels['episode'])]
|
||||
else:
|
||||
it = videolibrarydb.videolibrarydb[item.contentType][item.videolibrary_id]['item']
|
||||
xbmc.executebuiltin("Container.Update(" + sys.argv[0] + "?" + it.tourl() + ")")
|
||||
videolibrarydb.videolibrarydb.close()
|
||||
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
|
||||
return videolibrary.findvideos(item)
|
||||
# else:
|
||||
# xbmc.executebuiltin('ActivateWindow(10025,' + sys.argv[0] + "?" + item.tourl() + ")")
|
||||
# itemlist = videolibrary.findvideos(it)
|
||||
# platformtools.render_items(itemlist, item)
|
||||
|
||||
# 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)
|
||||
# from core.support import dbg;dbg()
|
||||
if len(itemlist) > 0:
|
||||
reopen = False
|
||||
# from core.support import dbg;dbg()
|
||||
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
|
||||
# itemlist=[]
|
||||
# item.fromLibrary = True
|
||||
# item.window = True
|
||||
# logger.debug()
|
||||
|
||||
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('@','')))
|
||||
it = xbmcgui.ListItem('\n[B]%s[/B] %s - %s [%s]' % (name, quality, item.contentTitle, get_channel_parameters(item.channel).get('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
|
||||
# # Modify the action (currently the video library needs "findvideos" since this is where the sources are searched
|
||||
# item.action = "findvideos"
|
||||
|
||||
# window_type = config.get_setting("window_type", "videolibrary") if config.get_setting('next_ep') < 3 and item.contentType != 'movie' else 1
|
||||
|
||||
# # and launch kodi again
|
||||
# if xbmc.getCondVisibility('Window.IsMedia') and not window_type == 1:
|
||||
# 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)
|
||||
# # from core.support import dbg;dbg()
|
||||
# if len(itemlist) > 0:
|
||||
# reopen = False
|
||||
# # from core.support import dbg;dbg()
|
||||
# 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('@','')))
|
||||
# it = xbmcgui.ListItem('\n[B]%s[/B] %s - %s [%s]' % (name, quality, item.contentTitle, get_channel_parameters(item.channel).get('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 (platformtools.is_playing() and item.action) or item.server == 'torrent' or config.get_setting('autoplay'): break
|
||||
|
||||
|
||||
Reference in New Issue
Block a user