Modifiche e Fix a segna come già visto

This commit is contained in:
Alhaziel01
2021-09-04 20:08:30 +02:00
parent 905e1ad6ee
commit 2a5a83c767
9 changed files with 148 additions and 127 deletions
+15 -21
View File
@@ -52,7 +52,7 @@ def genres(item):
args = support.match(data, patronBlock=r'genre-options-json="([^\]]+)\]', patron=r'name"\s*:\s*"([^"]+)').matches args = support.match(data, patronBlock=r'genre-options-json="([^\]]+)\]', patron=r'name"\s*:\s*"([^"]+)').matches
for arg in args: for arg in args:
itemlist.append(item.clone(title=support.typo(arg, 'bold'), args=arg, action='peliculas')) itemlist.append(item.clone(title=support.typo(arg, 'bold'), args=arg, action='peliculas'))
support.thumb(itemlist, mode='genre') support.thumb(itemlist, genre=True)
return itemlist return itemlist
@@ -129,7 +129,7 @@ def peliculas(item):
itemlist.append(makeItem(i, it, item)) itemlist.append(makeItem(i, it, item))
else: else:
recordlist.append(it) recordlist.append(it)
itemlist.sort(key=lambda item: item.n) itemlist.sort(key=lambda item: item.n)
if recordlist: if recordlist:
itemlist.append(item.clone(title=support.typo(support.config.get_localized_string(30992), 'color kod bold'), thumbnail=support.thumb(), page=page, records=recordlist)) itemlist.append(item.clone(title=support.typo(support.config.get_localized_string(30992), 'color kod bold'), thumbnail=support.thumb(), page=page, records=recordlist))
@@ -143,10 +143,7 @@ def makeItem(n, it, item):
title, lang = support.match(info['name'], patron=r'([^\[|$]+)(?:\[([^\]]+)\])?').match title, lang = support.match(info['name'], patron=r'([^\[|$]+)(?:\[([^\]]+)\])?').match
if not lang: if not lang:
lang = 'ITA' lang = 'ITA'
itm = item.clone(title=support.typo(title,'bold') + support.typo(lang,'_ [] color kod bold')) itm = item.clone(title=title, contentType = info['type'].replace('tv', 'tvshow'), contentLanguage = lang, year = info['release_date'].split('-')[0])
itm.contentType = info['type'].replace('tv', 'tvshow')
itm.language = lang
itm.year = info['release_date'].split('-')[0]
if itm.contentType == 'movie': if itm.contentType == 'movie':
@@ -176,18 +173,15 @@ def episodios(item):
for episodes in js: for episodes in js:
for it in episodes['episodes']: for it in episodes['episodes']:
itemlist.append( itemlist.append(
support.Item(channel=item.channel, item.clone(
title=it['name'], contentEpisodeNumber = it['number'],
episode = it['number'], contentSeason=episodes['number'],
season=episodes['number'],
thumbnail=it['images'][0]['original_url'] if 'images' in it and 'original_url' in it['images'][0] else item.thumbnail, thumbnail=it['images'][0]['original_url'] if 'images' in it and 'original_url' in it['images'][0] else item.thumbnail,
fanart=item.fanart, fanart=item.fanart,
plot=it['plot'], plot=it['plot'],
action='findvideos', action='findvideos',
contentType='episode', contentType='episode',
contentSeason = int(episodes['number']), contentTitle=support.cleantitle(it['name']),
contentEpisodeNumber = int(it['number']),
contentSerieName=item.fulltitle,
url=host + '/watch/' + str(episodes['title_id']), url=host + '/watch/' + str(episodes['title_id']),
episodeid= '?e=' + str(it['id']))) episodeid= '?e=' + str(it['id'])))
@@ -215,16 +209,16 @@ def findvideos(item):
return s return s
token = calculateToken() token = calculateToken()
def videourls(res):
newurl = '{}/{}{}'.format(url, res, token)
if requests.head(newurl, headers=headers).status_code == 200:
video_urls.append({'type':'m3u8', 'res':res, 'url':newurl})
with futures.ThreadPoolExecutor() as executor: # def videourls(res):
for res in ['480p', '720p', '1080p']: # newurl = '{}/{}{}'.format(url, res, token)
executor.submit(videourls, res) # if requests.head(newurl, headers=headers).status_code == 200:
# video_urls.append({'type':'m3u8', 'res':res, 'url':newurl})
# with futures.ThreadPoolExecutor() as executor:
# for res in ['480p', '720p', '1080p']:
# executor.submit(videourls, res)
if not video_urls: video_urls = [{'type':'m3u8', 'url':url + token}] if not video_urls: video_urls = [{'type':'m3u8', 'url':url + token}]
else: video_urls.sort(key=lambda url: int(support.match(url[0], patron=r'(\d+)p').match))
itemlist = [item.clone(title = channeltools.get_channel_parameters(item.channel)['title'], server='directo', video_urls=video_urls, thumbnail=channeltools.get_channel_parameters(item.channel)["thumbnail"], forcethumb=True)] itemlist = [item.clone(title = channeltools.get_channel_parameters(item.channel)['title'], server='directo', video_urls=video_urls, thumbnail=channeltools.get_channel_parameters(item.channel)["thumbnail"], forcethumb=True)]
return support.server(item, itemlist=itemlist) return support.server(item, itemlist=itemlist)
+2 -13
View File
@@ -683,17 +683,7 @@ def sort_servers(servers_list):
return [] return []
blacklisted_servers = config.get_setting("black_list", server='servers', default=[]) blacklisted_servers = config.get_setting("black_list", server='servers', default=[])
favorite_servers = config.get_setting('favorites_servers_list', server='servers', default=[]) favorite_servers = [s for s in config.get_setting('favorites_servers_list', server='servers', default=[]) if s not in blacklisted_servers]
favorite_servers = [s for s in favorite_servers if s not in blacklisted_servers]
if isinstance(servers_list[0], str):
servers_list = sorted(servers_list, key=lambda x: favorite_servers.index(x) if x in favorite_servers else 999)
return servers_list
favorite_quality = ['4k', '2160p', '2160', '4k2160p', '4k2160', '4k 2160p', '4k 2160', '2k',
'fullhd', 'fullhd 1080', 'fullhd 1080p', 'full hd', 'full hd 1080', 'full hd 1080p', 'hd1080', 'hd1080p', 'hd 1080', 'hd 1080p', '1080', '1080p',
'hd', 'hd720', 'hd720p', 'hd 720', 'hd 720p', '720', '720p', 'hdtv',
'sd', '480p', '480', '360p', '360', '240p', '240']
sorted_list = [] sorted_list = []
inverted = False inverted = False
@@ -721,9 +711,8 @@ def sort_servers(servers_list):
continue continue
element["index_server"] = index(favorite_servers, item.server.lower()) element["index_server"] = index(favorite_servers, item.server.lower())
element["index_quality"] = index(favorite_quality, item.quality.lower()) element["index_quality"] = platformtools.calcResolution(item.quality)
element['index_language'] = 0 if item.contentLanguage == 'ITA' else 1 element['index_language'] = 0 if item.contentLanguage == 'ITA' else 1
element['videoitem'] = item element['videoitem'] = item
sorted_list.append(element) sorted_list.append(element)
+3 -6
View File
@@ -597,7 +597,7 @@ def scrape(func):
if anime and inspect.stack()[1][3] not in ['find_episodes']: if anime and inspect.stack()[1][3] not in ['find_episodes']:
from platformcode import autorenumber from platformcode import autorenumber
if function == 'episodios': autorenumber.start(itemlist, item) if function == 'episodios': autorenumber.start(itemlist, item)
else: autorenumber.start(itemlist) else: autorenumber.start(itemlist, item)
if action != 'play' and 'patronMenu' not in args and 'patronGenreMenu' not in args and not disabletmdb and inspect.stack()[1][3] not in ['add_tvshow'] and function not in ['episodios', 'mainlist'] or (function in ['episodios'] and config.get_setting('episode_info')): # and function != 'episodios' and item.contentType in ['movie', 'tvshow', 'episode', 'undefined'] if action != 'play' and 'patronMenu' not in args and 'patronGenreMenu' not in args and not disabletmdb and inspect.stack()[1][3] not in ['add_tvshow'] and function not in ['episodios', 'mainlist'] or (function in ['episodios'] and config.get_setting('episode_info')): # and function != 'episodios' and item.contentType in ['movie', 'tvshow', 'episode', 'undefined']
tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True) tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True)
@@ -1139,12 +1139,10 @@ def videolibrary(itemlist, item, typography='', function_level=1, function=''):
logger.debug() logger.debug()
if item.contentType == 'movie': if item.contentType == 'movie':
action = 'add_movie_to_library' action = 'add_to_library'
extra = 'findvideos'
contentType = 'movie' contentType = 'movie'
else: else:
action = 'add_serie_to_library' action = 'add_to_library'
extra = 'episodios'
contentType = 'tvshow' contentType = 'tvshow'
function = function if function else inspect.stack()[function_level][3] function = function if function else inspect.stack()[function_level][3]
@@ -1176,7 +1174,6 @@ def videolibrary(itemlist, item, typography='', function_level=1, function=''):
url=item.url, url=item.url,
action=action, action=action,
from_action=item.action, from_action=item.action,
extra=extra,
path=item.path, path=item.path,
thumbnail=thumb('add_to_videolibrary') thumbnail=thumb('add_to_videolibrary')
)) ))
+10 -12
View File
@@ -687,11 +687,16 @@ def add_to_videolibrary(item, channel):
def add_to_videolibrary(item, channel): def add_to_videolibrary(item, channel):
itemlist = getattr(channel, item.from_action)(item) if item.contentType == 'movie':
if itemlist and itemlist[0].contentType == 'episode':
return add_tvshow(item, channel, itemlist)
else:
return add_movie(item) return add_movie(item)
elif item.contentType == 'tvshow':
return add_tvshow(item)
else:
itemlist = getattr(channel, item.from_action)(item)
if itemlist and itemlist[0].contentType == 'episode':
return add_tvshow(item, channel, itemlist)
else:
return add_movie(item)
def add_movie(item): def add_movie(item):
@@ -769,11 +774,6 @@ def add_tvshow(item, channel=None, itemlist=[]):
itemlist = [item.clone()] itemlist = [item.clone()]
else: else:
# This mark is because the item has something else apart in the "extra" attribute
# item.action = item.extra if item.extra else item.action
if isinstance(item.extra, str) and "###" in item.extra:
item.action = item.extra.split("###")[0]
item.extra = item.extra.split("###")[1]
if item.from_action: if item.from_action:
item.__dict__["action"] = item.__dict__.pop("from_action") item.__dict__["action"] = item.__dict__.pop("from_action")
@@ -811,7 +811,7 @@ def add_tvshow(item, channel=None, itemlist=[]):
if not check(item, itemlist): if not check(item, itemlist):
action = item.action action = item.action
item.setrenumber = True item.setrenumber = True
start(item) start(itemlist, item)
item.setrenumber = False item.setrenumber = False
item.action = action item.action = action
if not item.exit: if not item.exit:
@@ -820,8 +820,6 @@ def add_tvshow(item, channel=None, itemlist=[]):
else: else:
itemlist = getattr(channel, item.action)(item) itemlist = getattr(channel, item.action)(item)
global magnet_caching
magnet_caching = False
inserted, overwritten, failed, path = save_tvshow(item, itemlist) inserted, overwritten, failed, path = save_tvshow(item, itemlist)
+8 -5
View File
@@ -289,9 +289,9 @@ class addMovie(object):
def set_files(self): def set_files(self):
self.idFile = get_id('idFile', 'files') self.idFile = get_id('idFile', 'files')
if self.item.playcount: if self.info.get('playcount', None):
sql = 'INSERT OR IGNORE INTO files (idFile, idPath, strFilename, playCount, lastPlayed, dateAdded) VALUES ( ?, ?, ?, ?, ?, ?)' sql = 'INSERT OR IGNORE INTO files (idFile, idPath, strFilename, playCount, lastPlayed, dateAdded) VALUES ( ?, ?, ?, ?, ?, ?)'
params = (self.idFile, self.idPath, self.strFilename, self.item.playcount, self.item.lastplayed, date) params = (self.idFile, self.idPath, self.strFilename, self.info.get('playcount', None), self.item.lastplayed, date)
else: else:
sql = 'INSERT OR IGNORE INTO files (idFile, idPath, strFilename, dateAdded) VALUES ( ?, ?, ?, ?)' sql = 'INSERT OR IGNORE INTO files (idFile, idPath, strFilename, dateAdded) VALUES ( ?, ?, ?, ?)'
params = (self.idFile, self.idPath, self.strFilename, date) params = (self.idFile, self.idPath, self.strFilename, date)
@@ -331,7 +331,7 @@ class addMovie(object):
writer_link_params = [] writer_link_params = []
directors = self.info.get('director', '').split(', ') directors = self.info.get('director', '').split(', ')
directors_image = self.info.get('director_image', []) directors_image = self.info.get('director_image', [])
if not directors_image: writers_image = ['' for d in directors] if not directors_image: directors_image = ['' for d in directors]
writers = self.info.get('writer', '').split(', ') writers = self.info.get('writer', '').split(', ')
writers_image = self.info.get('writer_image', []) writers_image = self.info.get('writer_image', [])
if not writers_image: writers_image = ['' for w in writers] if not writers_image: writers_image = ['' for w in writers]
@@ -590,13 +590,16 @@ class addTvShow(object):
files = {r[1].replace('.strm',''):r[0] for r in records} files = {r[1].replace('.strm',''):r[0] for r in records}
self.idFiles = {} self.idFiles = {}
idFile = get_id('idFile', 'files') idFile = get_id('idFile', 'files')
# support.dbg()
for episode in self.idEpisodes.keys(): for episode in self.idEpisodes.keys():
if episode in files.keys(): if episode in files.keys():
self.idFiles[episode] = files[episode] self.idFiles[episode] = files[episode]
sql = 'update files set playCount= {} where idFile= {}'.format(self.episodes[episode]['item'].infoLabels.get('playcount', None), files[episode])
self.sql_actions.append([sql, ''])
else: else:
if self.item.playcount: if self.episodes[episode]['item'].infoLabels.get('playcount', None):
sql = 'INSERT INTO files (idFile, idPath, strFilename, playCount, lastPlayed, dateAdded) VALUES ( ?, ?, ?, ?, ?, ?)' sql = 'INSERT INTO files (idFile, idPath, strFilename, playCount, lastPlayed, dateAdded) VALUES ( ?, ?, ?, ?, ?, ?)'
params = (idFile, self.idPath, episode + '.strm', self.item.playcount, self.item.lastplayed, date) params = (idFile, self.idPath, episode + '.strm', self.episodes[episode]['item'].infoLabels.get('playcount', None), self.item.lastplayed, date)
else: else:
sql = 'INSERT INTO files (idFile, idPath, strFilename, dateAdded) VALUES ( ?, ?, ?, ?)' sql = 'INSERT INTO files (idFile, idPath, strFilename, dateAdded) VALUES ( ?, ?, ?, ?)'
params = (idFile, self.idPath, episode + '.strm', date) params = (idFile, self.idPath, episode + '.strm', date)
+1 -6
View File
@@ -260,13 +260,8 @@ def run(item=None):
elif item.action == "add_serie_to_library": elif item.action == "add_serie_to_library":
from core import videolibrarytools from core import videolibrarytools
videolibrarytools.add_tvshow(item, channel) videolibrarytools.add_tvshow(item, channel)
# Special action for adding a serie to the library
elif item.action == "add_to_library":
from core import videolibrarytools
videolibrarytools.add_to_videolibrary(item, channel)
# Special action for adding a undefined to the library # Special action for adding a serie to the library
elif item.action == "add_to_library": elif item.action == "add_to_library":
from core import videolibrarytools from core import videolibrarytools
videolibrarytools.add_to_videolibrary(item, channel) videolibrarytools.add_to_videolibrary(item, channel)
+24 -28
View File
@@ -293,26 +293,28 @@ def dialog_busy(state):
else: xbmc.executebuiltin('Dialog.Close(busydialognocancel)') else: xbmc.executebuiltin('Dialog.Close(busydialognocancel)')
def itemlist_refresh(offset=0): def itemlist_refresh(offset=0, disable=False):
try: if disable:
_id = xbmcgui.getCurrentWindowId()
win = xbmcgui.Window(_id)
cid = win.getFocusId()
ctl = win.getControl(cid)
pos = Item().fromurl(xbmc.getInfoLabel('ListItem.FileNameAndPath')).itemlistPosition + offset
logger.debug('ID:', _id, 'POSITION:', pos)
xbmc.executebuiltin("Container.Refresh") xbmc.executebuiltin("Container.Refresh")
# xbmc.executebuiltin('ReloadSkin()') else:
try:
_id = xbmcgui.getCurrentWindowId()
win = xbmcgui.Window(_id)
cid = win.getFocusId()
ctl = win.getControl(cid)
pos = Item().fromurl(xbmc.getInfoLabel('ListItem.FileNameAndPath')).itemlistPosition + offset
logger.debug('ID:', _id, 'POSITION:', pos)
xbmc.executebuiltin("Container.Refresh")
# xbmc.executebuiltin('ReloadSkin()')
while xbmcgui.getCurrentWindowDialogId() != 10138: while xbmcgui.getCurrentWindowDialogId() != 10138:
pass pass
while xbmcgui.getCurrentWindowDialogId() == 10138: while xbmcgui.getCurrentWindowDialogId() == 10138:
pass pass
ctl.selectItem(pos) ctl.selectItem(pos)
except: except:
xbmc.executebuiltin("Container.Refresh") xbmc.executebuiltin("Container.Refresh")
# xbmc.executebuiltin('ReloadSkin()')
def itemlist_update(item, replace=False): def itemlist_update(item, replace=False):
@@ -427,7 +429,7 @@ def render_items(itemlist, parent_item):
# r_list = [set_item(i, item, parent_item) for i, item in enumerate(itemlist)] # r_list = [set_item(i, item, parent_item) for i, item in enumerate(itemlist)]
r_list = [] r_list = []
position = 0 position = None
with futures.ThreadPoolExecutor() as executor: with futures.ThreadPoolExecutor() as executor:
searchList = [executor.submit(set_item, i, item, parent_item) for i, item in enumerate(itemlist)] searchList = [executor.submit(set_item, i, item, parent_item) for i, item in enumerate(itemlist)]
@@ -438,7 +440,7 @@ def render_items(itemlist, parent_item):
for item, item_url, listitem in r_list: for item, item_url, listitem in r_list:
if not position and not item.infoLabels.get('playcount', 0): if position == None and not item.infoLabels.get('playcount', 0) and item.channel != 'downloads':
position = item.itemlistPosition position = item.itemlistPosition
dirItems.append(('%s?%s' % (sys.argv[0], item_url), listitem, item.folder, len(r_list))) dirItems.append(('%s?%s' % (sys.argv[0], item_url), listitem, item.folder, len(r_list)))
xbmcplugin.addDirectoryItems(_handle, dirItems) xbmcplugin.addDirectoryItems(_handle, dirItems)
@@ -466,8 +468,7 @@ def render_items(itemlist, parent_item):
logger.debug('END render_items') logger.debug('END render_items')
if parent_item.channel == 'videolibrary' and parent_item.action in ['get_episodes', 'get_season']: if parent_item.channel == 'videolibrary' and parent_item.action in ['get_episodes', 'get_seasons'] and position:
while xbmcgui.getCurrentWindowDialogId() == 10138: while xbmcgui.getCurrentWindowDialogId() == 10138:
logger.debug('WINDOW ID', xbmcgui.getCurrentWindowDialogId()) logger.debug('WINDOW ID', xbmcgui.getCurrentWindowDialogId())
xbmc.sleep(100) xbmc.sleep(100)
@@ -475,7 +476,7 @@ def render_items(itemlist, parent_item):
win = xbmcgui.Window(10025) win = xbmcgui.Window(10025)
cid = win.getFocusId() cid = win.getFocusId()
ctl = win.getControl(cid) ctl = win.getControl(cid)
pos = position + (1 if xbmc.getInfoLabel('Container(10138).HasParent') else 0) pos = position + (1 if xbmc.getInfoLabel('Container(10138).HasParent') else 0)
ctl.selectItem(pos) ctl.selectItem(pos)
@@ -711,12 +712,7 @@ def set_context_commands(item, item_url, parent_item, **kwargs):
if item.channel != "videolibrary" and item.videolibrary != False and not item.disable_videolibrary: if item.channel != "videolibrary" and item.videolibrary != False and not item.disable_videolibrary:
# Add Series to the video library # Add Series to the video library
if item.action in ["episodios", "get_episodios", "get_seasons"] and item.contentSerieName: if item.contentTitle or item.contentSerieName:
context_commands.append((config.get_localized_string(60352), "RunPlugin(%s?%s&%s)" % (sys.argv[0], item_url, 'action=add_serie_to_library&from_action={}&contentChannel=videolibrary'.format(item.action))))
# Add Movie to Video Library
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_movie_to_library&from_action={}&contentChannel=videolibrary'.format(item.action))))
elif item.action in ['check'] and item.contentTitle or item.contentSerieName:
context_commands.append((config.get_localized_string(30161), "RunPlugin(%s?%s&%s)" % (sys.argv[0], item_url, 'action=add_to_library&from_action={}&contentChannel=videolibrary'.format(item.action)))) context_commands.append((config.get_localized_string(30161), "RunPlugin(%s?%s&%s)" % (sys.argv[0], item_url, 'action=add_to_library&from_action={}&contentChannel=videolibrary'.format(item.action))))
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') and not item.disable_videolibrary: 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') and not item.disable_videolibrary:
+22 -22
View File
@@ -260,33 +260,33 @@ def mark_content_as_watched_on_kodi(item, value=1):
@param value: > 0 for seen, 0 for not seen @param value: > 0 for seen, 0 for not seen
""" """
logger.debug() logger.debug()
# from core.support import dbg;dbg()
conn = sqlite3.connect(get_file_db()) if item.contentType == 'movie':
view = 'episode' if item.contentType != 'movie' else 'movie' conn = sqlite3.connect(get_file_db())
path = '%{}%'.format(item.strm_path.split('\\')[0].split('/')[0] if item.strm_path else item.base_name) path = '%{}%'.format(item.strm_path.split('\\')[0].split('/')[0] if item.strm_path else item.base_name)
sql = 'select idMovie from movie_view where strPath like "{}"'.format(path)
request_season = '' n, r = execute_sql_kodi(sql)
request_episode = '' if r:
if item.contentType in ['season', 'episode'] and item.contentSeason: request_season = ' and c12= {}'.format(item.contentSeason) payload = {"jsonrpc": "2.0", "method": "VideoLibrary.SetMovieDetails", "params": {"movieid": r[0][0], "playcount": value}, "id": 1}
if item.contentType in ['episode'] and item.contentEpisodeNumber: request_episode = ' and strFileName= "{}"'.format(item.strm_path.split('\\')[-1].split('/')[-1]) data = get_data(payload)
sql = 'select idFile from {}_view where strPath like "{}"{}{}'.format(view, path, request_episode, request_season)
n, r = execute_sql_kodi(sql, conn=conn) else:
if r: nun_records, records = execute_sql_kodi('SELECT idShow FROM tvshow_view WHERE uniqueid_value LIKE "{}"'.format(item.videolibrary_id))
sql = 'update files set playCount= {} where idFile= {}' # delete TV show
sql_actions = [sql.format(value, i[0]) for i in r] if records:
tvshowid = records[0][0]
cursor = conn.cursor() nun_records, records = execute_sql_kodi('SELECT idFile FROM episode WHERE idShow={}'.format(tvshowid))
for sql in sql_actions: sql = 'DELETE FROM files WHERE idFile IN (?)'
if type(sql) == list: params = [record[0] for record in records]
cursor.executemany(sql) sql = 'DELETE FROM files WHERE idFile IN {}'.format(tuple(params))
else: execute_sql_kodi(sql)
cursor.execute(sql)
conn.commit()
conn.close()
# platformtools.itemlist_refresh() payload = {"jsonrpc": "2.0", "method": "VideoLibrary.RemoveTVShow", "id": 1, "params": {"tvshowid": tvshowid}}
data = get_data(payload)
from platformcode.dbconverter import add_video;add_video(item)
def set_watched_on_kod(data): def set_watched_on_kod(data):
+63 -14
View File
@@ -331,7 +331,7 @@ def get_episodes(item):
def findvideos(item): def findvideos(item):
from core import autoplay from core import autoplay, servertools
from platformcode import platformtools from platformcode import platformtools
logger.debug() logger.debug()
if config.get_setting('next_ep') == 3 and item.contentType != 'movie': if config.get_setting('next_ep') == 3 and item.contentType != 'movie':
@@ -413,10 +413,9 @@ def findvideos(item):
if config.get_setting('autoplay'): if config.get_setting('autoplay'):
itemlist = autoplay.start(itemlist, item) itemlist = autoplay.start(itemlist, item)
else: else:
itemlist.sort(key=lambda it: (videolibrarytools.quality_order.index(it.quality.lower()) if it.quality and it.quality.lower() in videolibrarytools.quality_order else 999, it.server)) servertools.sort_servers(itemlist)
if config.get_setting('checklinks') and not config.get_setting('autoplay'): if config.get_setting('checklinks') and not config.get_setting('autoplay'):
from core import servertools
itemlist = servertools.check_list_links(itemlist, config.get_setting('checklinks_number')) itemlist = servertools.check_list_links(itemlist, config.get_setting('checklinks_number'))
if item.window: if item.window:
@@ -643,7 +642,7 @@ def mark_content_as_watched(item):
self.seasons = videolibrarydb['season'][self.item.videolibrary_id] self.seasons = videolibrarydb['season'][self.item.videolibrary_id]
self.episodes = videolibrarydb['episode'][self.item.videolibrary_id] self.episodes = videolibrarydb['episode'][self.item.videolibrary_id]
getattr(self, 'mark_' + self.item.contentType)() getattr(self, 'mark_' + (self.item.mark if self.item.mark else self.item.contentType))()
videolibrarydb.close() videolibrarydb.close()
if config.is_xbmc() and not self.item.not_update: if config.is_xbmc() and not self.item.not_update:
@@ -653,13 +652,51 @@ def mark_content_as_watched(item):
xbmc_videolibrary.mark_content_as_watched_on_kodi(movie, self.playcount) xbmc_videolibrary.mark_content_as_watched_on_kodi(movie, self.playcount)
else: else:
it = None it = None
if item.contentType == 'movie': it = self.movie if self.item.contentType == 'movie': it = self.movie['item']
elif item.contentType == 'episode': it = self.episodes['{:d}x{:02d}'.format(self.s, self.e)]['item'] elif self.item.contentType == 'episode': it = self.episodes['{:d}x{:02d}'.format(self.s, self.e)]['item']
elif item.contentType == 'tvshow': it = self.tvshow['item'] else: it = self.tvshow['item']
elif item.contentType == 'season': it = self.seasons[self.s] # elif self.item.contentType == 'season': it = self.seasons[self.s]
if it: xbmc_videolibrary.mark_content_as_watched_on_kodi(it, self.playcount) if it: xbmc_videolibrary.mark_content_as_watched_on_kodi(it, self.playcount)
platformtools.itemlist_refresh() platformtools.itemlist_refresh(1, True if item.contentType in ['season', 'episode'] else False)
def mark_previous(self):
if self.item.contentType == 'episode':
current_episode = current_playcount = self.episodes['{:d}x{:02d}'.format(self.s, self.e)]['item']
seasons = [s for s in self.seasons.keys()]
seasons.sort()
for it in self.episodes.values():
if (it['item'].contentSeason == current_episode.contentSeason and it['item'].contentEpisodeNumber < current_episode.contentEpisodeNumber) or it['item'].contentSeason < current_episode.contentSeason:
it['item'].infoLabels['playcount'] = 1
videolibrarydb['episode'][self.item.videolibrary_id] = self.episodes
for s in range(seasons[0], self.item.contentSeason + 1):
self.s = s
self.check_playcount('episode')
elif self.item.contentType == 'season':
seasons = [s for s in self.seasons.keys()]
seasons.sort()
for s in range(seasons[0], self.s):
self.s = s
self.mark_season()
def mark_following(self):
if self.item.contentType == 'episode':
current_episode = current_playcount = self.episodes['{:d}x{:02d}'.format(self.s, self.e)]['item']
seasons = [s for s in self.seasons.keys()]
seasons.sort()
for it in self.episodes.values():
if (it['item'].contentSeason == current_episode.contentSeason and it['item'].contentEpisodeNumber > current_episode.contentEpisodeNumber) or it['item'].contentSeason > current_episode.contentSeason:
it['item'].infoLabels['playcount'] = 0
videolibrarydb['episode'][self.item.videolibrary_id] = self.episodes
for s in range(self.item.contentSeason, seasons[-1] + 1):
self.s = s
self.check_playcount('episode')
elif self.item.contentType == 'season':
seasons = [s for s in self.seasons.keys()]
seasons.sort()
for s in range(self.s + 1, seasons[-1] + 1):
self.s = s
self.mark_season()
def mark_episode(self): def mark_episode(self):
current_playcount = self.episodes['{:d}x{:02d}'.format(self.s, self.e)]['item'].infoLabels['playcount'] current_playcount = self.episodes['{:d}x{:02d}'.format(self.s, self.e)]['item'].infoLabels['playcount']
@@ -683,7 +720,7 @@ def mark_content_as_watched(item):
self.seasons[self.s].infoLabels['playcount'] = 0 self.seasons[self.s].infoLabels['playcount'] = 0
videolibrarydb['season'][self.item.videolibrary_id] = self.seasons videolibrarydb['season'][self.item.videolibrary_id] = self.seasons
self.mark_all('episodes') self.mark_all('season_episodes')
if current_playcount == 0 or self.playcount == 0: if current_playcount == 0 or self.playcount == 0:
self.check_playcount('season') self.check_playcount('season')
@@ -729,7 +766,10 @@ def mark_content_as_watched(item):
if len(watched) == len(episodes): if len(watched) == len(episodes):
season_playcount = self.playcount season_playcount = self.playcount
self.tvshow['item'].infoLabels['playcount'] = tv_playcount self.tvshow['item'].infoLabels['playcount'] = tv_playcount
self.seasons[self.s].infoLabels['playcount'] = season_playcount try:
self.seasons[self.s].infoLabels['playcount'] = season_playcount
except:
logger.debug('No Season')
videolibrarydb['season'][self.item.videolibrary_id] = self.seasons videolibrarydb['season'][self.item.videolibrary_id] = self.seasons
else: else:
watched = [s for s in self.seasons.values() if s.infoLabels['playcount'] > 0] watched = [s for s in self.seasons.values() if s.infoLabels['playcount'] > 0]
@@ -739,8 +779,11 @@ def mark_content_as_watched(item):
videolibrarydb['tvshow'][self.item.videolibrary_id] = self.tvshow videolibrarydb['tvshow'][self.item.videolibrary_id] = self.tvshow
def mark_all(self, _type): def mark_all(self, _type):
episodes = [e for e in self.episodes.values() if e['item'].contentSeason == self.s] if _type == 'season_episodes':
if _type == 'episodes': episodes = [e for e in self.episodes.values() if e['item'].contentSeason == self.s]
for e in episodes:
e['item'].infoLabels['playcount'] = self.playcount
elif _type == 'episodes':
for n, ep in self.episodes.items(): for n, ep in self.episodes.items():
self.episodes[n]['item'].infoLabels['playcount'] = self.playcount self.episodes[n]['item'].infoLabels['playcount'] = self.playcount
# self.check_playcount('season') # self.check_playcount('season')
@@ -842,6 +885,7 @@ class subcontext(object):
return config.get_localized_string(self.titledict[self.item.contentType][_type]) return config.get_localized_string(self.titledict[self.item.contentType][_type])
def makecontext(self): def makecontext(self):
# support.dbg()
# set watched # set watched
# if not self.item.set: # if not self.item.set:
watched = self.item.infoLabels.get('playcount', 0) watched = self.item.infoLabels.get('playcount', 0)
@@ -852,7 +896,11 @@ class subcontext(object):
title = self.title('watched') title = self.title('watched')
value = 1 value = 1
self.context.append(title) self.context.append(title)
self.context.append('Segna precedenti come visti')
self.context.append('Segna successivi come non visti')
self.commands.append(self.item.clone(action='mark_content_as_watched', playcount=value)) self.commands.append(self.item.clone(action='mark_content_as_watched', playcount=value))
self.commands.append(self.item.clone(action='mark_content_as_watched', playcount=value, mark='previous'))
self.commands.append(self.item.clone(action='mark_content_as_watched', playcount=value, mark='following'))
if self.item.contentType in ['movie', 'tvshow', 'list']: if self.item.contentType in ['movie', 'tvshow', 'list']:
# delete # delete
@@ -1058,7 +1106,8 @@ def delete(item):
if config.is_xbmc() and config.get_setting('videolibrary_kodi'): if config.is_xbmc() and config.get_setting('videolibrary_kodi'):
from platformcode import xbmc_videolibrary from platformcode import xbmc_videolibrary
xbmc_videolibrary.clean_by_id(item) xbmc_videolibrary.clean_by_id(item)
platformtools.itemlist_refresh(-1) else:
platformtools.itemlist_refresh(-1)
# delete channel from video item # delete channel from video item
if select and select > 0: if select and select > 0: