- Fix e Migliorie Videoteca
- Server in finestra come default (per canali e videoteca)
This commit is contained in:
@@ -267,31 +267,77 @@ class addVideo(object):
|
||||
|
||||
def set_tvshow(self):
|
||||
posters, fanarts = get_images(self.item)
|
||||
sql = 'INSERT OR IGNORE INTO tvshow (idMovie, idFile, c00, c01, c03, c05, c06, c08, c09, c11, c12, c14, c15, c16, c18, c19, c20, c21, c22, c23, idSet, premiered)'
|
||||
sql += 'VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'
|
||||
params = (self.VideoId, # idMovie
|
||||
self.idFile, # idFile
|
||||
sql = 'INSERT OR IGNORE INTO tvshow (idShow, c00, c01, c02, c04, c05, c06, c08, c09, c11, c12, c13, c14, c16)'
|
||||
sql += 'VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'
|
||||
params = (self.VideoId, # idShow
|
||||
self.item.title, # c00
|
||||
self.item.plot.replace('"', "'"), # c01
|
||||
self.info.get('tagline'), # c03
|
||||
self.rating_id, # c05
|
||||
self.info.get('writer','').replace(',', ' /'), # c06
|
||||
posters, # c08
|
||||
self.uniqueID, #c09
|
||||
self.info.get('duration', 0), # c11
|
||||
self.info.get('mpaa'), # c12
|
||||
self.info.get('genre','').replace(',', ' /') if self.info.get('genre') else None, # c14
|
||||
self.info.get('director','').replace(',', ' /') if self.info.get('director') else None, # c15
|
||||
self.info.get('originaltitle'), # c16
|
||||
self.info.get('studio'), # c18
|
||||
self.info.get('trailer'), # c19
|
||||
fanarts, # c20
|
||||
self.info.get('country','').replace(',', ' /') if self.info.get('country') else None, # c21
|
||||
self.path, # c22
|
||||
self.idPath, # c23
|
||||
self.idSet, # idSet
|
||||
self.info.get('premiered')) # premiered
|
||||
nun_records, records = execute_sql_kodi(sql, params, conn)
|
||||
self.item.plot, # c01
|
||||
self.info.get('status'), # c02
|
||||
self.rating_id, # c04
|
||||
self.info.get('premiered'), # c05
|
||||
posters, # c06
|
||||
self.info.get('genre','').replace(',', ' /') if self.info.get('genre') else None, # c08
|
||||
self.info.get('originaltitle'), # c09
|
||||
fanarts, # c11
|
||||
self.uniqueID, #c12
|
||||
self.info.get('mpaa'), # c13
|
||||
self.info.get('studio'), # c14
|
||||
self.info.get('trailer'), # c16
|
||||
)
|
||||
|
||||
if self.item.thumbnail:
|
||||
self.art.append({'media_id':self.VideoId, 'media_type': 'movie', 'type':'poster', 'url':self.item.thumbnail})
|
||||
if self.item.fanart:
|
||||
self.art.append({'media_id':self.VideoId, 'media_type': 'movie', 'type':'fanart', 'url':self.item.fanart})
|
||||
if self.info.get('landscape'):
|
||||
self.art.append({'media_id':self.VideoId, 'media_type': 'movie', 'type':'landscape', 'url':self.info.get('landscape')})
|
||||
if self.info.get('banner'):
|
||||
self.art.append({'media_id':self.VideoId, 'media_type': 'movie', 'type':'banner', 'url':self.info.get('banner')})
|
||||
if self.info.get('clearlogo'):
|
||||
self.art.append({'media_id':self.VideoId, 'media_type': 'movie', 'type':'clearlogo', 'url':self.info.get('clearlogo')})
|
||||
if self.info.get('clearart'):
|
||||
self.art.append({'media_id':self.VideoId, 'media_type': 'movie', 'type':'clearart', 'url':self.info.get('clearart')})
|
||||
if self.info.get('disc'):
|
||||
self.art.append({'media_id':self.VideoId, 'media_type': 'movie', 'type':'disc', 'url':self.info.get('disc')})
|
||||
|
||||
self.sql_actions.append([sql, params])
|
||||
|
||||
def set_season(self):
|
||||
posters, fanarts = get_images(self.item)
|
||||
sql = 'INSERT OR IGNORE INTO tvshow (idShow, c00, c01, c02, c04, c05, c06, c08, c09, c11, c12, c13, c14, c16)'
|
||||
sql += 'VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'
|
||||
params = (self.VideoId, # idShow
|
||||
self.item.title, # c00
|
||||
self.item.plot, # c01
|
||||
self.info.get('status'), # c02
|
||||
self.rating_id, # c04
|
||||
self.info.get('premiered'), # c05
|
||||
posters, # c06
|
||||
self.info.get('genre','').replace(',', ' /') if self.info.get('genre') else None, # c08
|
||||
self.info.get('originaltitle'), # c09
|
||||
fanarts, # c11
|
||||
self.uniqueID, #c12
|
||||
self.info.get('mpaa'), # c13
|
||||
self.info.get('studio'), # c14
|
||||
self.info.get('trailer'), # c16
|
||||
)
|
||||
|
||||
if self.item.thumbnail:
|
||||
self.art.append({'media_id':self.VideoId, 'media_type': 'movie', 'type':'poster', 'url':self.item.thumbnail})
|
||||
if self.item.fanart:
|
||||
self.art.append({'media_id':self.VideoId, 'media_type': 'movie', 'type':'fanart', 'url':self.item.fanart})
|
||||
if self.info.get('landscape'):
|
||||
self.art.append({'media_id':self.VideoId, 'media_type': 'movie', 'type':'landscape', 'url':self.info.get('landscape')})
|
||||
if self.info.get('banner'):
|
||||
self.art.append({'media_id':self.VideoId, 'media_type': 'movie', 'type':'banner', 'url':self.info.get('banner')})
|
||||
if self.info.get('clearlogo'):
|
||||
self.art.append({'media_id':self.VideoId, 'media_type': 'movie', 'type':'clearlogo', 'url':self.info.get('clearlogo')})
|
||||
if self.info.get('clearart'):
|
||||
self.art.append({'media_id':self.VideoId, 'media_type': 'movie', 'type':'clearart', 'url':self.info.get('clearart')})
|
||||
if self.info.get('disc'):
|
||||
self.art.append({'media_id':self.VideoId, 'media_type': 'movie', 'type':'disc', 'url':self.info.get('disc')})
|
||||
|
||||
self.sql_actions.append([sql, params])
|
||||
|
||||
def set_art(self):
|
||||
params = []
|
||||
|
||||
@@ -226,7 +226,10 @@ def run(item=None):
|
||||
if config.get_setting("max_links", "videolibrary") != 0:
|
||||
itemlist = limit_itemlist(itemlist)
|
||||
|
||||
platformtools.render_items(itemlist, item)
|
||||
if item.window:
|
||||
platformtools.serverwindow(item, itemlist)
|
||||
else:
|
||||
platformtools.render_items(itemlist, item)
|
||||
|
||||
# Special action for adding a movie to the library
|
||||
elif item.action == "add_movie_to_library":
|
||||
@@ -447,9 +450,9 @@ def play_from_library(item):
|
||||
# logger.debug("item: \n" + item.tostring('\n'))
|
||||
# from core.support import dbg; dbg()
|
||||
import xbmc, xbmcgui, xbmcplugin
|
||||
item.window_type = config.get_setting("window_type", "videolibrary") if config.get_setting('next_ep') < 3 and item.contentType != 'movie' else 1
|
||||
xbmc.Player().stop()
|
||||
item.window_type = config.get_setting("window_type") if config.get_setting('next_ep') < 3 and item.contentType != 'movie' else 0
|
||||
xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, xbmcgui.ListItem(path=os.path.join(config.get_runtime_path(), "resources", "kod.mp4")))
|
||||
xbmc.Player().stop()
|
||||
if xbmc.getCondVisibility('Window.IsMedia') and not item.window_type == 1:
|
||||
if item.contentType == 'episode':
|
||||
it = videolibrarydb.videolibrarydb[item.contentType][item.videolibrary_id]['{}x{:02d}'.format(item.infoLabels['season'], item.infoLabels['episode'])]
|
||||
|
||||
@@ -279,20 +279,24 @@ def dialog_select_group(heading, _list, preselect=0):
|
||||
|
||||
|
||||
def itemlist_refresh(offset=0):
|
||||
win = xbmcgui.Window(xbmcgui.getCurrentWindowId())
|
||||
cid = win.getFocusId()
|
||||
ctl = win.getControl(cid)
|
||||
pos = Item().fromurl(xbmc.getInfoLabel('ListItem.FileNameAndPath')).itemlistPosition + offset
|
||||
try:
|
||||
_id = xbmcgui.getCurrentWindowId()
|
||||
win = xbmcgui.Window(_id)
|
||||
cid = win.getFocusId()
|
||||
ctl = win.getControl(cid)
|
||||
pos = Item().fromurl(xbmc.getInfoLabel('ListItem.FileNameAndPath')).itemlistPosition + offset
|
||||
logger.debug('ID:', _id, 'POSITION:', pos)
|
||||
# xbmc.executebuiltin("Container.Refresh")
|
||||
xbmc.executebuiltin('ReloadSkin()')
|
||||
|
||||
# xbmc.executebuiltin("Container.Refresh")
|
||||
xbmc.executebuiltin('ReloadSkin()')
|
||||
while xbmcgui.getCurrentWindowDialogId() != 10138:
|
||||
pass
|
||||
while xbmcgui.getCurrentWindowDialogId() == 10138:
|
||||
pass
|
||||
|
||||
while xbmcgui.getCurrentWindowDialogId() != 10138:
|
||||
pass
|
||||
while xbmcgui.getCurrentWindowDialogId() == 10138:
|
||||
pass
|
||||
|
||||
ctl.selectItem(pos)
|
||||
ctl.selectItem(pos)
|
||||
except:
|
||||
xbmc.executebuiltin('ReloadSkin()')
|
||||
|
||||
|
||||
def itemlist_update(item, replace=False):
|
||||
@@ -382,17 +386,22 @@ def render_items(itemlist, parent_item):
|
||||
listitem.addContextMenuItems(context_commands)
|
||||
return item, item_url, listitem
|
||||
|
||||
# dirItems.append(('%s?%s' % (sys.argv[0], item_url), listitem, item.folder))
|
||||
|
||||
r_list = []
|
||||
with futures.ThreadPoolExecutor() as executor:
|
||||
searchList = [executor.submit(set_item, i, item) for i, item in enumerate(itemlist)]
|
||||
for res in futures.as_completed(searchList):
|
||||
r_list.append(res.result())
|
||||
r_list.sort(key=lambda it: it[0].itemlistPosition)
|
||||
|
||||
for item, item_url, listitem in r_list:
|
||||
dirItems.append(('%s?%s' % (sys.argv[0], item_url), listitem, item.folder))
|
||||
dirItems.append(('%s?%s' % (sys.argv[0], item_url), listitem, item.folder, len(r_list)))
|
||||
xbmcplugin.addDirectoryItems(_handle, dirItems)
|
||||
|
||||
if parent_item.sorted:
|
||||
if parent_item.sorted == 'year': xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_DATE)
|
||||
elif parent_item.sorted == 'name': xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_TITLE_IGNORE_THE)
|
||||
|
||||
if parent_item.list_type == '':
|
||||
breadcrumb = parent_item.category.capitalize()
|
||||
else:
|
||||
@@ -409,6 +418,7 @@ def render_items(itemlist, parent_item):
|
||||
set_view_mode(itemlist[0], parent_item)
|
||||
|
||||
xbmcplugin.endOfDirectory(_handle)
|
||||
|
||||
logger.debug('END render_items')
|
||||
|
||||
|
||||
@@ -1149,11 +1159,11 @@ def set_player(item, xlistitem, mediaurl, view, strm):
|
||||
xbmc_videolibrary.mark_auto_as_watched(item)
|
||||
|
||||
# for cases where the audio playback window appears in place of the video one
|
||||
if item.focusOnVideoPlayer:
|
||||
while is_playing() and xbmcgui.getCurrentWindowId() != 12006:
|
||||
continue
|
||||
xbmc.sleep(500)
|
||||
xbmcgui.Window(12005).show()
|
||||
# if item.focusOnVideoPlayer:
|
||||
# while is_playing() and xbmcgui.getCurrentWindowId() != 12006:
|
||||
# continue
|
||||
# xbmc.sleep(500)
|
||||
# xbmcgui.Window(12005).show()
|
||||
|
||||
|
||||
def add_next_to_playlist(item):
|
||||
@@ -1541,4 +1551,63 @@ def prevent_busy(item):
|
||||
if not item.autoplay and not item.window:
|
||||
xbmc.Player().play(os.path.join(config.get_runtime_path(), "resources", "kod.mp4"))
|
||||
xbmc.sleep(200)
|
||||
xbmc.Player().stop()
|
||||
xbmc.Player().stop()
|
||||
|
||||
|
||||
def serverwindow(item, itemlist):
|
||||
from core import filetools, jsontools
|
||||
class ServerWindow(xbmcgui.WindowXMLDialog):
|
||||
def start(self, item, itemlist):
|
||||
self.itemlist = itemlist
|
||||
self.item = item
|
||||
self.servers = []
|
||||
self.selection = -1
|
||||
|
||||
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[^\]]+)')
|
||||
path = filetools.join(config.get_runtime_path(), 'servers', videoitem.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('{}{}'.format(name, quality))
|
||||
it.setProperties({'name': self.item.title, 'channel': videoitem.ch_name, 'color': color if color else 'FF0082C2'})
|
||||
it.setArt({'poster':self.item.contentThumbnail, 'thumb':videoitem.thumbnail, 'fanart':item.fanart})
|
||||
self.servers.append(it)
|
||||
self.doModal()
|
||||
return self.selection
|
||||
|
||||
def onInit(self):
|
||||
self.SERVERS = self.getControl(100)
|
||||
self.SERVERS.reset()
|
||||
self.SERVERS.addItems(self.servers)
|
||||
self.setFocusId(100)
|
||||
|
||||
def onClick(self, control_id):
|
||||
if control_id == 100:
|
||||
self.selection = self.itemlist[self.SERVERS.getSelectedPosition()].clone(window=True)
|
||||
self.close()
|
||||
|
||||
reopen = False
|
||||
if len(itemlist) > 0:
|
||||
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:
|
||||
return
|
||||
else:
|
||||
from platformcode.launcher import run
|
||||
run(selection)
|
||||
reopen = True
|
||||
@@ -27,7 +27,7 @@ def mark_auto_as_watched(item):
|
||||
actual_time = 0
|
||||
total_time = 0
|
||||
|
||||
time_limit = time.time() + 30
|
||||
time_limit = time.time() + 10
|
||||
while not platformtools.is_playing() and time.time() < time_limit:
|
||||
time.sleep(1)
|
||||
|
||||
@@ -38,6 +38,7 @@ def mark_auto_as_watched(item):
|
||||
|
||||
percentage = float(config.get_setting("watched_setting")) / 100
|
||||
time_from_end = config.get_setting('next_ep_seconds')
|
||||
|
||||
if item.contentType != 'movie' and 0 < config.get_setting('next_ep') < 3:
|
||||
next_dialogs = ['NextDialog.xml', 'NextDialogExtended.xml', 'NextDialogCompact.xml']
|
||||
next_ep_type = config.get_setting('next_ep_type')
|
||||
@@ -46,7 +47,8 @@ def mark_auto_as_watched(item):
|
||||
except: next_episode = False
|
||||
logger.debug(next_episode)
|
||||
|
||||
while platformtools.is_playing():
|
||||
while not xbmc.Monitor().abortRequested():
|
||||
if not platformtools.is_playing(): break
|
||||
try: actual_time = xbmc.Player().getTime()
|
||||
except: pass
|
||||
try: total_time = xbmc.Player().getTotalTime()
|
||||
@@ -95,12 +97,9 @@ def mark_auto_as_watched(item):
|
||||
while platformtools.is_playing():
|
||||
xbmc.sleep(100)
|
||||
|
||||
if not show_server and not item.window and not item.no_return:
|
||||
if not show_server and not item.no_return and not item.window:
|
||||
xbmc.sleep(700)
|
||||
xbmc.executebuiltin('Action(ParentDir)')
|
||||
else:
|
||||
videolibrary.serverwindow.close()
|
||||
|
||||
|
||||
if marked:
|
||||
from specials import videolibrary
|
||||
@@ -264,14 +263,16 @@ def mark_content_as_watched_on_kodi(item, value=1):
|
||||
@param value: > 0 for seen, 0 for not seen
|
||||
"""
|
||||
logger.debug()
|
||||
# from core.support import dbg;dbg()
|
||||
|
||||
conn = sqlite3.connect(get_file_db())
|
||||
view = 'episode' if item.contentType != 'movie' else 'movie'
|
||||
path = '%{}%'.format(item.strm_path.split('\\')[0].split('/')[0] if item.strm_path else item.base_name)
|
||||
|
||||
request_season = ''
|
||||
request_episode = ''
|
||||
if item.contentSeason: request_season = ' and c12= {}'.format(item.contentSeason)
|
||||
if item.contentEpisodeNumber: request_episode = ' and strFileName= "{}"'.format(item.strm_path.split('\\')[-1].split('/')[-1])
|
||||
if item.contentType in ['season', 'episode'] and item.contentSeason: request_season = ' and c12= {}'.format(item.contentSeason)
|
||||
if item.contentType in ['episode'] and item.contentEpisodeNumber: request_episode = ' and strFileName= "{}"'.format(item.strm_path.split('\\')[-1].split('/')[-1])
|
||||
sql = 'select idFile from {}_view where strPath like "{}"{}{}'.format(view, path, request_episode, request_season)
|
||||
|
||||
n, r = execute_sql_kodi(sql, conn=conn)
|
||||
@@ -294,7 +295,7 @@ def mark_content_as_watched_on_kodi(item, value=1):
|
||||
def set_watched_on_kod(data):
|
||||
from specials import videolibrary
|
||||
from core.videolibrarytools import videolibrarydb
|
||||
# support.dbg()
|
||||
# from core.support import dbg;dbg()
|
||||
|
||||
data = jsontools.load(data)
|
||||
Type = data.get('item', {}).get('type','')
|
||||
@@ -332,6 +333,7 @@ def set_watched_on_kod(data):
|
||||
_id = scrapertools.find_single_match(records[0][0], r'\[([^\]]+)')
|
||||
contents = videolibrarydb[Type].get(_id, {})
|
||||
item = contents.get('item', None)
|
||||
|
||||
if item:
|
||||
item.playcount = playcount
|
||||
item.not_update = True
|
||||
|
||||
Reference in New Issue
Block a user