Fix Episodio Successivo

This commit is contained in:
Alhaziel01
2021-07-01 19:48:26 +02:00
parent 1e2f88c47a
commit c86cdab9da
8 changed files with 53 additions and 74 deletions

View File

@@ -458,12 +458,14 @@ def play_from_library(item):
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 xbmc.getCondVisibility('Window.IsMedia') and not item.window_type == 0:
if item.contentType == 'episode':
it = videolibrarydb.videolibrarydb[item.contentType][item.videolibrary_id]['{}x{:02d}'.format(item.infoLabels['season'], item.infoLabels['episode'])]
it = videolibrarydb.videolibrarydb[item.contentType][item.videolibrary_id]['{}x{:02d}'.format(item.infoLabels['season'], item.infoLabels['episode'])]['item']
else:
it = videolibrarydb.videolibrarydb[item.contentType][item.videolibrary_id]['item']
xbmc.executebuiltin("Container.Update(" + sys.argv[0] + "?" + it.tourl() + ")")
it.from_library = True
xbmc.executebuiltin("Container.Update(" + sys.argv[0] + "?" + it.tourl() + ")")
videolibrarydb.videolibrarydb.close()
else:
item.window = True
return videolibrary.findvideos(item)

View File

@@ -366,7 +366,7 @@ def render_items(itemlist, parent_item):
title = item.title
episode = ''
if parent_item.channel not in ['videolibrary'] and title[:1] not in ['[', '']:
if (parent_item.channel not in ['videolibrary'] or item.server) and title[:1] not in ['[', '']:
if type(item.contentSeason) == int and type(item.contentEpisodeNumber) == int and not item.onlyep:
episode = '{}x{:02d}'.format(item.contentSeason, item.contentEpisodeNumber)
elif type(item.contentEpisodeNumber) == int:
@@ -377,7 +377,7 @@ def render_items(itemlist, parent_item):
if episode: title = '{}. {}'.format(episode, title)
if item.title2: title = '{} - {}'.format(title, item.title2)
if not config.get_setting('format_title'):
if config.get_setting('format_title'):
server = typo(servertools.get_server_parameters(item.server).get('name', item.server.capitalize()), '_ []') if item.server else ''
quality = typo(item.quality, '_ [] color kod') if item.quality else ''
lang = typo(item.contentLanguage, '_ [] color kod') if item.contentLanguage else ''
@@ -1442,7 +1442,7 @@ def set_player(item, xlistitem, mediaurl, view, strm):
xbmc_player.setSubtitles(item.subtitle)
# if it is a video library file send to mark as seen
if strm or item.strm_path: item.options['strm'] = True
if strm or item.strm_path or item.from_library: item.options['strm'] = True
# if player_mode == 1: item.options['continue'] = True
from platformcode import xbmc_videolibrary
xbmc_videolibrary.mark_auto_as_watched(item)
@@ -1460,16 +1460,13 @@ def add_next_to_playlist(item):
from core import filetools, videolibrarytools
from platformcode import xbmc_videolibrary
def add_to_playlist(item):
if item.contentType != 'movie' and item.strm_path:
if item.contentType != 'movie':
next= xbmc_videolibrary.next_ep(item)
if next:
next.back = True
nfo_path = filetools.join(config.get_videolibrary_path(), config.get_setting("folder_tvshows"), next.strm_path.replace('strm','nfo'))
if nfo_path and filetools.isfile(nfo_path):
head_nfo, item_nfo = videolibrarytools.read_nfo(nfo_path)
nextItem = xbmcgui.ListItem(path=item_nfo.url)
nextItem.setArt({"thumb": item_nfo.contentThumbnail if item_nfo.contentThumbnail else item_nfo.thumbnail})
set_infolabels(nextItem, item_nfo, True)
nextItem = xbmcgui.ListItem(path=next.url)
nextItem.setArt({"thumb": next.contentThumbnail if next.contentThumbnail else next.thumbnail})
set_infolabels(nextItem, next, True)
nexturl = "plugin://plugin.video.kod/?" + next.tourl()
playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
playlist.add(nexturl, nextItem)
@@ -1861,7 +1858,16 @@ def serverwindow(item, itemlist):
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'})
# format Title
if self.item.contentSeason and self.item.contentEpisodeNumber:
title = '{}x{:02d}. {}'.format(self.item.contentSeason, self.item.contentEpisodeNumber, self.item.contentTitle)
elif self.item.contentEpisodeNumber:
title = '{:02d}. {}'.format(self.item.contentEpisodeNumber, self.item.contentTitle)
else:
title = self.item.contentTitle
it.setProperties({'name': 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()

View File

@@ -15,7 +15,7 @@ if PY3:
else:
import urllib2 # Usamos el nativo de PY2 que es más rápido
from core import filetools, jsontools, support
from core import filetools, jsontools, support, videolibrarydb
from platformcode import config, logger, platformtools
from core import scrapertools
from xml.dom import minidom
@@ -75,8 +75,8 @@ def mark_auto_as_watched(item):
break
# check for next Episode
if next_episode and sync and time_from_end >= difference:
nextdialog = NextDialog(ND, config.get_runtime_path())
if next_episode and marked and time_from_end >= difference:
nextdialog = NextDialog(ND, config.get_runtime_path(), item=next_episode)
while platformtools.is_playing() and not nextdialog.is_exit():
xbmc.sleep(100)
if nextdialog.continuewatching:
@@ -106,8 +106,8 @@ def mark_auto_as_watched(item):
videolibrary.mark_content_as_watched(item)
if next_episode and next_episode.next_ep and config.get_setting('next_ep') == 1:
from platformcode.launcher import play_from_library
play_from_library(next_episode)
from platformcode.launcher import run
run(next_episode)
# db need to be closed when not used, it will cause freezes
from core import db
@@ -1354,48 +1354,20 @@ def ask_set_content(silent=False):
def next_ep(item):
from core.item import Item
logger.debug()
item.next_ep = False
logger.debug(item)
episode = '{}x{:02d}'.format(item.contentSeason, item.contentEpisodeNumber)
episodes = sorted(videolibrarydb.videolibrarydb['episode'][item.videolibrary_id].items())
videolibrarydb.videolibrarydb.close()
# 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.debug('Next File:' + str(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),
window = item.window)
global INFO
INFO = filetools.join(path, next_file.replace("strm", "nfo"))
nextIndex = [k for k, v in episodes].index(episode) + 1
if nextIndex == 0 or nextIndex == len(episodes):
it = None
else:
item=None
it = episodes[nextIndex][1]['item']
if item.from_library: it.action = 'play_from_library'
logger.debug('Next File:' + '{}x{:02d}. {}'.format(it.contentSeason, it.contentEpisodeNumber, it.title))
return item
return it
class NextDialog(xbmcgui.WindowXMLDialog):
item = None
@@ -1408,19 +1380,13 @@ class NextDialog(xbmcgui.WindowXMLDialog):
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"]
info = kwargs.get('item').infoLabels
if "fanart" in info: img = info["fanart"]
elif "thumbnail" in info: img = info["thumbnail"]
else: img = filetools.join(config.get_runtime_path(), "resources", "noimage.png")
self.setProperty("next_img", img)
self.setProperty("title", info["tvshowtitle"])
self.setProperty("ep_title", "%dx%02d - %s" % (info["season"], info["episode"], info["title"]))
self.setProperty("ep_title", "{}x{:02d}. {}".format(info["season"], info["episode"], info["title"]))
self.show()
def set_exit(self, EXIT):