Fix e migliorie Videoteca
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -284,7 +284,8 @@ def itemlist_refresh(offset=0):
|
||||
ctl = win.getControl(cid)
|
||||
pos = Item().fromurl(xbmc.getInfoLabel('ListItem.FileNameAndPath')).itemlistPosition + offset
|
||||
|
||||
xbmc.executebuiltin("Container.Refresh")
|
||||
# xbmc.executebuiltin("Container.Refresh")
|
||||
xbmc.executebuiltin('ReloadSkin()')
|
||||
|
||||
while xbmcgui.getCurrentWindowDialogId() != 10138:
|
||||
pass
|
||||
@@ -684,7 +685,7 @@ def play_video(item, strm=False, force_direct=False, autoplay=False):
|
||||
|
||||
def play():
|
||||
if item.channel == 'downloads':
|
||||
logger.debug("Play local video: %s [%s]" % (item.title, item.url))
|
||||
logger.debug("Play local video: %s [%s]" % (item.fulltitle, item.url))
|
||||
xlistitem = xbmcgui.ListItem(path=item.url)
|
||||
xlistitem.setArt({"thumb": item.thumbnail})
|
||||
set_infolabels(xlistitem, item, True)
|
||||
@@ -720,7 +721,7 @@ def play_video(item, strm=False, force_direct=False, autoplay=False):
|
||||
if not mediaurl: return
|
||||
|
||||
# video information is obtained.
|
||||
xlistitem = xbmcgui.ListItem(path=item.url)
|
||||
xlistitem = xbmcgui.ListItem(item.title, path=item.url)
|
||||
xlistitem.setArt({"thumb": item.contentThumbnail if item.contentThumbnail else item.thumbnail})
|
||||
set_infolabels(xlistitem, item, True)
|
||||
|
||||
@@ -1084,6 +1085,7 @@ def get_video_seleccionado(item, seleccion, video_urls, autoplay=False):
|
||||
|
||||
def set_player(item, xlistitem, mediaurl, view, strm):
|
||||
logger.debug()
|
||||
# from core.support import dbg;dbg()
|
||||
item.options = {'strm':False}
|
||||
# logger.debug("item:\n" + item.tostring('\n'))
|
||||
|
||||
@@ -1538,11 +1540,6 @@ def set_played_time(item):
|
||||
def prevent_busy(item):
|
||||
logger.debug()
|
||||
if not item.autoplay and not item.window:
|
||||
if item.globalsearch: xbmc.Player().play(os.path.join(config.get_runtime_path(), "resources", "kod.mp4"))
|
||||
else: xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, xbmcgui.ListItem(path=os.path.join(config.get_runtime_path(), "resources", "kod.mp4")))
|
||||
xbmc.Player().play(os.path.join(config.get_runtime_path(), "resources", "kod.mp4"))
|
||||
xbmc.sleep(200)
|
||||
xbmc.Player().stop()
|
||||
# xbmc.executebuiltin('Action(Stop)')
|
||||
# xbmc.sleep(500)
|
||||
# xbmc.Player().stop()
|
||||
# xbmc.sleep(500)
|
||||
xbmc.Player().stop()
|
||||
@@ -31,7 +31,6 @@ def mark_auto_as_watched(item):
|
||||
while not platformtools.is_playing() and time.time() < time_limit:
|
||||
time.sleep(1)
|
||||
|
||||
|
||||
marked = False
|
||||
sync = False
|
||||
next_episode = None
|
||||
@@ -100,7 +99,7 @@ def mark_auto_as_watched(item):
|
||||
xbmc.sleep(700)
|
||||
xbmc.executebuiltin('Action(ParentDir)')
|
||||
# xbmc.sleep(500)
|
||||
|
||||
|
||||
if marked:
|
||||
from specials import videolibrary
|
||||
videolibrary.mark_content_as_watched(item)
|
||||
@@ -287,7 +286,7 @@ def mark_content_as_watched_on_kodi(item, value=1):
|
||||
conn.commit()
|
||||
conn.close()
|
||||
|
||||
platformtools.itemlist_refresh()
|
||||
# platformtools.itemlist_refresh()
|
||||
|
||||
|
||||
def set_watched_on_kod(data):
|
||||
|
||||
Reference in New Issue
Block a user