diff --git a/channels/cineblog01.py b/channels/cineblog01.py index aace84e3..31ced302 100644 --- a/channels/cineblog01.py +++ b/channels/cineblog01.py @@ -267,4 +267,4 @@ def findvid_serie(item): def play(item): support.log() - return servertools.find_video_items(data=item.url) + return servertools.find_video_items(item, data=item.url) diff --git a/core/support.py b/core/support.py index 17afbf28..5cdb85e8 100755 --- a/core/support.py +++ b/core/support.py @@ -1192,9 +1192,6 @@ def server(item, data='', itemlist=[], headers='', AutoPlay=True, CheckLinks=Tru if patronTag: addQualityTag(item, verifiedItemlist, data, patronTag) - # Auto Play & Hide Links - AP = config.get_setting('autoplay') - # Check Links if not item.global_search and (config.get_setting('checklinks') or config.get_setting('checklinks', item.channel)): if config.get_setting('checklinks', item.channel): @@ -1210,8 +1207,8 @@ def server(item, data='', itemlist=[], headers='', AutoPlay=True, CheckLinks=Tru videolibrary(verifiedItemlist, item) if Download: download(verifiedItemlist, item, function_level=3) - if item.contentChannel == 'videolibrary' or not config.get_setting('autoplay') or not config.get_setting('hide_servers'): - return verifiedItemlist + # if item.contentChannel == 'videolibrary' or not config.get_setting('autoplay'): + return verifiedItemlist def filterLang(item, itemlist): diff --git a/platformcode/launcher.py b/platformcode/launcher.py index 8ed62f79..a2c70eb5 100644 --- a/platformcode/launcher.py +++ b/platformcode/launcher.py @@ -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 \ No newline at end of file diff --git a/platformcode/platformtools.py b/platformcode/platformtools.py index 986c7985..df1def61 100644 --- a/platformcode/platformtools.py +++ b/platformcode/platformtools.py @@ -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) \ No newline at end of file + 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 \ No newline at end of file diff --git a/platformcode/xbmc_videolibrary.py b/platformcode/xbmc_videolibrary.py index 636a3131..08bc57bd 100644 --- a/platformcode/xbmc_videolibrary.py +++ b/platformcode/xbmc_videolibrary.py @@ -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) \ No newline at end of file + 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() \ No newline at end of file diff --git a/resources/language/resource.language.en_gb/strings.po b/resources/language/resource.language.en_gb/strings.po index 55e2497a..c4f3db0d 100644 --- a/resources/language/resource.language.en_gb/strings.po +++ b/resources/language/resource.language.en_gb/strings.po @@ -195,6 +195,10 @@ msgctxt "#30045" msgid "Resume from:" msgstr "" +msgctxt "#30046" +msgid "Resume from start" +msgstr "" + msgctxt "#30050" msgid "Server connection error" msgstr "" diff --git a/resources/language/resource.language.it_it/strings.po b/resources/language/resource.language.it_it/strings.po index 6d2e2fc1..d444157b 100644 --- a/resources/language/resource.language.it_it/strings.po +++ b/resources/language/resource.language.it_it/strings.po @@ -195,6 +195,10 @@ msgctxt "#30045" msgid "Resume from:" msgstr "Riprendi da:" +msgctxt "#30046" +msgid "Resume from start" +msgstr "Riprendi dall'inizio" + msgctxt "#30050" msgid "Server connection error" msgstr "Errore connessione server" diff --git a/resources/settings.xml b/resources/settings.xml index b6d82544..6a3462d1 100644 --- a/resources/settings.xml +++ b/resources/settings.xml @@ -20,7 +20,7 @@ - + @@ -35,10 +35,10 @@ - - - - + + + + diff --git a/resources/skins/Default/720p/ChannelSettings.xml b/resources/skins/Default/720p/ChannelSettings.xml index e095e11f..ebb5d276 100644 --- a/resources/skins/Default/720p/ChannelSettings.xml +++ b/resources/skins/Default/720p/ChannelSettings.xml @@ -19,7 +19,7 @@ 100% 100% - Shortcut/white.png + white.png @@ -27,7 +27,7 @@ 0 100% 1 - Shortcut/white.png + white.png @@ -47,8 +47,8 @@ 25 30 30 - Controls/DialogCloseButton-focus.png - Controls/DialogCloseButton-focus.png + close.png + close.png @@ -58,8 +58,8 @@ 60 110 FFFFFFFF - Shortcut/white.png - Shortcut/white.png + white.png + white.png center center @@ -72,8 +72,8 @@ 60 110 FFFFFFFF - Shortcut/white.png - Shortcut/white.png + white.png + white.png center center @@ -86,8 +86,8 @@ 60 110 FFFFFFFF - Shortcut/white.png - Shortcut/white.png + white.png + white.png center center @@ -116,14 +116,14 @@ 0 10 540 - Shortcut/white.png + white.png 120 0 10 540 - Shortcut/white.png + white.png diff --git a/resources/skins/Default/720p/DarkShortCutMenu.xml b/resources/skins/Default/720p/DarkShortCutMenu.xml index cee155c4..037af2a7 100644 --- a/resources/skins/Default/720p/DarkShortCutMenu.xml +++ b/resources/skins/Default/720p/DarkShortCutMenu.xml @@ -12,8 +12,8 @@ 0 100% 100% - Shortcut/white.png - Shortcut/white.png + white.png + white.png WindowOpen WindowClose Action(close) @@ -39,9 +39,9 @@ 219 1100 10 - Shortcut/white.png - Shortcut/white.png - Shortcut/white.png + white.png + white.png + white.png false horizontal 32500 @@ -50,7 +50,7 @@ 1100 218 - Shortcut/white.png + white.png -130 @@ -78,7 +78,7 @@ 1 220 218 - Shortcut/white.png + white.png 0 diff --git a/resources/skins/Default/720p/InfoWindow.xml b/resources/skins/Default/720p/InfoWindow.xml index d971eff0..27045eb4 100644 --- a/resources/skins/Default/720p/InfoWindow.xml +++ b/resources/skins/Default/720p/InfoWindow.xml @@ -18,7 +18,7 @@ 100% 100% - Shortcut/white.png + white.png @@ -47,8 +47,8 @@ 25 30 30 - Controls/DialogCloseButton-focus.png - Controls/DialogCloseButton-focus.png + close.png + close.png @@ -315,8 +315,8 @@ 200 50 110 - Shortcut/white.png - Shortcut/white.png + white.png + white.png center center @@ -327,8 +327,8 @@ 200 50 110 - Shortcut/white.png - Shortcut/white.png + white.png + white.png center center @@ -339,8 +339,8 @@ 200 50 110 - Shortcut/white.png - Shortcut/white.png + white.png + white.png center center @@ -351,8 +351,8 @@ 200 50 110 - Shortcut/white.png - Shortcut/white.png + white.png + white.png center center diff --git a/resources/skins/Default/720p/NextDialog.xml b/resources/skins/Default/720p/NextDialog.xml index 4b5fbbb9..fd1e5a83 100644 --- a/resources/skins/Default/720p/NextDialog.xml +++ b/resources/skins/Default/720p/NextDialog.xml @@ -5,82 +5,60 @@ Dialog.Close(videoosd,true) + 0 + 0 + 100% - - + + - - + + - - 0 + + horizontal 15 40 - 100% - - - 0 - 100% + 0 + right + + 40 - NextDialog/background-diffuse.png + auto + font30_title + 20 + 80FFFFFF + FFFFFFFF + 80FFFFFF + 22000000 + center + center + white.png + white.png + no - + + + 40 + auto + font30_title + 20 + 80FFFFFF + FFFFFFFF + 80FFFFFF + 22000000 + center + center + white.png + white.png + no + + 0 - 0 - 100% - - - -1000 - -1000 - 1 - 1 - - - horizontal - 40 - 0 - right - - - SendClick(3012) - 40 - auto - font30_title - 20 - 80FFFFFF - FFFFFFFF - 80FFFFFF - 22000000 - center - center - NextDialog/background-diffuse.png - NextDialog/background-diffuse.png - no - - - - 40 - auto - font30_title - 20 - 80FFFFFF - FFFFFFFF - 80FFFFFF - 22000000 - center - center - NextDialog/background-diffuse.png - NextDialog/background-diffuse.png - no - - - 0 - 30 - 40 - NextDialog/background-diffuse.png - - + 30 + 40 + white.png diff --git a/resources/skins/Default/720p/NextDialogCompact.xml b/resources/skins/Default/720p/NextDialogCompact.xml index dd348317..d698b0da 100644 --- a/resources/skins/Default/720p/NextDialogCompact.xml +++ b/resources/skins/Default/720p/NextDialogCompact.xml @@ -4,85 +4,57 @@ Dialog.Close(fullscreeninfo,true) Dialog.Close(videoosd,true) - + + horizontal + 15 + 40 + 0 + right - - + + - - + + - - 0 - 15 - 50 - 100% - + + + 40 + 80 + font30_title + 10 + 80FFFFFF + FFFFFFFF + 80FFFFFF + 22000000 + center + left + NextDialog/play.png + NextDialog/play.png + no + + + + 40 + 40 + font30_title + 30 + 80FFFFFF + FFFFFFFF + 80FFFFFF + 22000000 + center + center + NextDialog/close.png + NextDialog/close.png + no + - 0 - 100% - 40 - - - - 0 - 0 - 100% - - - -1000 - -1000 - 1 - 1 - - - horizontal - 40 - 0 - right - - - SendClick(3012) - - 40 - 100 - font30_title - 12 - 80FFFFFF - FFFFFFFF - 80FFFFFF - 22000000 - center - left - NextDialog/play-fo.png - NextDialog/play-nf.png - no - - - - 40 - 40 - font30_title - 30 - 80FFFFFF - FFFFFFFF - 80FFFFFF - 22000000 - center - center - NextDialog/close-fo.png - NextDialog/close-nf.png - no - - - 0 - 20 - 40 - NextDialog/background.png - - - + 0 + 20 + 40 + NextDialog/background.png diff --git a/resources/skins/Default/720p/NextDialogExtended.xml b/resources/skins/Default/720p/NextDialogExtended.xml index 22bf4c44..54b8d906 100644 --- a/resources/skins/Default/720p/NextDialogExtended.xml +++ b/resources/skins/Default/720p/NextDialogExtended.xml @@ -6,12 +6,12 @@ - - + + - - + + 30 @@ -26,59 +26,47 @@ 180 $INFO[Window.Property(next_img)] - - 0 + + vertical + 220 + 326 + 0 0 - 100% - - -1000 - -1000 - 1 - 1 - - - vertical - 220 - 326 - 0 + + 180 + 326 0 - - - SendClick(3012) - 180 - 326 - 0 - font30_title - 20 - FFFFFFFF - FFFFFFFF - FFFFFFFF - 22000000 - top - center - NextDialog/background-play.png - NextDialog/background-diffuse.png - no - - - - 40 - 326 - font30_title - 20 - 80FFFFFF - FFFFFFFF - 80FFFFFF - 22000000 - center - center - NextDialog/background-diffuse.png - NextDialog/background-diffuse.png - no - + font30_title + 20 + FFFFFFFF + FFFFFFFF + FFFFFFFF + 22000000 + top + center + NextDialog/background-play.png + white.png + no - + + + 40 + 326 + font30_title + 20 + 80FFFFFF + FFFFFFFF + FFFFFFFF + 22000000 + center + center + white.png + white.png + no + + + 60 40 center @@ -86,12 +74,12 @@ center true 50 - FFFFFFFF - ff000000 + FFFFFFFF + FF000000 Window.Property(title) font30_title - + 40 40 center @@ -99,26 +87,25 @@ center true 50 - FFFFFFFF - ff000000 + FFFFFFFF + FF000000 Window.Property(ep_title) font20_title - + 20 - 25 + 25 auto top true right true 50 - FFFFFFFF - ff000000 + FFFFFFFF + FF000000 Player.TimeRemaining(secs),, font30_title - diff --git a/resources/skins/Default/720p/Recaptcha.xml b/resources/skins/Default/720p/Recaptcha.xml index cc552796..4168b44e 100644 --- a/resources/skins/Default/720p/Recaptcha.xml +++ b/resources/skins/Default/720p/Recaptcha.xml @@ -19,7 +19,7 @@ 510 640 45 - Shortcut/dialog-bg-solid.png + Controls/dialog-bg-solid.png 30 @@ -39,8 +39,8 @@ 110 FFFFFFFF FFFFFFFF - Controls/KeyboardKey.png - Controls/KeyboardKeyNF.png + white.png + white.png center center @@ -57,8 +57,8 @@ 110 FFFFFFFF FFFFFFFF - Controls/KeyboardKey.png - Controls/KeyboardKeyNF.png + white.png + white.png center center @@ -75,8 +75,8 @@ 110 FFFFFFFF FFFFFFFF - Controls/KeyboardKey.png - Controls/KeyboardKeyNF.png + white.png + white.png center center @@ -96,9 +96,9 @@ 75 150 150 - Controls/background-diffuse.png - Controls/background-diffuse.png - Controls/check_mark.png + white.png + white.png + Controls/check_mark.png Controls/check_mark.png 10002 10008 @@ -110,9 +110,9 @@ 225 150 150 - Controls/background-diffuse.png - Controls/background-diffuse.png - Controls/check_mark.png + white.png + white.png + Controls/check_mark.png Controls/check_mark.png 10003 10009 @@ -124,9 +124,9 @@ 375 150 150 - Controls/background-diffuse.png - Controls/background-diffuse.png - Controls/check_mark.png + white.png + white.png + Controls/check_mark.png Controls/check_mark.png 10004 10010 @@ -138,9 +138,9 @@ 75 150 150 - Controls/background-diffuse.png - Controls/background-diffuse.png - Controls/check_mark.png + white.png + white.png + Controls/check_mark.png Controls/check_mark.png 10005 10011 @@ -152,9 +152,9 @@ 225 150 150 - Controls/background-diffuse.png - Controls/background-diffuse.png - Controls/check_mark.png + white.png + white.png + Controls/check_mark.png Controls/check_mark.png 10006 10012 @@ -166,9 +166,9 @@ 375 150 150 - Controls/background-diffuse.png - Controls/background-diffuse.png - Controls/check_mark.png + white.png + white.png + Controls/check_mark.png Controls/check_mark.png 10007 10013 @@ -180,9 +180,9 @@ 75 150 150 - Controls/background-diffuse.png - Controls/background-diffuse.png - Controls/check_mark.png + white.png + white.png + Controls/check_mark.png Controls/check_mark.png 10008 10002 @@ -194,9 +194,9 @@ 225 150 150 - Controls/background-diffuse.png - Controls/background-diffuse.png - Controls/check_mark.png + white.png + white.png + Controls/check_mark.png Controls/check_mark.png 10009 10003 @@ -208,9 +208,9 @@ 375 150 150 - Controls/background-diffuse.png - Controls/background-diffuse.png - Controls/check_mark.png + white.png + white.png + Controls/check_mark.png Controls/check_mark.png 10010 10004 diff --git a/resources/skins/Default/720p/ResumePlayback.xml b/resources/skins/Default/720p/ResumePlayback.xml index 8337c989..3f6830cb 100644 --- a/resources/skins/Default/720p/ResumePlayback.xml +++ b/resources/skins/Default/720p/ResumePlayback.xml @@ -6,53 +6,45 @@ - - + - - + - 0 - 15 + 440 + 320 40 - 100% + 400 - horizontal - 40 + vertical + 80 0 - right + center - + SendClick(3012) 40 - auto + 400 font30_title 20 - 80FFFFFF - FFFFFFFF - 80FFFFFF - 22000000 + FFFFFFFF center center - NextDialog/background-diffuse.png - NextDialog/background-diffuse.png + white.png + white.png no - + 40 - auto + 400 font30_title 20 - 80FFFFFF - FFFFFFFF - 80FFFFFF - 22000000 + FFFFFFFF center center - NextDialog/background-diffuse.png - NextDialog/background-diffuse.png + white.png + white.png no diff --git a/resources/skins/Default/720p/ShortCutMenu.xml b/resources/skins/Default/720p/ShortCutMenu.xml index dfb2a0eb..bc93587d 100644 --- a/resources/skins/Default/720p/ShortCutMenu.xml +++ b/resources/skins/Default/720p/ShortCutMenu.xml @@ -12,8 +12,8 @@ 0 100% 100% - Shortcut/white.png - Shortcut/white.png + white.png + white.png WindowOpen WindowClose Action(close) @@ -39,9 +39,9 @@ 219 1100 10 - Shortcut/white.png - Shortcut/white.png - Shortcut/white.png + white.png + white.png + white.png false horizontal 32500 @@ -50,7 +50,7 @@ 1100 218 - Shortcut/white.png + white.png -130 @@ -78,7 +78,7 @@ 1 220 218 - Shortcut/white.png + white.png 0 diff --git a/resources/skins/Default/media/Controls/DialogCloseButton.png b/resources/skins/Default/media/Controls/DialogCloseButton.png deleted file mode 100644 index cd9e52f0..00000000 Binary files a/resources/skins/Default/media/Controls/DialogCloseButton.png and /dev/null differ diff --git a/resources/skins/Default/media/Controls/KeyboardKey.png b/resources/skins/Default/media/Controls/KeyboardKey.png deleted file mode 100644 index eaba2e98..00000000 Binary files a/resources/skins/Default/media/Controls/KeyboardKey.png and /dev/null differ diff --git a/resources/skins/Default/media/Controls/KeyboardKeyNF.png b/resources/skins/Default/media/Controls/KeyboardKeyNF.png deleted file mode 100644 index 877b11b6..00000000 Binary files a/resources/skins/Default/media/Controls/KeyboardKeyNF.png and /dev/null differ diff --git a/resources/skins/Default/media/Controls/KeyboardKeyWhite.png b/resources/skins/Default/media/Controls/KeyboardKeyWhite.png deleted file mode 100644 index 6a34a4b8..00000000 Binary files a/resources/skins/Default/media/Controls/KeyboardKeyWhite.png and /dev/null differ diff --git a/resources/skins/Default/media/Controls/ScrollBack.png b/resources/skins/Default/media/Controls/ScrollBack.png deleted file mode 100644 index 07f88c5c..00000000 Binary files a/resources/skins/Default/media/Controls/ScrollBack.png and /dev/null differ diff --git a/resources/skins/Default/media/Controls/ScrollBar.png b/resources/skins/Default/media/Controls/ScrollBar.png deleted file mode 100644 index ce738d65..00000000 Binary files a/resources/skins/Default/media/Controls/ScrollBar.png and /dev/null differ diff --git a/resources/skins/Default/media/Controls/background-diffuse.png b/resources/skins/Default/media/Controls/background-diffuse.png deleted file mode 100644 index f6368603..00000000 Binary files a/resources/skins/Default/media/Controls/background-diffuse.png and /dev/null differ diff --git a/resources/skins/Default/media/Controls/check_mark.png b/resources/skins/Default/media/Controls/check_mark.png index 76b618bd..c94dd025 100644 Binary files a/resources/skins/Default/media/Controls/check_mark.png and b/resources/skins/Default/media/Controls/check_mark.png differ diff --git a/resources/skins/Default/media/Shortcut/dialog-bg-solid.png b/resources/skins/Default/media/Controls/dialog-bg-solid.png similarity index 100% rename from resources/skins/Default/media/Shortcut/dialog-bg-solid.png rename to resources/skins/Default/media/Controls/dialog-bg-solid.png diff --git a/resources/skins/Default/media/Controls/dialogheader.png b/resources/skins/Default/media/Controls/dialogheader.png deleted file mode 100644 index 25f5333f..00000000 Binary files a/resources/skins/Default/media/Controls/dialogheader.png and /dev/null differ diff --git a/resources/skins/Default/media/Controls/spinDown-Focus.png b/resources/skins/Default/media/Controls/spinDown-Focus.png deleted file mode 100644 index 31d02dae..00000000 Binary files a/resources/skins/Default/media/Controls/spinDown-Focus.png and /dev/null differ diff --git a/resources/skins/Default/media/Controls/spinDown-noFocus.png b/resources/skins/Default/media/Controls/spinDown-noFocus.png deleted file mode 100644 index 4987fbbc..00000000 Binary files a/resources/skins/Default/media/Controls/spinDown-noFocus.png and /dev/null differ diff --git a/resources/skins/Default/media/Controls/spinUp-Focus.png b/resources/skins/Default/media/Controls/spinUp-Focus.png deleted file mode 100644 index 0ce1fcc5..00000000 Binary files a/resources/skins/Default/media/Controls/spinUp-Focus.png and /dev/null differ diff --git a/resources/skins/Default/media/Controls/spinUp-noFocus.png b/resources/skins/Default/media/Controls/spinUp-noFocus.png deleted file mode 100644 index cbbc1b70..00000000 Binary files a/resources/skins/Default/media/Controls/spinUp-noFocus.png and /dev/null differ diff --git a/resources/skins/Default/media/NextDialog/background-diffuse.png b/resources/skins/Default/media/NextDialog/background-diffuse.png deleted file mode 100644 index f6368603..00000000 Binary files a/resources/skins/Default/media/NextDialog/background-diffuse.png and /dev/null differ diff --git a/resources/skins/Default/media/NextDialog/background-play.png b/resources/skins/Default/media/NextDialog/background-play.png index f5a4b8c1..063d94a9 100644 Binary files a/resources/skins/Default/media/NextDialog/background-play.png and b/resources/skins/Default/media/NextDialog/background-play.png differ diff --git a/resources/skins/Default/media/NextDialog/close-nf.png b/resources/skins/Default/media/NextDialog/close-nf.png deleted file mode 100644 index aa61c1eb..00000000 Binary files a/resources/skins/Default/media/NextDialog/close-nf.png and /dev/null differ diff --git a/resources/skins/Default/media/NextDialog/close-fo.png b/resources/skins/Default/media/NextDialog/close.png similarity index 100% rename from resources/skins/Default/media/NextDialog/close-fo.png rename to resources/skins/Default/media/NextDialog/close.png diff --git a/resources/skins/Default/media/NextDialog/play-fo.png b/resources/skins/Default/media/NextDialog/play-fo.png deleted file mode 100644 index 1f82754c..00000000 Binary files a/resources/skins/Default/media/NextDialog/play-fo.png and /dev/null differ diff --git a/resources/skins/Default/media/NextDialog/play-nf.png b/resources/skins/Default/media/NextDialog/play-nf.png deleted file mode 100644 index 64531f6b..00000000 Binary files a/resources/skins/Default/media/NextDialog/play-nf.png and /dev/null differ diff --git a/resources/skins/Default/media/NextDialog/play.png b/resources/skins/Default/media/NextDialog/play.png new file mode 100644 index 00000000..12aedfa5 Binary files /dev/null and b/resources/skins/Default/media/NextDialog/play.png differ diff --git a/resources/skins/Default/media/Controls/DialogCloseButton-focus.png b/resources/skins/Default/media/close.png similarity index 100% rename from resources/skins/Default/media/Controls/DialogCloseButton-focus.png rename to resources/skins/Default/media/close.png diff --git a/resources/skins/Default/media/white.png b/resources/skins/Default/media/white.png new file mode 100644 index 00000000..528c66f6 Binary files /dev/null and b/resources/skins/Default/media/white.png differ diff --git a/specials/autoplay.py b/specials/autoplay.py index 3f934dd3..8d0b7437 100644 --- a/specials/autoplay.py +++ b/specials/autoplay.py @@ -28,6 +28,7 @@ def start(itemlist, item): :param item: item (the main item of the channel) :return: try to auto-reproduce, in case of failure it returns the itemlist that it received in the beginning ''' + from inspect import stack if item.global_search: return itemlist logger.info() @@ -111,6 +112,7 @@ def start(itemlist, item): # if the server and the quality are not in the favorites lists or the url is repeated, we discard the item if item.server.lower() not in favorite_servers or item.quality.lower() not in favorite_quality or item.url in url_list_valid: item.type_b = True + item.play_from = base_item.play_from b_dict['videoitem']= item autoplay_b.append(b_dict) continue @@ -122,6 +124,7 @@ def start(itemlist, item): # if the server is not in the favorites list or the url is repeated, we discard the item if item.server.lower() not in favorite_servers or item.url in url_list_valid: item.type_b = True + item.play_from = base_item.play_from b_dict['videoitem'] = item autoplay_b.append(b_dict) continue @@ -132,6 +135,7 @@ def start(itemlist, item): # if the quality is not in the favorites list or the url is repeated, we discard the item if item.quality.lower() not in favorite_quality or item.url in url_list_valid: item.type_b = True + item.play_from = base_item.play_from b_dict['videoitem'] = item autoplay_b.append(b_dict) continue @@ -140,13 +144,14 @@ def start(itemlist, item): else: # Do not order # if the url is repeated, we discard the item + item.play_from = base_item.play_from if item.url in url_list_valid: continue # If the item reaches here we add it to the list of valid urls and to autoplay_list url_list_valid.append(item.url) item.plan_b=True - + item.play_from = base_item.play_from autoplay_elem['videoitem'] = item autoplay_list.append(autoplay_elem) @@ -225,13 +230,11 @@ def start(itemlist, item): else: videoitem = resolved_item[0] # If not directly reproduce and mark as seen - # Check if the item comes from the video library try: - if base_item.contentChannel == 'videolibrary': + if base_item.contentChannel == 'videolibrary' or base_item.nfo: # Mark as seen from platformcode import xbmc_videolibrary - xbmc_videolibrary.mark_auto_as_watched(base_item) # Fill the video with the data of the main item and play play_item = base_item.clone(url=videoitem) platformtools.play_video(play_item.url, autoplay=True) diff --git a/specials/nextep.py b/specials/nextep.py deleted file mode 100644 index 4b496d28..00000000 --- a/specials/nextep.py +++ /dev/null @@ -1,207 +0,0 @@ -# -*- coding: utf-8 -*- -import xbmc, xbmcgui, os -from platformcode import config, platformtools -from time import time, sleep -from core import jsontools, filetools -from core.support import log, dbg -from core.item import Item -from platformcode.launcher import play_from_library - -import sys -if sys.version_info[0] >= 3: - from concurrent import futures -else: - from concurrent_py2 import futures - -next_dialogs = ['NextDialog.xml', 'NextDialogExtended.xml', 'NextDialogCompact.xml'] -next_ep_type = config.get_setting('next_ep_type') - -# compatibility with previous version -if type(next_ep_type) == bool: - ND = 'NextDialogCompact.xml' if config.get_setting('next_ep_type') else 'NextDialog.xml' -else: - ND = next_dialogs[next_ep_type] - -def check(item): - return True if config.get_setting('next_ep') > 0 and item.contentType != 'movie' else False - - -def return_item(item): - log() - with futures.ThreadPoolExecutor() as executor: - future = executor.submit(next_ep, item) - item = future.result() - return item - -def run(item): - log() - with futures.ThreadPoolExecutor() as executor: - future = executor.submit(next_ep, item) - item = future.result() - if item.next_ep: - return play_from_library(item) - - -def videolibrary(item): - from threading import Thread - item.videolibrary = True - Thread(target=next_ep, args=[item]).start() - - -def next_ep(item): - log() - - condition = config.get_setting('next_ep') - item.next_ep = False - item.show_server = True - - VL = True if item.videolibrary else False - - time_over = False - time_limit = time() + 30 - time_setting = config.get_setting('next_ep_seconds') - TimeFromEnd = time_setting - - # wait until the video plays - while not platformtools.is_playing() and time() < time_limit: - sleep(1) - - while platformtools.is_playing() and not time_over: - try: - Total = xbmc.Player().getTotalTime() - Actual = xbmc.Player().getTime() - Difference = Total - Actual - if Total > TimeFromEnd >= Difference: - time_over = True - except: - break - - if time_over: - if condition == 1: # hide server afther x second - item.show_server = False - elif condition == 2: # 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] - log('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= os.sep + filetools.join(base_path, next_file)) - - global INFO - INFO = filetools.join(path, next_file.replace("strm", "nfo")) - log('Next Info:',INFO) - - nextDialog = NextDialog(ND, config.get_runtime_path()) - nextDialog.show() - while platformtools.is_playing() and not nextDialog.is_still_watching(): - xbmc.sleep(100) - pass - - nextDialog.close() - log('Next Episode:', nextDialog.stillwatching) - - if nextDialog.stillwatching or nextDialog.continuewatching: - item.next_ep = True - xbmc.Player().stop() - if VL: - sleep(1) - xbmc.executebuiltin('Action(Back)') - sleep(0.5) - return play_from_library(item) - else: - item.show_server = False - if VL: - sleep(1) - xbmc.executebuiltin('Action(Back)') - sleep(0.5) - return None - - return item - - -class NextDialog(xbmcgui.WindowXMLDialog): - item = None - cancel = False - stillwatching = False - continuewatching = True - - def __init__(self, *args, **kwargs): - log() - 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) - info = info["infoLabels"] - self.setProperty("title", info["tvshowtitle"]) - self.setProperty("ep_title", "%dx%02d - %s" % (info["season"], info["episode"], info["title"])) - if "episodio_imagen" in info: - img = info["episodio_imagen"] - else: - img = filetools.join(config.get_runtime_path(), "resources", "noimage.png") - self.setProperty("next_img", img) - - def set_still_watching(self, stillwatching): - self.stillwatching = stillwatching - - def set_continue_watching(self, continuewatching): - self.continuewatching = continuewatching - - def is_still_watching(self): - return self.stillwatching - - 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_still_watching(True) - self.set_continue_watching(False) - self.close() - elif controlId == 3013: # Cancel - self.set_continue_watching(False) - self.close() - - def onAction(self, action): - log() - if action in self.action_exitkeys_id: - self.set_continue_watching(False) - self.close() diff --git a/specials/videolibrary.py b/specials/videolibrary.py index c9f8c192..27a2790e 100644 --- a/specials/videolibrary.py +++ b/specials/videolibrary.py @@ -582,6 +582,7 @@ def findvideos(item): # We run find_videos, from the channel or common item_json.contentChannel = 'videolibrary' + item_json.play_from = item.play_from if hasattr(channel, 'findvideos'): from core import servertools if item_json.videolibray_emergency_urls: @@ -629,10 +630,7 @@ def findvideos(item): if autoplay.play_multi_channel(item, itemlist): # hideserver return [] - from inspect import stack - from specials import nextep - if nextep.check(item) and stack()[1][3] == 'run': - nextep.videolibrary(item) + add_download_items(item, itemlist) return itemlist