KoD 1.5.1
- corretta e migliorata la nuova ricerca globale\n- salvataggio punto di visione basato sull'id tmdb (disponibile su qualunque canale / server anche senza salvare in videoteca)\n- alcuni fix e migliore\n
This commit is contained in:
@@ -1,621 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import xbmc, xbmcgui, sys, channelselector, time
|
||||
from core.support import dbg, typo, tmdb
|
||||
from core.item import Item
|
||||
from core import channeltools, servertools, scrapertools
|
||||
from platformcode import platformtools, config, logger
|
||||
from platformcode.launcher import run
|
||||
from threading import Thread
|
||||
|
||||
if sys.version_info[0] >= 3: from concurrent import futures
|
||||
else: from concurrent_py2 import futures
|
||||
|
||||
info_language = ["de", "en", "es", "fr", "it", "pt"] # from videolibrary.json
|
||||
def_lang = info_language[config.get_setting("info_language", "videolibrary")]
|
||||
|
||||
|
||||
def busy(state):
|
||||
if state: xbmc.executebuiltin('ActivateWindow(busydialognocancel)')
|
||||
else: xbmc.executebuiltin('Dialog.Close(busydialognocancel)')
|
||||
|
||||
def set_workers():
|
||||
workers = config.get_setting('thread_number') if config.get_setting('thread_number') > 0 else None
|
||||
return workers
|
||||
|
||||
def Search(item):
|
||||
xbmc.executebuiltin('Dialog.Close(all,true)')
|
||||
SearchWindow('GlobalSearch.xml', config.get_runtime_path()).start(item)
|
||||
xbmc.sleep(600)
|
||||
|
||||
# Actions
|
||||
LEFT = 1
|
||||
RIGHT = 2
|
||||
UP = 3
|
||||
DOWN = 4
|
||||
ENTER = 7
|
||||
EXIT = 10
|
||||
BACKSPACE = 92
|
||||
SWIPEUP = 531
|
||||
CONTEXT = 117
|
||||
|
||||
# Container
|
||||
SEARCH = 1
|
||||
EPISODES = 2
|
||||
SERVERS = 3
|
||||
NORESULTS = 4
|
||||
LOADING = 5
|
||||
|
||||
# Search
|
||||
MAINTITLE = 100
|
||||
CHANNELS = 101
|
||||
RESULTS = 102
|
||||
|
||||
PROGRESS = 500
|
||||
COUNT = 501
|
||||
MENU = 502
|
||||
BACK = 503
|
||||
CLOSE = 504
|
||||
QUALITYTAG = 505
|
||||
|
||||
# Servers
|
||||
EPISODESLIST = 200
|
||||
SERVERLIST = 300
|
||||
|
||||
class SearchWindow(xbmcgui.WindowXML):
|
||||
def start(self, item):
|
||||
logger.debug()
|
||||
self.exit = False
|
||||
self.item = item
|
||||
self.lastSearch()
|
||||
if not self.item.text: return
|
||||
self.type = self.item.mode
|
||||
self.channels = []
|
||||
self.find = []
|
||||
self.persons = []
|
||||
self.episodes = []
|
||||
self.servers = []
|
||||
self.results = {}
|
||||
self.channelsList = self.get_channels()
|
||||
self.focus = SEARCH
|
||||
self.process = True
|
||||
self.page = 1
|
||||
self.moduleDict = {}
|
||||
self.searchActions = []
|
||||
self.thread = None
|
||||
self.doModal()
|
||||
|
||||
def lastSearch(self):
|
||||
logger.debug()
|
||||
if not self.item.text:
|
||||
if config.get_setting('last_search'): last_search = channeltools.get_channel_setting('Last_searched', 'search', '')
|
||||
else: last_search = ''
|
||||
if not self.item.text: self.item.text = platformtools.dialog_input(default=last_search, heading='')
|
||||
if self.item.text: channeltools.set_channel_setting('Last_searched', self.item.text, 'search')
|
||||
|
||||
def select(self):
|
||||
logger.debug()
|
||||
self.PROGRESS.setVisible(False)
|
||||
items = []
|
||||
if self.persons:
|
||||
tmdb_info = tmdb.discovery(self.item, dict_=self.item.discovery)
|
||||
results = tmdb_info.results.get('cast',[])
|
||||
else:
|
||||
tmdb_info = tmdb.Tmdb(texto_buscado=self.item.text, tipo=self.item.mode.replace('show', ''))
|
||||
results = tmdb_info.results
|
||||
|
||||
for result in results:
|
||||
logger.info(result)
|
||||
result = tmdb_info.get_infoLabels(result, origen=result)
|
||||
movie = result.get('title','')
|
||||
tvshow = result.get('name','')
|
||||
title = tvshow if tvshow else movie
|
||||
result['mode'] = 'tvshow' if tvshow else 'movie'
|
||||
self.find.append(result)
|
||||
thumb = 'Infoplus/' + result['mode'].replace('show','') + '.png'
|
||||
it = xbmcgui.ListItem(title)
|
||||
it.setProperty('thumb', result.get('thumbnail', thumb))
|
||||
it.setProperty('fanart', result.get('fanart',''))
|
||||
it.setProperty('plot', result.get('overview', ''))
|
||||
it.setProperty('search','search')
|
||||
year = result.get('release_date','')
|
||||
if year: it.setProperty('year','[' + year.split('/')[-1] + ']')
|
||||
else:
|
||||
year = result.get('first_air_date','')
|
||||
if year: it.setProperty('year','[' + year.split('-')[0] + ']')
|
||||
items.append(it)
|
||||
|
||||
if items:
|
||||
self.RESULTS.reset()
|
||||
self.RESULTS.addItems(items)
|
||||
self.setFocusId(RESULTS)
|
||||
else:
|
||||
self.NORESULTS.setVisible(True)
|
||||
|
||||
def actors(self):
|
||||
logger.debug()
|
||||
self.PROGRESS.setVisible(False)
|
||||
items = []
|
||||
|
||||
dict_ = {'url': 'search/person', 'language': def_lang, 'query': self.item.text, 'page':self.page}
|
||||
prof = {'Acting': 'Actor', 'Directing': 'Director', 'Production': 'Productor'}
|
||||
plot = ''
|
||||
self.item.search_type = 'person'
|
||||
tmdb_inf = tmdb.discovery(self.item, dict_=dict_)
|
||||
results = tmdb_inf.results
|
||||
|
||||
for elem in results:
|
||||
name = elem.get('name', '')
|
||||
if not name: continue
|
||||
rol = elem.get('known_for_department', '')
|
||||
rol = prof.get(rol, rol)
|
||||
know_for = elem.get('known_for', '')
|
||||
cast_id = elem.get('id', '')
|
||||
if know_for:
|
||||
t_k = know_for[0].get('title', '')
|
||||
if t_k: plot = '%s in %s' % (rol, t_k)
|
||||
|
||||
t = elem.get('profile_path', '')
|
||||
if t: thumb = 'https://image.tmdb.org/t/p/original' + t
|
||||
else : thumb = 'Infoplus/no_photo.png'
|
||||
|
||||
discovery = {'url': 'person/%s/combined_credits' % cast_id, 'page': '1', 'sort_by': 'primary_release_date.desc', 'language': def_lang}
|
||||
self.persons.append(discovery)
|
||||
it = xbmcgui.ListItem(name)
|
||||
it.setProperty('thumb', thumb)
|
||||
it.setProperty('plot', plot)
|
||||
it.setProperty('search','persons')
|
||||
items.append(it)
|
||||
if len(results) > 19:
|
||||
it = xbmcgui.ListItem(config.get_localized_string(70006))
|
||||
it.setProperty('thumb', 'Infoplus/next_focus.png')
|
||||
it.setProperty('search','next')
|
||||
items.append(it)
|
||||
if self.page > 1:
|
||||
it = xbmcgui.ListItem(config.get_localized_string(70005))
|
||||
it.setProperty('thumb', 'Infoplus/previous_focus.png')
|
||||
it.setProperty('search','previous')
|
||||
items.insert(0, it)
|
||||
|
||||
if items:
|
||||
self.RESULTS.reset()
|
||||
self.RESULTS.addItems(items)
|
||||
self.setFocusId(RESULTS)
|
||||
else:
|
||||
self.NORESULTS.setVisible(True)
|
||||
|
||||
def get_channels(self):
|
||||
logger.debug()
|
||||
channels_list = []
|
||||
all_channels = channelselector.filterchannels('all')
|
||||
|
||||
for ch in all_channels:
|
||||
channel = ch.channel
|
||||
ch_param = channeltools.get_channel_parameters(channel)
|
||||
if not ch_param.get("active", False):
|
||||
continue
|
||||
list_cat = ch_param.get("categories", [])
|
||||
|
||||
if not ch_param.get("include_in_global_search", False):
|
||||
continue
|
||||
|
||||
if 'anime' in list_cat:
|
||||
n = list_cat.index('anime')
|
||||
list_cat[n] = 'tvshow'
|
||||
|
||||
if self.item.mode == 'all' or self.item.type in list_cat:
|
||||
if config.get_setting("include_in_global_search", channel) and ch_param.get("active", False):
|
||||
channels_list.append(channel)
|
||||
|
||||
logger.debug('search in channels:',channels_list)
|
||||
|
||||
return channels_list
|
||||
|
||||
def getModule(self, channel):
|
||||
logger.debug()
|
||||
try:
|
||||
module = __import__('channels.%s' % channel, fromlist=["channels.%s" % channel])
|
||||
mainlist = getattr(module, 'mainlist')(Item(channel=channel, global_search=True))
|
||||
action = [elem for elem in mainlist if elem.action == "search" and (self.item.mode == 'all' or elem.contentType in [self.item.mode, 'undefined'])]
|
||||
return module, action
|
||||
except:
|
||||
import traceback
|
||||
logger.error('error importing/getting search items of ' + channel)
|
||||
logger.error(traceback.format_exc())
|
||||
return None, None
|
||||
|
||||
def search(self):
|
||||
count = 0
|
||||
self.count = 0
|
||||
self.LOADING.setVisible(True)
|
||||
with futures.ThreadPoolExecutor() as executor:
|
||||
results = []
|
||||
for channel in self.channelsList:
|
||||
if self.exit: return
|
||||
results.append(executor.submit(self.getModule, channel))
|
||||
|
||||
for res in futures.as_completed(results):
|
||||
if self.exit: return
|
||||
module, action = res.result()
|
||||
if module and action:
|
||||
channel = action[0].channel
|
||||
self.moduleDict[channel] = module
|
||||
self.searchActions += action
|
||||
count += 1
|
||||
percent = (float(count) / len(self.channelsList)) * 100
|
||||
self.PROGRESS.setPercent(percent)
|
||||
self.COUNT.setText('%s/%s' % (count, len(self.channelsList)))
|
||||
self.channelsList = []
|
||||
|
||||
with futures.ThreadPoolExecutor(max_workers=set_workers()) as executor:
|
||||
for searchAction in self.searchActions:
|
||||
if self.exit: return
|
||||
executor.submit(self.get_channel_results, self.item, self.moduleDict, searchAction)
|
||||
self.moduleDict = {}
|
||||
self.searchActions = []
|
||||
|
||||
def get_channel_results(self, item, module_dict, search_action):
|
||||
logger.debug()
|
||||
channel = search_action.channel
|
||||
results = []
|
||||
valid = []
|
||||
other = []
|
||||
module = module_dict[channel]
|
||||
searched_id = item.infoLabels['tmdb_id']
|
||||
|
||||
try:
|
||||
results.extend(module.search(search_action, item.text))
|
||||
if len(results) == 1:
|
||||
if not results[0].action or config.get_localized_string(70006).lower() in results[0].title.lower():
|
||||
results = []
|
||||
|
||||
if self.item.mode != 'all':
|
||||
for elem in results:
|
||||
if self.exit:
|
||||
return
|
||||
if not elem.infoLabels.get('year', ""):
|
||||
elem.infoLabels['year'] = '-'
|
||||
tmdb.set_infoLabels_item(elem)
|
||||
if elem.infoLabels['tmdb_id'] == searched_id:
|
||||
elem.from_channel = channel
|
||||
elem.verified ='ok.png'
|
||||
valid.append(elem)
|
||||
else:
|
||||
other.append(elem)
|
||||
except:
|
||||
pass
|
||||
|
||||
self.count += 1
|
||||
if self.item.mode == 'all': self.update(channel, results)
|
||||
else: self.update(channel, valid + other)
|
||||
|
||||
def makeItem(self, item):
|
||||
logger.debug()
|
||||
thumb = item.thumbnail if item.thumbnail else 'Infoplus/' + item.contentType.replace('show','') + 'png'
|
||||
logger.info('THUMB', thumb)
|
||||
it = xbmcgui.ListItem(item.title)
|
||||
it.setProperty('year', '[' + str(item.year if item.year else item.infoLabels.get('year','')) + ']')
|
||||
it.setProperty('thumb', thumb)
|
||||
it.setProperty('fanart', item.fanart)
|
||||
it.setProperty('plot', item.plot)
|
||||
it.setProperty('verified', item.verified)
|
||||
if item.server:
|
||||
color = scrapertools.find_single_match(item.alive, r'(FF[^\]]+)')
|
||||
it.setProperty('channel', channeltools.get_channel_parameters(item.channel).get('title',''))
|
||||
it.setProperty('thumb', "https://raw.githubusercontent.com/kodiondemand/media/master/resources/servers/%s.png" % item.server.lower())
|
||||
it.setProperty('servername', servertools.get_server_parameters(item.server.lower()).get('name',item.server))
|
||||
it.setProperty('color', color if color else 'FF0082C2')
|
||||
return it
|
||||
|
||||
def update(self, channel, results):
|
||||
if self.exit:
|
||||
return
|
||||
logger.debug('Search on channel', channel)
|
||||
if results:
|
||||
channelParams = channeltools.get_channel_parameters(channel)
|
||||
name = channelParams['title']
|
||||
if name not in self.results:
|
||||
self.results[name] = [results, len(self.channels)]
|
||||
item = xbmcgui.ListItem(name)
|
||||
item.setProperty('thumb', channelParams['thumbnail'])
|
||||
item.setProperty('position', '0')
|
||||
item.setProperty('results', str(len(results)))
|
||||
item.setProperty('verified', results[0].verified)
|
||||
self.channels.append(item)
|
||||
else:
|
||||
self.results[name].append([results, len(self.channels)])
|
||||
self.channels[int(self.results[name][1])].setProperty('results', str(len(results)))
|
||||
pos = self.CHANNELS.getSelectedPosition()
|
||||
self.CHANNELS.reset()
|
||||
self.CHANNELS.addItems(self.channels)
|
||||
self.CHANNELS.selectItem(pos)
|
||||
if len(self.channels) == 1:
|
||||
self.setFocusId(CHANNELS)
|
||||
items = []
|
||||
for result in self.results[name][0]:
|
||||
items.append(self.makeItem(result))
|
||||
self.RESULTS.reset()
|
||||
self.RESULTS.addItems(items)
|
||||
percent = (float(self.count) / len(self.searchActions)) * 100
|
||||
self.LOADING.setVisible(False)
|
||||
self.PROGRESS.setPercent(percent)
|
||||
self.COUNT.setText('%s/%s [%s"]' % (self.count, len(self.searchActions), int(time.time() - self.time) ))
|
||||
if percent == 100 and not self.results:
|
||||
self.PROGRESS.setVisible(False)
|
||||
self.NORESULTS.setVisible(True)
|
||||
|
||||
def onInit(self):
|
||||
self.time = time.time()
|
||||
|
||||
# collect controls
|
||||
self.CHANNELS = self.getControl(CHANNELS)
|
||||
self.RESULTS = self.getControl(RESULTS)
|
||||
self.PROGRESS = self.getControl(PROGRESS)
|
||||
self.COUNT = self.getControl(COUNT)
|
||||
self.MAINTITLE = self.getControl(MAINTITLE)
|
||||
self.MAINTITLE.setText(typo(config.get_localized_string(30993).replace('...','') % '"%s"' % self.item.text, 'bold'))
|
||||
self.SEARCH = self.getControl(SEARCH)
|
||||
self.EPISODES = self.getControl(EPISODES)
|
||||
self.EPISODESLIST = self.getControl(EPISODESLIST)
|
||||
self.SERVERS = self.getControl(SERVERS)
|
||||
self.SERVERLIST = self.getControl(SERVERLIST)
|
||||
self.NORESULTS = self.getControl(NORESULTS)
|
||||
self.NORESULTS.setVisible(False)
|
||||
self.LOADING = self.getControl(LOADING)
|
||||
self.LOADING.setVisible(False)
|
||||
|
||||
self.Focus(self.focus)
|
||||
|
||||
if self.type:
|
||||
self.type = None
|
||||
if self.item.mode in ['all', 'search']:
|
||||
if self.item.type: self.item.mode = self.item.type
|
||||
self.thread = Thread(target=self.search)
|
||||
self.thread.start()
|
||||
elif self.item.mode in ['movie', 'tvshow']:
|
||||
self.select()
|
||||
elif self.item.mode in ['person']:
|
||||
self.actors()
|
||||
|
||||
def Focus(self, focusid):
|
||||
if focusid in [SEARCH]:
|
||||
self.focus = CHANNELS
|
||||
self.SEARCH.setVisible(True)
|
||||
self.EPISODES.setVisible(False)
|
||||
self.SERVERS.setVisible(False)
|
||||
if focusid in [EPISODES]:
|
||||
self.focus = focusid
|
||||
self.SEARCH.setVisible(False)
|
||||
self.EPISODES.setVisible(True)
|
||||
self.SERVERS.setVisible(False)
|
||||
if focusid in [SERVERS]:
|
||||
self.focus = SERVERLIST
|
||||
self.SEARCH.setVisible(False)
|
||||
self.EPISODES.setVisible(False)
|
||||
self.SERVERS.setVisible(True)
|
||||
|
||||
def onAction(self, action):
|
||||
action = action.getId()
|
||||
focus = self.getFocusId()
|
||||
if action in [CONTEXT] and focus in [RESULTS, EPISODESLIST, SERVERLIST]:
|
||||
self.context()
|
||||
|
||||
elif action in [SWIPEUP] and self.CHANNELS.isVisible():
|
||||
self.setFocusId(CHANNELS)
|
||||
pos = self.CHANNELS.getSelectedPosition()
|
||||
self.CHANNELS.selectItem(pos)
|
||||
|
||||
elif action in [LEFT, RIGHT] and focus in [CHANNELS] and self.CHANNELS.isVisible():
|
||||
items = []
|
||||
name = self.CHANNELS.getSelectedItem().getLabel()
|
||||
subpos = int(self.CHANNELS.getSelectedItem().getProperty('position'))
|
||||
for result in self.results[name][0]:
|
||||
items.append(self.makeItem(result))
|
||||
self.RESULTS.reset()
|
||||
self.RESULTS.addItems(items)
|
||||
self.RESULTS.selectItem(subpos)
|
||||
|
||||
elif action in [DOWN] and focus in [BACK, CLOSE, MENU]:
|
||||
if self.SERVERS.isVisible(): self.setFocusId(SERVERLIST)
|
||||
elif self.EPISODES.isVisible(): self.setFocusId(EPISODESLIST)
|
||||
else: self.setFocusId(RESULTS)
|
||||
|
||||
elif focus in [RESULTS] and self.item.mode == 'all':
|
||||
pos = self.RESULTS.getSelectedPosition()
|
||||
self.CHANNELS.getSelectedItem().setProperty('position', str(pos))
|
||||
|
||||
elif action == ENTER and focus in [CHANNELS]:
|
||||
self.setFocusId(RESULTS)
|
||||
|
||||
if action in [BACKSPACE]:
|
||||
self.Back()
|
||||
|
||||
elif action in [EXIT]:
|
||||
self.Close()
|
||||
|
||||
def onClick(self, control_id):
|
||||
if self.RESULTS.getSelectedItem(): search = self.RESULTS.getSelectedItem().getProperty('search')
|
||||
else: search = None
|
||||
if control_id in [CHANNELS]:
|
||||
items = []
|
||||
name = self.CHANNELS.getSelectedItem().getLabel()
|
||||
subpos = int(self.CHANNELS.getSelectedItem().getProperty('position'))
|
||||
for result in self.results[name][0]:
|
||||
items.append(self.makeItem(result))
|
||||
self.RESULTS.reset()
|
||||
self.RESULTS.addItems(items)
|
||||
self.RESULTS.selectItem(subpos)
|
||||
self.CHANNELS.getSelectedItem().setProperty('position', str(subpos))
|
||||
|
||||
elif control_id in [BACK]:
|
||||
self.Back()
|
||||
|
||||
elif control_id in [CLOSE]:
|
||||
self.Close()
|
||||
|
||||
elif control_id in [MENU]:
|
||||
self.context()
|
||||
|
||||
elif search:
|
||||
pos = self.RESULTS.getSelectedPosition()
|
||||
if search == 'next':
|
||||
self.page += 1
|
||||
self.actors()
|
||||
elif search == 'previous':
|
||||
self.page -= 1
|
||||
self.actors()
|
||||
elif search == 'persons':
|
||||
self.item.discovery = self.persons[pos]
|
||||
self.select()
|
||||
else:
|
||||
result = self.find[pos]
|
||||
name = self.RESULTS.getSelectedItem().getLabel()
|
||||
item = Item(mode='search', type=result['mode'], contentType=result['mode'], infoLabels=result, selected = True, text=name)
|
||||
if self.item.mode == 'movie': item.contentTitle = self.RESULTS.getSelectedItem().getLabel()
|
||||
else: item.contentSerieName = self.RESULTS.getSelectedItem().getLabel()
|
||||
return Search(item)
|
||||
|
||||
elif control_id in [RESULTS, EPISODESLIST]:
|
||||
busy(True)
|
||||
if control_id in [RESULTS]:
|
||||
name = self.CHANNELS.getSelectedItem().getLabel()
|
||||
self.pos = self.RESULTS.getSelectedPosition()
|
||||
item = self.results[name][0][self.pos]
|
||||
else:
|
||||
self.pos = self.EPISODESLIST.getSelectedPosition()
|
||||
item = self.episodes[self.pos]
|
||||
try:
|
||||
self.channel = __import__('channels.%s' % item.channel, fromlist=["channels.%s" % item.channel])
|
||||
self.itemsResult = getattr(self.channel, item.action)(item)
|
||||
except:
|
||||
import traceback
|
||||
logger.error('error importing/getting search items of ' + item.channel)
|
||||
logger.error(traceback.format_exc())
|
||||
self.itemsResult = []
|
||||
|
||||
if self.itemsResult and self.itemsResult[0].action in ['play', '']:
|
||||
|
||||
if config.get_setting('checklinks') and not config.get_setting('autoplay'):
|
||||
self.itemsResult = servertools.check_list_links(self.itemsResult, config.get_setting('checklinks_number'))
|
||||
self.servers = self.itemsResult
|
||||
self.itemsResult = []
|
||||
uhd = []
|
||||
fhd = []
|
||||
hd = []
|
||||
sd = []
|
||||
unknown = []
|
||||
for i, item in enumerate(self.servers):
|
||||
if item.server:
|
||||
it = self.makeItem(item)
|
||||
it.setProperty('index', str(i))
|
||||
if item.quality in ['4k', '2160p', '2160', '4k2160p', '4k2160', '4k 2160p', '4k 2160', '2k']:
|
||||
it.setProperty('quality', 'uhd.png')
|
||||
uhd.append(it)
|
||||
elif item.quality in ['fullhd', 'fullhd 1080', 'fullhd 1080p', 'full hd', 'full hd 1080', 'full hd 1080p', 'hd1080', 'hd1080p', 'hd 1080', 'hd 1080p', '1080', '1080p']:
|
||||
it.setProperty('quality', 'Fhd.png')
|
||||
fhd.append(it)
|
||||
elif item.quality in ['hd', 'hd720', 'hd720p', 'hd 720', 'hd 720p', '720', '720p', 'hdtv']:
|
||||
it.setProperty('quality', 'hd.png')
|
||||
hd.append(it)
|
||||
elif item.quality in ['sd', '480p', '480', '360p', '360', '240p', '240']:
|
||||
it.setProperty('quality', 'sd.png')
|
||||
sd.append(it)
|
||||
else:
|
||||
it.setProperty('quality', '')
|
||||
unknown.append(it)
|
||||
elif not item.action:
|
||||
self.getControl(QUALITYTAG).setText(item.fulltitle)
|
||||
|
||||
|
||||
uhd.sort(key=lambda it: it.getProperty('index'))
|
||||
fhd.sort(key=lambda it: it.getProperty('index'))
|
||||
hd.sort(key=lambda it: it.getProperty('index'))
|
||||
sd.sort(key=lambda it: it.getProperty('index'))
|
||||
unknown.sort(key=lambda it: it.getProperty('index'))
|
||||
|
||||
serverlist = uhd + fhd + hd + sd + unknown
|
||||
|
||||
self.Focus(SERVERS)
|
||||
self.SERVERLIST.reset()
|
||||
self.SERVERLIST.addItems(serverlist)
|
||||
self.setFocusId(SERVERLIST)
|
||||
|
||||
else:
|
||||
self.episodes = self.itemsResult
|
||||
self.itemsResult = []
|
||||
episodes = []
|
||||
for item in self.episodes:
|
||||
if item.action == 'findvideos':
|
||||
it = xbmcgui.ListItem(item.title)
|
||||
episodes.append(it)
|
||||
|
||||
self.Focus(EPISODES)
|
||||
self.EPISODESLIST.reset()
|
||||
self.EPISODESLIST.addItems(episodes)
|
||||
self.setFocusId(EPISODESLIST)
|
||||
|
||||
busy(False)
|
||||
|
||||
elif control_id in [SERVERLIST]:
|
||||
index = int(self.getControl(control_id).getSelectedItem().getProperty('index'))
|
||||
server = self.servers[index]
|
||||
server.player_mode = 0
|
||||
run(server)
|
||||
|
||||
def Back(self):
|
||||
self.getControl(QUALITYTAG).setText('')
|
||||
if self.SERVERS.isVisible():
|
||||
if self.episodes:
|
||||
self.Focus(EPISODES)
|
||||
self.setFocusId(EPISODESLIST)
|
||||
else:
|
||||
self.Focus(SEARCH)
|
||||
self.setFocusId(RESULTS)
|
||||
self.RESULTS.selectItem(self.pos)
|
||||
elif self.EPISODES.isVisible():
|
||||
self.episodes = []
|
||||
self.Focus(SEARCH)
|
||||
self.setFocusId(RESULTS)
|
||||
self.RESULTS.selectItem(self.pos)
|
||||
elif self.item.mode in ['person'] and self.find:
|
||||
self.find = []
|
||||
self.actors()
|
||||
else:
|
||||
self.Close()
|
||||
|
||||
def Close(self):
|
||||
self.exit = True
|
||||
if self.thread:
|
||||
busy(True)
|
||||
self.thread.join()
|
||||
busy(False)
|
||||
self.close()
|
||||
|
||||
def context(self):
|
||||
pos = self.RESULTS.getSelectedPosition()
|
||||
name = self.CHANNELS.getSelectedItem().getLabel()
|
||||
item = self.results[name][0][pos]
|
||||
context = [config.get_localized_string(70739), config.get_localized_string(70557), config.get_localized_string(30155), config.get_localized_string(60359)]
|
||||
context_commands = ["RunPlugin(%s?%s)" % (sys.argv[0], 'action=open_browser&url=' + item.url),
|
||||
"RunPlugin(%s?%s&%s)" % (sys.argv[0], item.tourl(), 'channel=kodfavorites&action=addFavourite&from_channel=' + item.channel + '&from_action=' + item.action),
|
||||
"RunPlugin(%s?%s&%s)" % (sys.argv[0], item.tourl(), 'channel=favorites&action=addFavourite&from_channel=' + item.channel + '&from_action=' + item.action),
|
||||
"RunPlugin(%s?%s)" % (sys.argv[0], 'channel=trailertools&action=buscartrailer&contextual=True&search_title=' + item.contentTitle if item.contentTitle else item.fulltitle)]
|
||||
if item.contentType == 'movie':
|
||||
context += [config.get_localized_string(60353), config.get_localized_string(60354)]
|
||||
context_commands += ["RunPlugin(%s?%s&%s)" % (sys.argv[0], item.tourl(), 'action=add_pelicula_to_library&from_action=' + item.action),
|
||||
"RunPlugin(%s?%s&%s)" % (sys.argv[0], item.tourl(), 'channel=downloads&action=save_download&from_channel=' + item.channel + '&from_action=' +item.action)]
|
||||
|
||||
else:
|
||||
context += [config.get_localized_string(60352), config.get_localized_string(60355), config.get_localized_string(60357)]
|
||||
context_commands += ["RunPlugin(%s?%s&%s)" % (sys.argv[0], item.tourl(), 'action=add_serie_to_library&from_action=' + item.action),
|
||||
"RunPlugin(%s?%s&%s)" % (sys.argv[0], item.tourl(), 'channel=downloads&action=save_download&from_channel=' + item.channel + '&from_action=' + item.action),
|
||||
"RunPlugin(%s?%s&%s)" % (sys.argv[0], item.tourl(), 'channel=downloads&action=save_download&download=season&from_channel=' + item.channel +'&from_action=' + item.action)]
|
||||
|
||||
if self.EPISODES.isVisible() or self.SERVERS.isVisible():
|
||||
pos = self.EPISODESLIST.getSelectedPosition()
|
||||
item = self.episodes[pos]
|
||||
context += [config.get_localized_string(60356)]
|
||||
context_commands += ["RunPlugin(%s?%s&%s)" % (sys.argv[0], item.tourl(), 'channel=downloads&action=save_download&from_channel=' + item.channel + '&from_action=' +item.action)]
|
||||
|
||||
index = xbmcgui.Dialog().contextmenu(context)
|
||||
if index > 0: xbmc.executebuiltin(context_commands[index])
|
||||
@@ -37,6 +37,7 @@ def start():
|
||||
updater.showSavedChangelog()
|
||||
|
||||
def run(item=None):
|
||||
# from core.support import dbg;dbg()
|
||||
logger.debug()
|
||||
if not item:
|
||||
# Extract item from sys.argv
|
||||
@@ -135,12 +136,6 @@ def run(item=None):
|
||||
from platformcode import infoplus
|
||||
return infoplus.Main(item)
|
||||
|
||||
elif config.get_setting('new_search') and item.channel == "search" and item.action == 'new_search':
|
||||
from platformcode.globalsearch import Search
|
||||
item.contextual = True
|
||||
Search(item)
|
||||
return
|
||||
|
||||
elif item.channel == "backup":
|
||||
from platformcode import backup
|
||||
return getattr(backup, item.action)(item)
|
||||
@@ -489,17 +484,24 @@ def play_from_library(item):
|
||||
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(100)
|
||||
play_time = platformtools.resume_playback(item, True)
|
||||
if not play_time and config.get_setting('autoplay'):
|
||||
while platformtools.is_playing(): sleep(1)
|
||||
# from core.support import dbg;dbg()
|
||||
if item.contentType == 'movie': nfo_path = item.nfo
|
||||
else: nfo_path = item.strm_path.replace('strm','nfo')
|
||||
if nfo_path and filetools.isfile(nfo_path):
|
||||
from core import videolibrarytools
|
||||
head_nfo, item_nfo = videolibrarytools.read_nfo(nfo_path)
|
||||
played_time = platformtools.get_played_time(item_nfo)
|
||||
else: played_time = 0
|
||||
|
||||
if not played_time and config.get_setting('autoplay'):
|
||||
return
|
||||
|
||||
# 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)
|
||||
|
||||
# from core.support import dbg;dbg()
|
||||
if len(itemlist) > 0:
|
||||
while not xbmc.Monitor().abortRequested():
|
||||
# The user chooses the mirror
|
||||
|
||||
@@ -547,7 +547,7 @@ def set_context_commands(item, item_url, parent_item, **kwargs):
|
||||
context_commands.append(("InfoPlus", "RunPlugin(%s?%s&%s)" % (sys.argv[0], item_url, 'channel=infoplus&action=Main&from_channel=' + item.channel)))
|
||||
|
||||
# Go to the Main Menu (channel.mainlist)
|
||||
if parent_item.channel not in ["news", "channelselector", "downloads"] and item.action != "mainlist":
|
||||
if parent_item.channel not in ["news", "channelselector", "downloads", "search"] and item.action != "mainlist" and not parent_item.noMainMenu:
|
||||
if parent_item.action != "mainlist":
|
||||
context_commands.insert(0, (config.get_localized_string(60349), "Container.Refresh (%s?%s)" % (sys.argv[0], Item(channel=item.channel, action="mainlist").tourl())))
|
||||
context_commands.insert(1, (config.get_localized_string(70739), "Container.Update (%s?%s)" % (sys.argv[0], Item(action="open_browser", url=item.url).tourl())))
|
||||
@@ -556,7 +556,7 @@ def set_context_commands(item, item_url, parent_item, **kwargs):
|
||||
if item.channel not in ["favorites", "videolibrary", "help", ""] and parent_item.channel != "favorites":
|
||||
context_commands.append( (config.get_localized_string(70557), "RunPlugin(%s?%s&%s)" % (sys.argv[0], item_url, urllib.urlencode({'channel': "kodfavorites", 'action': "addFavourite", 'from_channel': item.channel, 'from_action': item.action}))))
|
||||
# Search in other channels
|
||||
if item.contentTitle and item.contentType in ['movie', 'tvshow'] and item.channel != 'search' and item.action not in ['play'] and parent_item.action != 'mainlist':
|
||||
if item.contentTitle and item.contentType in ['movie', 'tvshow'] and parent_item.channel != 'search' and item.action not in ['play'] and parent_item.action != 'mainlist':
|
||||
|
||||
# Search in other channels
|
||||
if item.contentSerieName != '':
|
||||
@@ -586,7 +586,7 @@ def set_context_commands(item, item_url, parent_item, **kwargs):
|
||||
elif item.action in ["detail", "findvideos"] and item.contentType == 'movie' and item.contentTitle:
|
||||
context_commands.append((config.get_localized_string(60353), "RunPlugin(%s?%s&%s)" % (sys.argv[0], item_url, 'action=add_pelicula_to_library&from_action=' + item.action)))
|
||||
|
||||
if not item.local and item.channel not in ["downloads", "filmontv"] and item.server != 'torrent' and parent_item.action != 'mainlist' and config.get_setting('downloadenabled'):
|
||||
if not item.local and item.channel not in ["downloads", "filmontv", "search"] and item.server != 'torrent' and parent_item.action != 'mainlist' and config.get_setting('downloadenabled'):
|
||||
# Download movie
|
||||
if item.contentType == "movie":
|
||||
context_commands.append((config.get_localized_string(60354), "RunPlugin(%s?%s&%s)" % (sys.argv[0], item_url, 'channel=downloads&action=save_download&from_channel=' + item.channel + '&from_action=' + item.action)))
|
||||
@@ -679,9 +679,7 @@ def play_video(item, strm=False, force_direct=False, autoplay=False):
|
||||
|
||||
if force_direct: item.play_from = 'window'
|
||||
|
||||
|
||||
item, nfo_path, head_nfo, item_nfo = resume_playback(item)
|
||||
set_player(item, xlistitem, mediaurl, view, strm, nfo_path, head_nfo, item_nfo)
|
||||
set_player(item, xlistitem, mediaurl, view, strm)
|
||||
|
||||
|
||||
def stop_video():
|
||||
@@ -1009,9 +1007,17 @@ def get_video_seleccionado(item, seleccion, video_urls):
|
||||
return mediaurl, view, mpd
|
||||
|
||||
|
||||
def set_player(item, xlistitem, mediaurl, view, strm, nfo_path=None, head_nfo=None, item_nfo=None):
|
||||
def set_player(item, xlistitem, mediaurl, view, strm):
|
||||
logger.debug()
|
||||
item.options = {'strm':False, 'continue':False}
|
||||
# logger.debug("item:\n" + item.tostring('\n'))
|
||||
|
||||
# Prevent Busy
|
||||
if not item.autoplay:
|
||||
if item.globalsearch: xbmc.executebuiltin("PlayMedia(" + os.path.join(config.get_runtime_path(), "resources", "kod.mp4") + ")")
|
||||
else: xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, xbmcgui.ListItem(path=os.path.join(config.get_runtime_path(), "resources", "kod.mp4")))
|
||||
xbmc.Player().stop()
|
||||
|
||||
# Moved del conector "torrent" here
|
||||
if item.server == "torrent":
|
||||
play_torrent(item, xlistitem, mediaurl)
|
||||
@@ -1028,29 +1034,26 @@ def set_player(item, xlistitem, mediaurl, view, strm, nfo_path=None, head_nfo=No
|
||||
player_mode = item.player_mode
|
||||
else:
|
||||
player_mode = config.get_setting("player_mode")
|
||||
if (player_mode == 3 and mediaurl.startswith("rtmp")) or item.play_from == 'window' or item.nfo: player_mode = 0
|
||||
if (player_mode == 3 and mediaurl.startswith("rtmp")): player_mode = 0
|
||||
elif "megacrypter.com" in mediaurl: player_mode = 3
|
||||
logger.info("mediaurl=" + mediaurl)
|
||||
|
||||
if player_mode == 0:
|
||||
logger.info('Player Mode: Direct')
|
||||
if player_mode in [0,1]:
|
||||
logger.info('Player Mode:' + ['Direct', 'Bookmark'][player_mode])
|
||||
# Add the listitem to a playlist
|
||||
playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
|
||||
playlist.clear()
|
||||
playlist.add(mediaurl, xlistitem)
|
||||
|
||||
# played_time = resume_playback(get_played_time(item))
|
||||
|
||||
# Reproduce
|
||||
xbmc_player.play(playlist, xlistitem)
|
||||
# viewed(item, played_time)
|
||||
if config.get_setting('trakt_sync'):
|
||||
from core import trakt_tools
|
||||
trakt_tools.wait_for_update_trakt()
|
||||
|
||||
elif player_mode == 1:
|
||||
logger.info('Player Mode: setResolvedUrl')
|
||||
xlistitem.setPath(mediaurl)
|
||||
xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, xlistitem)
|
||||
# xbmc.sleep(2500)
|
||||
|
||||
elif player_mode == 2:
|
||||
logger.info('Player Mode: Built-In')
|
||||
xbmc.executebuiltin("PlayMedia(" + mediaurl + ")")
|
||||
@@ -1068,13 +1071,14 @@ def set_player(item, xlistitem, mediaurl, view, strm, nfo_path=None, head_nfo=No
|
||||
xbmc_player.setSubtitles(item.subtitle)
|
||||
|
||||
# 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, nfo_path, head_nfo, item_nfo)
|
||||
if strm or item.strm_path: item.options['strm'] = True
|
||||
if player_mode == 1: item.options['continue'] = True
|
||||
from platformcode import xbmc_videolibrary
|
||||
xbmc_videolibrary.mark_auto_as_watched(item)
|
||||
|
||||
# for cases where the audio playback window appears in place of the video one
|
||||
if item.focusOnVideoPlayer:
|
||||
while is_playing and xbmcgui.getCurrentWindowId() != 12006:
|
||||
while is_playing() and xbmcgui.getCurrentWindowId() != 12006:
|
||||
continue
|
||||
xbmc.sleep(500)
|
||||
xbmcgui.Window(12005).show()
|
||||
@@ -1136,16 +1140,16 @@ def play_torrent(item, xlistitem, mediaurl):
|
||||
time.sleep(3)
|
||||
|
||||
|
||||
def resume_playback(item, return_played_time=False):
|
||||
def resume_playback(played_time):
|
||||
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.action_exitkeys_id = [92, 10]
|
||||
self.progress_control = None
|
||||
self.item = kwargs.get('item')
|
||||
m, s = divmod(float(self.item.played_time), 60)
|
||||
played_time = kwargs.get('played_time')
|
||||
m, s = divmod(played_time, 60)
|
||||
h, m = divmod(m, 60)
|
||||
self.setProperty("time", '%02d:%02d:%02d' % (h, m, s))
|
||||
|
||||
@@ -1168,38 +1172,17 @@ def resume_playback(item, return_played_time=False):
|
||||
if action in self.action_exitkeys_id:
|
||||
self.set_values(False)
|
||||
self.close()
|
||||
|
||||
|
||||
from core import videolibrarytools, filetools
|
||||
|
||||
# Read NFO FILE
|
||||
if item.contentType == 'movie':
|
||||
nfo_path = item.nfo
|
||||
else:
|
||||
nfo_path = 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 [3] or item.play_from == 'window') and item_nfo.played_time and item_nfo.played_time >= 120:
|
||||
Dialog = ResumePlayback('ResumePlayback.xml', config.get_runtime_path(), item=item_nfo)
|
||||
Dialog.show()
|
||||
t = 0
|
||||
while not Dialog.is_close() and t < 100:
|
||||
t += 1
|
||||
xbmc.sleep(100)
|
||||
if not Dialog.Resume: item_nfo.played_time = 0
|
||||
else:
|
||||
item_nfo.played_time = 0
|
||||
|
||||
return item, nfo_path, head_nfo, item_nfo
|
||||
else:
|
||||
item.nfo = item.strm_path = ""
|
||||
return item, None, None, None
|
||||
|
||||
if played_time:
|
||||
Dialog = ResumePlayback('ResumePlayback.xml', config.get_runtime_path(), played_time=played_time)
|
||||
Dialog.show()
|
||||
t = 0
|
||||
while not Dialog.is_close() and t < 100:
|
||||
t += 1
|
||||
xbmc.sleep(100)
|
||||
if not Dialog.Resume: played_time = 0
|
||||
else: played_time = 0
|
||||
xbmc.sleep(300)
|
||||
return played_time
|
||||
|
||||
##### INPUTSTREM #####
|
||||
|
||||
@@ -1396,3 +1379,65 @@ def get_platform():
|
||||
ret["arch"] = "arm"
|
||||
|
||||
return ret
|
||||
|
||||
|
||||
|
||||
def get_played_time(item):
|
||||
import sqlite3
|
||||
from core import filetools
|
||||
db_name = filetools.join(config.get_data_path(), "kod_db.sqlite")
|
||||
ID = item.infoLabels['tmdb_id']
|
||||
conn = sqlite3.connect(db_name, timeout=15)
|
||||
c = conn.cursor()
|
||||
c.execute('CREATE TABLE IF NOT EXISTS viewed (tmdb_id TEXT, season INT, episode INT, played_time REAL)')
|
||||
conn.commit()
|
||||
if ID:
|
||||
if item.contentType == 'movie': c.execute("SELECT played_time FROM viewed WHERE tmdb_id=?", (ID,))
|
||||
elif 'season' in item.infoLabels:
|
||||
S = item.infoLabels['season']
|
||||
E = item.infoLabels['episode']
|
||||
c.execute("SELECT played_time FROM viewed WHERE tmdb_id=? AND season=? AND episode=?", (ID, S, E))
|
||||
elif 'episode' in item.infoLabels:
|
||||
E = item.infoLabels['episode']
|
||||
c.execute("SELECT played_time FROM viewed WHERE tmdb_id=? AND episode=?", (ID, E))
|
||||
result = c.fetchone()
|
||||
if not result: played_time = 0
|
||||
else: played_time = result[0]
|
||||
else: played_time = 0
|
||||
conn.close()
|
||||
return played_time
|
||||
|
||||
def set_played_time(item):
|
||||
import sqlite3
|
||||
from core import filetools
|
||||
ID = item.infoLabels['tmdb_id']
|
||||
played_time = item.played_time
|
||||
db_name = filetools.join(config.get_data_path(), "kod_db.sqlite")
|
||||
conn = sqlite3.connect(db_name, timeout=15)
|
||||
c = conn.cursor()
|
||||
if item.contentType == 'movie':
|
||||
c.execute("SELECT played_time FROM viewed WHERE tmdb_id=?", (ID,))
|
||||
result = c.fetchone()
|
||||
if result:
|
||||
if played_time > 0: c.execute("UPDATE viewed SET played_time=? WHERE tmdb_id=?", (item.played_time, ID))
|
||||
else: c.execute("DELETE from viewed WHERE tmdb_id=?", (ID,))
|
||||
else: c.execute("INSERT INTO viewed (tmdb_id, played_time) VALUES (?, ?)", (ID, item.played_time))
|
||||
elif 'season' in item.infoLabels:
|
||||
S = item.infoLabels['season']
|
||||
E = item.infoLabels['episode']
|
||||
c.execute("SELECT played_time FROM viewed WHERE tmdb_id=? AND season = ? AND episode=?", (ID, S, E))
|
||||
result = c.fetchone()
|
||||
if result:
|
||||
if played_time > 0: c.execute("UPDATE viewed SET played_time=? WHERE tmdb_id=? AND season=? AND episode=?", (item.played_time, ID, S, E))
|
||||
else: c.execute("DELETE from viewed WHERE tmdb_id=? AND season=? AND episode=?", (ID, S, E))
|
||||
else: c.execute("INSERT INTO viewed (tmdb_id, season, episode, played_time) VALUES (?, ?, ?, ?)", (ID, S, E, item.played_time))
|
||||
elif 'episode' in item.infoLabels:
|
||||
E = item.infoLabels['episode']
|
||||
c.execute("SELECT played_time FROM viewed WHERE tmdb_id=? AND episode=?", (ID, E))
|
||||
result = c.fetchone()
|
||||
if result:
|
||||
if played_time > 0: c.execute("UPDATE viewed SET played_time=? WHERE tmdb_id=? AND episode=?", (item.played_time, ID, E))
|
||||
else: c.execute("DELETE from viewed WHERE tmdb_id=? AND episode=?", (ID, E))
|
||||
else: c.execute("INSERT INTO viewed (tmdb_id, episode, played_time) VALUES (?, ?, ?)", (ID, E, item.played_time))
|
||||
conn.commit()
|
||||
conn.close()
|
||||
|
||||
@@ -20,15 +20,19 @@ from core import scrapertools
|
||||
from xml.dom import minidom
|
||||
|
||||
|
||||
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):
|
||||
def mark_auto_as_watched(item):
|
||||
def mark_as_watched_subThread(item):
|
||||
logger.debug()
|
||||
actual_time = 0
|
||||
total_time = 0
|
||||
# logger.debug("item:\n" + item.tostring('\n'))
|
||||
if item.options['continue']: item.played_time = platformtools.resume_playback(platformtools.get_played_time(item))
|
||||
|
||||
time_limit = time.time() + 30
|
||||
while not platformtools.is_playing() and time.time() < time_limit:
|
||||
time.sleep(1)
|
||||
|
||||
|
||||
marked = False
|
||||
next_episode = None
|
||||
show_server = True
|
||||
@@ -39,14 +43,15 @@ def mark_auto_as_watched(item, nfo_path=None, head_nfo=None, item_nfo=None):
|
||||
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)
|
||||
try: next_episode = next_ep(item)
|
||||
except: next_episode = False
|
||||
|
||||
while platformtools.is_playing():
|
||||
actual_time = xbmc.Player().getTime()
|
||||
total_time = xbmc.Player().getTotalTime()
|
||||
if item_nfo.played_time and xbmcgui.getCurrentWindowId() == 12005:
|
||||
xbmc.Player().seekTime(item_nfo.played_time)
|
||||
item_nfo.played_time = 0 # Fix for Slow Devices
|
||||
if item.played_time and xbmcgui.getCurrentWindowId() == 12005:
|
||||
xbmc.Player().seekTime(item.played_time)
|
||||
item.played_time = 0 # Fix for Slow Devices
|
||||
|
||||
mark_time = total_time * percentage
|
||||
difference = total_time - actual_time
|
||||
@@ -55,7 +60,7 @@ def mark_auto_as_watched(item, nfo_path=None, head_nfo=None, item_nfo=None):
|
||||
if actual_time > mark_time and not marked:
|
||||
logger.info("Marked as Watched")
|
||||
item.playcount = 1
|
||||
marked = True
|
||||
if item.options['strm'] : marked = True
|
||||
show_server = False
|
||||
from specials import videolibrary
|
||||
videolibrary.mark_content_as_watched2(item)
|
||||
@@ -75,9 +80,11 @@ def mark_auto_as_watched(item, nfo_path=None, head_nfo=None, item_nfo=None):
|
||||
break
|
||||
xbmc.sleep(1000)
|
||||
|
||||
# Set played time
|
||||
item_nfo.played_time = int(actual_time) if not marked else 0
|
||||
filetools.write(nfo_path, head_nfo + item_nfo.tojson())
|
||||
if item.options['continue']:
|
||||
if 120 < actual_time < (total_time / 100) * 80:
|
||||
item.played_time = actual_time
|
||||
else: item.played_time = 0
|
||||
platformtools.set_played_time(item)
|
||||
|
||||
# Silent sync with Trakt
|
||||
if marked and config.get_setting("trakt_sync"): sync_trakt_kodi()
|
||||
@@ -94,7 +101,7 @@ def mark_auto_as_watched(item, nfo_path=None, head_nfo=None, item_nfo=None):
|
||||
|
||||
# If it is configured to mark as seen
|
||||
if config.get_setting("mark_as_watched", "videolibrary"):
|
||||
threading.Thread(target=mark_as_watched_subThread, args=[item, nfo_path, head_nfo, item_nfo]).start()
|
||||
threading.Thread(target=mark_as_watched_subThread, args=[item]).start()
|
||||
|
||||
|
||||
|
||||
@@ -1340,12 +1347,11 @@ class NextDialog(xbmcgui.WindowXMLDialog):
|
||||
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"]
|
||||
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"]))
|
||||
|
||||
@@ -1381,4 +1387,4 @@ class NextDialog(xbmcgui.WindowXMLDialog):
|
||||
if action in self.action_exitkeys_id:
|
||||
self.set_exit(True)
|
||||
self.set_continue_watching(False)
|
||||
self.close()
|
||||
self.close()
|
||||
|
||||
Reference in New Issue
Block a user