- Unico Tread per:
- Segna come visto - Episodio successivo - Rimosse impostazioni nascondi server (non più necessarie) - Ottimizzazione grafica finestre
This commit is contained in:
@@ -400,7 +400,6 @@ def limit_itemlist(itemlist):
|
||||
|
||||
|
||||
def play_from_library(item):
|
||||
# from core.support import dbg;dbg()
|
||||
"""
|
||||
The .strm files when played from kodi, this expects it to be a "playable" file so it cannot contain
|
||||
more items, at most a selection dialog can be placed.
|
||||
@@ -413,96 +412,65 @@ def play_from_library(item):
|
||||
"""
|
||||
import xbmcgui, xbmcplugin, xbmc
|
||||
from time import sleep, time
|
||||
from specials import nextep
|
||||
|
||||
def show_server(item, itemlist, p_dialog):
|
||||
if item.show_server:
|
||||
# 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)
|
||||
|
||||
p_dialog.update(100, ''); sleep(0.5); p_dialog.close()
|
||||
|
||||
if len(itemlist) > 0:
|
||||
while not xbmc.Monitor().abortRequested():
|
||||
# The user chooses the mirror
|
||||
options = []
|
||||
selection_implementation =0
|
||||
for item in itemlist:
|
||||
item.thumbnail = "https://github.com/kodiondemand/media/raw/master/resources/servers/" + item.server.lower() + '.png'
|
||||
quality = '[B][' + item.quality + '][/B]' if item.quality else ''
|
||||
if item.server:
|
||||
it = xbmcgui.ListItem('\n[B]%s[/B] %s - %s' % (item.server, quality, item.contentTitle))
|
||||
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]
|
||||
item.play_from = 'window'
|
||||
platformtools.play_video(item)
|
||||
if (platformtools.is_playing() and item.action) or item.server == 'torrent' or config.get_setting('autoplay'): break
|
||||
|
||||
itemlist=[]
|
||||
item.fromLibrary = True
|
||||
logger.info()
|
||||
logger.debug("item: \n" + item.tostring('\n'))
|
||||
# logger.debug("item: \n" + item.tostring('\n'))
|
||||
|
||||
# We try to reproduce an image (this does nothing and also does not give an error)
|
||||
# Try to reproduce an image (this does nothing and also does not give an error)
|
||||
xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, xbmcgui.ListItem(path=os.path.join(config.get_runtime_path(), "resources", "kod.mp4")))
|
||||
xbmc.Player().stop()
|
||||
|
||||
# we modify the action (currently the video library needs "findvideos" since this is where the sources are searched
|
||||
# Modify the action (currently the video library needs "findvideos" since this is where the sources are searched
|
||||
item.action = "findvideos"
|
||||
check_next_ep = nextep.check(item)
|
||||
|
||||
window_type = config.get_setting("window_type", "videolibrary")
|
||||
|
||||
# and we launch kodi again
|
||||
# and launch kodi again
|
||||
if xbmc.getCondVisibility('Window.IsMedia') and not window_type == 1:
|
||||
# Conventional window
|
||||
xbmc.executebuiltin("Container.Update(" + sys.argv[0] + "?" + item.tourl() + ")")
|
||||
|
||||
else:
|
||||
# from core.support import dbg;dbg()
|
||||
# Pop-up window
|
||||
if config.get_setting('autoplay') and config.get_setting('hide_servers'):
|
||||
item.show_server = False
|
||||
else:
|
||||
item.show_server = True
|
||||
|
||||
from specials import videolibrary, autoplay
|
||||
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()
|
||||
while platformtools.is_playing(): # Conventional window
|
||||
sleep(1)
|
||||
play_time = platformtools.resume_playback(item, True)
|
||||
if not play_time:
|
||||
return
|
||||
|
||||
# if not config.get_setting('autoplay'): show_server(item, itemlist, p_dialog)
|
||||
|
||||
if check_next_ep:
|
||||
item.show_server = True
|
||||
# p_dialog.update(100, '')
|
||||
# sleep(0.5)
|
||||
# p_dialog.close()
|
||||
if not config.get_setting('autoplay'): show_server(item, itemlist, p_dialog)
|
||||
item = nextep.return_item(item)
|
||||
if item.next_ep: return play_from_library(item)
|
||||
else:
|
||||
while platformtools.is_playing(): # Conventional window
|
||||
sleep(5)
|
||||
p_dialog.update(50, '')
|
||||
|
||||
show_server(item, itemlist, p_dialog)
|
||||
|
||||
if item.show_server and check_next_ep:
|
||||
nextep.run(item)
|
||||
sleep(0.5)
|
||||
p_dialog.close()
|
||||
# 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:
|
||||
while not xbmc.Monitor().abortRequested():
|
||||
# The user chooses the mirror
|
||||
options = []
|
||||
selection_implementation = 0
|
||||
for item in itemlist:
|
||||
item.thumbnail = "https://github.com/kodiondemand/media/raw/master/resources/servers/" + item.server.lower() + '.png'
|
||||
quality = '[B][' + item.quality + '][/B]' if item.quality else ''
|
||||
if item.server:
|
||||
it = xbmcgui.ListItem('\n[B]%s[/B] %s - %s' % (item.server, quality, item.contentTitle))
|
||||
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)
|
||||
if (platformtools.is_playing() and item.action) or item.server == 'torrent' or config.get_setting('autoplay'): break
|
||||
@@ -548,7 +548,10 @@ def play_video(item, strm=False, force_direct=False, autoplay=False):
|
||||
xlistitem.setProperty('inputstream.adaptive.manifest_type', 'mpd')
|
||||
|
||||
if force_direct: item.play_from = 'window'
|
||||
set_player(item, xlistitem, mediaurl, view, strm)
|
||||
|
||||
|
||||
nfo_path, head_nfo, item_nfo = resume_playback(item)
|
||||
set_player(item, xlistitem, mediaurl, view, strm, nfo_path, head_nfo, item_nfo)
|
||||
|
||||
|
||||
def stop_video():
|
||||
@@ -876,9 +879,9 @@ def get_video_seleccionado(item, seleccion, video_urls):
|
||||
return mediaurl, view, mpd
|
||||
|
||||
|
||||
def set_player(item, xlistitem, mediaurl, view, strm):
|
||||
def set_player(item, xlistitem, mediaurl, view, strm, nfo_path=None, head_nfo=None, item_nfo=None):
|
||||
logger.info()
|
||||
logger.debug("item:\n" + item.tostring('\n'))
|
||||
# logger.debug("item:\n" + item.tostring('\n'))
|
||||
# Moved del conector "torrent" here
|
||||
if item.server == "torrent":
|
||||
play_torrent(item, xlistitem, mediaurl)
|
||||
@@ -914,7 +917,7 @@ def set_player(item, xlistitem, mediaurl, view, strm):
|
||||
# if it is a video library file send to mark as seen
|
||||
if strm or item.strm_path:
|
||||
from platformcode import xbmc_videolibrary
|
||||
xbmc_videolibrary.mark_auto_as_watched(item)
|
||||
xbmc_videolibrary.mark_auto_as_watched(item, nfo_path, head_nfo, item_nfo)
|
||||
xlistitem.setPath(mediaurl)
|
||||
xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, xlistitem)
|
||||
xbmc.sleep(2500)
|
||||
@@ -938,7 +941,7 @@ def set_player(item, xlistitem, mediaurl, view, strm):
|
||||
# if it is a video library file send to mark as seen
|
||||
if strm or item.strm_path:
|
||||
from platformcode import xbmc_videolibrary
|
||||
xbmc_videolibrary.mark_auto_as_watched(item)
|
||||
xbmc_videolibrary.mark_auto_as_watched(item, nfo_path, head_nfo, item_nfo)
|
||||
|
||||
|
||||
def torrent_client_installed(show_tuple=False):
|
||||
@@ -998,4 +1001,89 @@ def play_torrent(item, xlistitem, mediaurl):
|
||||
|
||||
|
||||
def log(texto):
|
||||
xbmc.log(texto, xbmc.LOGNOTICE)
|
||||
xbmc.log(texto, xbmc.LOGNOTICE)
|
||||
|
||||
def resume_playback(item, return_played_time=False):
|
||||
class ResumePlayback(xbmcgui.WindowXMLDialog):
|
||||
Close = False
|
||||
Resume = False
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.action_exitkeys_id = [xbmcgui.ACTION_BACKSPACE, xbmcgui.ACTION_PREVIOUS_MENU, xbmcgui.ACTION_NAV_BACK]
|
||||
self.progress_control = None
|
||||
self.item = kwargs.get('item')
|
||||
m, s = divmod(float(self.item.played_time), 60)
|
||||
h, m = divmod(m, 60)
|
||||
self.setProperty("time", '%02d:%02d:%02d' % (h, m, s))
|
||||
|
||||
def set_values(self, value):
|
||||
self.Resume = value
|
||||
self.Close = True
|
||||
|
||||
def is_close(self):
|
||||
return self.Close
|
||||
|
||||
def onClick(self, controlId):
|
||||
if controlId == 3012: # Resume
|
||||
self.set_values(True)
|
||||
self.close()
|
||||
elif controlId == 3013: # Cancel
|
||||
self.set_values(False)
|
||||
self.close()
|
||||
|
||||
def onAction(self, action):
|
||||
if action in self.action_exitkeys_id:
|
||||
self.set_values(False)
|
||||
self.close()
|
||||
|
||||
|
||||
from core import videolibrarytools, filetools
|
||||
|
||||
# if nfo and strm_path not exist
|
||||
if not item.nfo:
|
||||
if item.contentType == 'movie':
|
||||
vl = xbmc.translatePath(filetools.join(config.get_setting("videolibrarypath"), config.get_setting("folder_movies")))
|
||||
path = '%s [%s]' % (item.contentTitle, item.infoLabels['IMDBNumber'])
|
||||
item.nfo = filetools.join(vl, path, path + '.nfo')
|
||||
if not item.strm_path: item.strm_path = filetools.join(path, item.contentTitle + '.strm')
|
||||
else:
|
||||
vl = xbmc.translatePath(filetools.join(config.get_setting("videolibrarypath"), config.get_setting("folder_tvshows")))
|
||||
path = '%s [%s]' % (item.contentSerieName, item.infoLabels['IMDBNumber'])
|
||||
item.nfo = filetools.join(vl, path, 'tvshow.nfo')
|
||||
if item.contentSeason and item.contentEpisodeNumber:
|
||||
title = str(item.contentSeason) + 'x' + str(item.contentEpisodeNumber).zfill(2)
|
||||
else:
|
||||
season, episode = scrapertools.find_single_match(item.title, r'(\d+)x(\d+)')
|
||||
item.contentSeason = int(season)
|
||||
item.contentEpisodeNumber = int(episode)
|
||||
title = season + 'x' + episode.zfill(2)
|
||||
if not item.strm_path: item.strm_path = filetools.join(path, title + '.strm')
|
||||
|
||||
# Read NFO FILE
|
||||
if item.contentType == 'movie':
|
||||
nfo_path = item.nfo
|
||||
elif xbmc.translatePath(filetools.join(config.get_setting("videolibrarypath"), config.get_setting("folder_tvshows"))) in item.strm_path:
|
||||
nfo_path = item.strm_path.replace('strm','nfo')
|
||||
else:
|
||||
nfo_path = xbmc.translatePath(filetools.join(config.get_setting("videolibrarypath"), config.get_setting("folder_tvshows"),item.strm_path.replace('strm','nfo')))
|
||||
if filetools.isfile(nfo_path):
|
||||
head_nfo, item_nfo = videolibrarytools.read_nfo(nfo_path)
|
||||
|
||||
if return_played_time:
|
||||
return item_nfo.played_time
|
||||
# Show Window
|
||||
elif (config.get_setting("player_mode") not in [1, 3] or item.play_from == 'window') and item_nfo.played_time:
|
||||
Dialog = ResumePlayback('ResumePlayback.xml', config.get_runtime_path(), item=item_nfo)
|
||||
Dialog.show()
|
||||
t = 0
|
||||
while not Dialog.is_close() and t < 50:
|
||||
t += 1
|
||||
xbmc.sleep(100)
|
||||
if not Dialog.Resume: item_nfo.played_time = 0
|
||||
else:
|
||||
item_nfo.played_time = 0
|
||||
|
||||
return nfo_path, head_nfo, item_nfo
|
||||
else:
|
||||
item.nfo = item.strm_path = ""
|
||||
return None, None, None
|
||||
@@ -15,7 +15,7 @@ from core import scrapertools
|
||||
from xml.dom import minidom
|
||||
|
||||
|
||||
def mark_auto_as_watched(item):
|
||||
def mark_auto_as_watched(item, nfo_path=None, head_nfo=None, item_nfo=None):
|
||||
def mark_as_watched_subThread(item, nfo_path, head_nfo, item_nfo):
|
||||
logger.info()
|
||||
# logger.debug("item:\n" + item.tostring('\n'))
|
||||
@@ -25,22 +25,54 @@ def mark_auto_as_watched(item):
|
||||
time.sleep(1)
|
||||
|
||||
sync_with_trakt = False
|
||||
next_episode = None
|
||||
show_server = True
|
||||
EXIT = False
|
||||
|
||||
percentage = float(config.get_setting("watched_setting")) / 100
|
||||
while platformtools.is_playing():
|
||||
time_from_end = config.get_setting('next_ep_seconds')
|
||||
|
||||
while platformtools.is_playing() and not EXIT:
|
||||
actual_time = xbmc.Player().getTime()
|
||||
totaltime = xbmc.Player().getTotalTime()
|
||||
if item_nfo.played_time and actual_time < item_nfo.played_time:
|
||||
total_time = xbmc.Player().getTotalTime()
|
||||
if item_nfo.played_time and item_nfo.played_time > actual_time > 1:
|
||||
xbmc.Player().seekTime(item_nfo.played_time)
|
||||
|
||||
mark_time = totaltime * percentage
|
||||
mark_time = total_time * percentage
|
||||
difference = total_time - actual_time
|
||||
|
||||
# Mark as Watched
|
||||
if actual_time > mark_time:
|
||||
logger.debug("Marked as Watched")
|
||||
item.playcount = 1
|
||||
sync_with_trakt = True
|
||||
from specials import videolibrary
|
||||
videolibrary.mark_content_as_watched2(item)
|
||||
break
|
||||
show_server = False
|
||||
if item.contentType == 'movie' or not config.get_setting('next_ep'):
|
||||
EXIT = True
|
||||
|
||||
# check for next Episode
|
||||
if item.contentType != 'movie' and total_time > time_from_end >= difference:
|
||||
next_dialogs = ['NextDialog.xml', 'NextDialogExtended.xml', 'NextDialogCompact.xml']
|
||||
next_ep_type = config.get_setting('next_ep_type')
|
||||
ND = next_dialogs[next_ep_type]
|
||||
next_episode = next_ep(item)
|
||||
if next_episode:
|
||||
nextdialog = NextDialog(ND, config.get_runtime_path())
|
||||
nextdialog.show()
|
||||
while platformtools.is_playing() and not nextdialog.is_exit():
|
||||
xbmc.sleep(100)
|
||||
pass
|
||||
EXIT = True
|
||||
nextdialog.close()
|
||||
if nextdialog.continuewatching:
|
||||
next_episode.next_ep = True
|
||||
else:
|
||||
EXIT = True
|
||||
|
||||
if next_episode and next_episode.next_ep:
|
||||
xbmc.Player().stop()
|
||||
|
||||
time.sleep(1)
|
||||
|
||||
@@ -51,91 +83,23 @@ def mark_auto_as_watched(item):
|
||||
|
||||
# Silent sync with Trakt
|
||||
if sync_with_trakt and config.get_setting("trakt_sync"):sync_trakt_kodi()
|
||||
while platformtools.is_playing():
|
||||
xbmc.sleep(100)
|
||||
if not show_server and item.play_from != 'window':
|
||||
xbmc.sleep(700)
|
||||
xbmc.executebuiltin('Action(Back)')
|
||||
xbmc.sleep(500)
|
||||
if next_episode:
|
||||
if next_episode.next_ep:
|
||||
from platformcode.launcher import play_from_library
|
||||
return play_from_library(next_episode)
|
||||
|
||||
# If it is configured to mark as seen
|
||||
if config.get_setting("mark_as_watched", "videolibrary"):
|
||||
nfo_path, head_nfo, item_nfo = resume_playback(item)
|
||||
threading.Thread(target=mark_as_watched_subThread, args=[item, nfo_path, head_nfo, item_nfo]).start()
|
||||
|
||||
|
||||
def resume_playback(item):
|
||||
class ResumePlayback(xbmcgui.WindowXMLDialog):
|
||||
Close = False
|
||||
Resume = False
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.action_exitkeys_id = [xbmcgui.ACTION_BACKSPACE, xbmcgui.ACTION_PREVIOUS_MENU, xbmcgui.ACTION_NAV_BACK]
|
||||
self.progress_control = None
|
||||
self.item = kwargs.get('item')
|
||||
m, s = divmod(float(self.item.played_time), 60)
|
||||
h, m = divmod(m, 60)
|
||||
self.setProperty("title", config.get_localized_string(30045) +' %02d:%02d:%02d' % (h, m, s))
|
||||
|
||||
def set_values(self, value):
|
||||
self.Resume = value
|
||||
self.Close = True
|
||||
|
||||
def is_close(self):
|
||||
return self.Close
|
||||
|
||||
def onClick(self, controlId):
|
||||
if controlId == 3012: # Resume
|
||||
self.set_values(True)
|
||||
self.close()
|
||||
elif controlId == 3013: # Cancel
|
||||
self.set_values(False)
|
||||
self.close()
|
||||
|
||||
def onAction(self, action):
|
||||
if action in self.action_exitkeys_id:
|
||||
self.set_values(False)
|
||||
self.close()
|
||||
|
||||
|
||||
from core import videolibrarytools
|
||||
# from core.support import dbg;dbg()
|
||||
|
||||
# if nfo and strm_path not exist
|
||||
if not item.nfo:
|
||||
if item.contentType == 'movie':
|
||||
vl = xbmc.translatePath(filetools.join(config.get_setting("videolibrarypath"), config.get_setting("folder_movies")))
|
||||
path = '%s [%s]' % (item.contentTitle, item.infoLabels['IMDBNumber'])
|
||||
item.nfo = filetools.join(vl, path, path + '.nfo')
|
||||
if not item.strm_path: item.strm_path = filetools.join(path, item.contentTitle + '.strm')
|
||||
else:
|
||||
vl = xbmc.translatePath(filetools.join(config.get_setting("videolibrarypath"), config.get_setting("folder_tvshows")))
|
||||
path = '%s [%s]' % (item.contentSerieName, item.infoLabels['IMDBNumber'])
|
||||
item.nfo = filetools.join(vl, path, 'tvshow.nfo')
|
||||
if item.contentSeason and item.contentEpisodeNumber:
|
||||
title = str(item.contentSeason) + 'x' + str(item.contentEpisodeNumber).zfill(2)
|
||||
else:
|
||||
season, episode = scrapertools.find_single_match(item.title, r'(\d+)x(\d+)')
|
||||
item.contentSeason = int(season)
|
||||
item.contentEpisodeNumber = int(episode)
|
||||
title = season + 'x' + episode.zfill(2)
|
||||
if not item.strm_path: item.strm_path = filetools.join(path, title + '.strm')
|
||||
|
||||
# Read NFO FILE
|
||||
if item.contentType == 'movie':
|
||||
nfo_path = item.nfo
|
||||
elif xbmc.translatePath(filetools.join(config.get_setting("videolibrarypath"), config.get_setting("folder_tvshows"))) in item.strm_path:
|
||||
nfo_path = item.strm_path.replace('strm','nfo')
|
||||
else:
|
||||
nfo_path = xbmc.translatePath(filetools.join(config.get_setting("videolibrarypath"), config.get_setting("folder_tvshows"),item.strm_path.replace('strm','nfo')))
|
||||
head_nfo, item_nfo = videolibrarytools.read_nfo(nfo_path)
|
||||
|
||||
# Show Window
|
||||
if (config.get_setting("player_mode") not in [3] or item.play_from == 'window') and item_nfo.played_time:
|
||||
Dialog = ResumePlayback('ResumePlayback.xml', config.get_runtime_path(), item=item_nfo)
|
||||
Dialog.show()
|
||||
t = 0
|
||||
while not Dialog.is_close() and t < 50:
|
||||
t += 1
|
||||
xbmc.sleep(100)
|
||||
if not Dialog.Resume: item_nfo.played_time = 0
|
||||
else:
|
||||
item_nfo.played_time = 0
|
||||
return nfo_path, head_nfo, item_nfo
|
||||
|
||||
|
||||
def sync_trakt_addon(path_folder):
|
||||
@@ -164,7 +128,7 @@ def sync_trakt_addon(path_folder):
|
||||
shows = list(shows.items())
|
||||
|
||||
# we get the series id to compare
|
||||
_id = re.findall("\[(.*?)\]", path_folder, flags=re.DOTALL)[0]
|
||||
_id = re.findall(r"\[(.*?)\]", path_folder, flags=re.DOTALL)[0]
|
||||
logger.debug("the id is %s" % _id)
|
||||
|
||||
if "tt" in _id:
|
||||
@@ -206,7 +170,7 @@ def sync_trakt_addon(path_folder):
|
||||
logger.debug("dict_trakt_show %s " % dict_trakt_show)
|
||||
|
||||
# we get the keys that are episodes
|
||||
regex_epi = re.compile('\d+x\d+')
|
||||
regex_epi = re.compile(r'\d+x\d+')
|
||||
keys_episodes = [key for key in serie.library_playcounts if regex_epi.match(key)]
|
||||
# we get the keys that are seasons
|
||||
keys_seasons = [key for key in serie.library_playcounts if 'season ' in key]
|
||||
@@ -330,7 +294,6 @@ def mark_content_as_watched_on_kodi(item, value=1):
|
||||
path = filetools.join(tail, filename)
|
||||
|
||||
for d in data['result']['episodes']:
|
||||
|
||||
if d['file'].replace("/", "\\").endswith(path.replace("/", "\\")):
|
||||
# logger.debug("I mark the episode as seen")
|
||||
episodeid = d['episodeid']
|
||||
@@ -430,7 +393,7 @@ def mark_content_as_watched_on_kod(path):
|
||||
path1 = path.replace("\\\\", "\\") # Windows format
|
||||
if not path2:
|
||||
path2 = path1.replace("\\", "/") # Format no Windows
|
||||
nfo_name = scrapertools.find_single_match(path2, '\]\/(.*?)$') # I build the name of the .nfo
|
||||
nfo_name = scrapertools.find_single_match(path2, r'\]\/(.*?)$') # I build the name of the .nfo
|
||||
path1 = path1.replace(nfo_name, '') # for SQL I just need the folder
|
||||
path2 = path2.replace(nfo_name, '') # for SQL I just need the folder
|
||||
path2 = filetools.remove_smb_credential(path2) # If the file is on an SMB server, we remove the credentials
|
||||
@@ -448,7 +411,7 @@ def mark_content_as_watched_on_kod(path):
|
||||
if contentType == "episode_view":
|
||||
title_plain = title.replace('.strm', '') # If it is Serial, we remove the suffix .strm
|
||||
else:
|
||||
title_plain = scrapertools.find_single_match(item.strm_path, '.(.*?\s\[.*?\])') # if it's a movie, we remove the title
|
||||
title_plain = scrapertools.find_single_match(item.strm_path, r'.(.*?\s\[.*?\])') # if it's a movie, we remove the title
|
||||
if playCount is None or playCount == 0: # not yet seen, we set it to 0
|
||||
playCount_final = 0
|
||||
elif playCount >= 1:
|
||||
@@ -463,7 +426,7 @@ def mark_content_as_watched_on_kod(path):
|
||||
if item.infoLabels['mediatype'] == "tvshow": # We update the Season and Series playCounts
|
||||
for season in item.library_playcounts:
|
||||
if "season" in season: # we look for the tags "season" inside playCounts
|
||||
season_num = int(scrapertools.find_single_match(season, 'season (\d+)')) # we save the season number
|
||||
season_num = int(scrapertools.find_single_match(season, r'season (\d+)')) # we save the season number
|
||||
item = videolibrary.check_season_playcount(item, season_num) # We call the method that updates Temps. and series
|
||||
|
||||
filetools.write(path, head_nfo + item.tojson())
|
||||
@@ -551,7 +514,7 @@ def update(folder_content=config.get_setting("folder_tvshows"), folder=""):
|
||||
# update_path = filetools.join(videolibrarypath, folder_content, folder) + "/" # Encoder problems in "folder"
|
||||
update_path = filetools.join(videolibrarypath, folder_content, ' ').rstrip()
|
||||
|
||||
if videolibrarypath.startswith("special:") or not scrapertools.find_single_match(update_path, '(^\w+:\/\/)'):
|
||||
if videolibrarypath.startswith("special:") or not scrapertools.find_single_match(update_path, r'(^\w+:\/\/)'):
|
||||
payload["params"] = {"directory": update_path}
|
||||
|
||||
while xbmc.getCondVisibility('Library.IsScanningVideo()'):
|
||||
@@ -593,7 +556,7 @@ def set_content(content_type, silent=False, custom=False):
|
||||
if not xbmc.getCondVisibility('System.HasAddon(metadata.themoviedb.org)'):
|
||||
if not silent:
|
||||
# Ask if we want to install metadata.themoviedb.org
|
||||
install = platformtools.dialog_yesno(config.get_localized_string(60046))
|
||||
install = platformtools.dialog_yesno(config.get_localized_string(60046),'')
|
||||
else:
|
||||
install = True
|
||||
|
||||
@@ -617,7 +580,7 @@ def set_content(content_type, silent=False, custom=False):
|
||||
continuar = False
|
||||
if not silent:
|
||||
# Ask if we want to install metadata.universal
|
||||
install = platformtools.dialog_yesno(config.get_localized_string(70095))
|
||||
install = platformtools.dialog_yesno(config.get_localized_string(70095),'')
|
||||
else:
|
||||
install = True
|
||||
|
||||
@@ -647,7 +610,7 @@ def set_content(content_type, silent=False, custom=False):
|
||||
if not xbmc.getCondVisibility('System.HasAddon(metadata.tvdb.com)'):
|
||||
if not silent:
|
||||
#Ask if we want to install metadata.tvdb.com
|
||||
install = platformtools.dialog_yesno(config.get_localized_string(60048))
|
||||
install = platformtools.dialog_yesno(config.get_localized_string(60048),'')
|
||||
else:
|
||||
install = True
|
||||
|
||||
@@ -671,7 +634,7 @@ def set_content(content_type, silent=False, custom=False):
|
||||
continuar = False
|
||||
if not silent:
|
||||
# Ask if we want to install metadata.tvshows.themoviedb.org
|
||||
install = platformtools.dialog_yesno(config.get_localized_string(60050))
|
||||
install = platformtools.dialog_yesno(config.get_localized_string(60050),'')
|
||||
else:
|
||||
install = True
|
||||
|
||||
@@ -705,7 +668,7 @@ def set_content(content_type, silent=False, custom=False):
|
||||
if sql_videolibrarypath.startswith("special://"):
|
||||
sql_videolibrarypath = sql_videolibrarypath.replace('/profile/', '/%/').replace('/home/userdata/', '/%/')
|
||||
sep = '/'
|
||||
elif scrapertools.find_single_match(sql_videolibrarypath, '(^\w+:\/\/)'):
|
||||
elif scrapertools.find_single_match(sql_videolibrarypath, r'(^\w+:\/\/)'):
|
||||
sep = '/'
|
||||
else:
|
||||
sep = os.sep
|
||||
@@ -1282,4 +1245,113 @@ def ask_set_content(silent=False):
|
||||
# configuration from the settings menu
|
||||
else:
|
||||
platformtools.dialog_ok(config.get_localized_string(80026), config.get_localized_string(80023))
|
||||
do_config(True)
|
||||
do_config(True)
|
||||
|
||||
|
||||
def next_ep(item):
|
||||
from core.item import Item
|
||||
logger.info()
|
||||
item.next_ep = False
|
||||
|
||||
if config.get_setting('next_ep'): # play next file if exist
|
||||
# check if next file exist
|
||||
current_filename = filetools.basename(item.strm_path)
|
||||
base_path = filetools.basename(filetools.dirname(item.strm_path))
|
||||
path = filetools.join(config.get_videolibrary_path(), config.get_setting("folder_tvshows"),base_path)
|
||||
fileList = []
|
||||
for file in filetools.listdir(path):
|
||||
if file.endswith('.strm'):
|
||||
fileList.append(file)
|
||||
|
||||
fileList.sort()
|
||||
|
||||
nextIndex = fileList.index(current_filename) + 1
|
||||
if nextIndex == 0 or nextIndex == len(fileList):
|
||||
next_file = None
|
||||
else:
|
||||
next_file = fileList[nextIndex]
|
||||
logger.info('Next File:' + next_file)
|
||||
|
||||
# start next episode window afther x time
|
||||
if next_file:
|
||||
season_ep = next_file.split('.')[0]
|
||||
season = season_ep.split('x')[0]
|
||||
episode = season_ep.split('x')[1]
|
||||
next_ep = '%sx%s' % (season, episode)
|
||||
item = Item(
|
||||
action= 'play_from_library',
|
||||
channel= 'videolibrary',
|
||||
contentEpisodeNumber= episode,
|
||||
contentSeason= season,
|
||||
contentTitle= next_ep,
|
||||
contentType= 'episode',
|
||||
infoLabels= {'episode': episode, 'mediatype': 'episode', 'season': season, 'title': next_ep},
|
||||
strm_path= filetools.join(base_path, next_file),
|
||||
play_from = item.play_from)
|
||||
|
||||
global INFO
|
||||
INFO = filetools.join(path, next_file.replace("strm", "nfo"))
|
||||
# logger.info('Next Info:\n' + str(INFO))
|
||||
|
||||
return item
|
||||
|
||||
|
||||
class NextDialog(xbmcgui.WindowXMLDialog):
|
||||
item = None
|
||||
cancel = False
|
||||
EXIT = False
|
||||
continuewatching = True
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.action_exitkeys_id = [xbmcgui.ACTION_STOP, xbmcgui.ACTION_BACKSPACE, xbmcgui.ACTION_PREVIOUS_MENU, xbmcgui.ACTION_NAV_BACK]
|
||||
self.progress_control = None
|
||||
|
||||
# set info
|
||||
f = filetools.file_open(INFO, 'r')
|
||||
full_info = f.read().split('\n')
|
||||
full_info = full_info[1:]
|
||||
f.close()
|
||||
full_info = "".join(full_info)
|
||||
info = jsontools.load(full_info)
|
||||
if "thumbnail" in info:
|
||||
img = info["thumbnail"]
|
||||
else:
|
||||
img = filetools.join(config.get_runtime_path(), "resources", "noimage.png")
|
||||
self.setProperty("next_img", img)
|
||||
info = info["infoLabels"]
|
||||
self.setProperty("title", info["tvshowtitle"])
|
||||
self.setProperty("ep_title", "%dx%02d - %s" % (info["season"], info["episode"], info["title"]))
|
||||
|
||||
def set_exit(self, EXIT):
|
||||
self.EXIT = EXIT
|
||||
|
||||
def set_continue_watching(self, continuewatching):
|
||||
self.continuewatching = continuewatching
|
||||
|
||||
def is_exit(self):
|
||||
return self.EXIT
|
||||
|
||||
def onFocus(self, controlId):
|
||||
pass
|
||||
|
||||
def doAction(self):
|
||||
pass
|
||||
|
||||
def closeDialog(self):
|
||||
self.close()
|
||||
|
||||
def onClick(self, controlId):
|
||||
if controlId == 3012: # Still watching
|
||||
self.set_exit(True)
|
||||
self.set_continue_watching(True)
|
||||
self.close()
|
||||
elif controlId == 3013: # Cancel
|
||||
self.set_exit(True)
|
||||
self.set_continue_watching(False)
|
||||
self.close()
|
||||
|
||||
def onAction(self, action):
|
||||
if action in self.action_exitkeys_id:
|
||||
self.set_exit(True)
|
||||
self.set_continue_watching(False)
|
||||
self.close()
|
||||
Reference in New Issue
Block a user