- Unico Tread per:

- Segna come visto
  - Episodio successivo
- Rimosse impostazioni nascondi server (non più necessarie)
- Ottimizzazione grafica finestre
This commit is contained in:
Alhaziel01
2020-06-18 17:13:44 +02:00
parent 3770274912
commit d0c3294314
43 changed files with 557 additions and 701 deletions
+7 -4
View File
@@ -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)
-207
View File
@@ -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()
+2 -4
View File
@@ -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