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

View File

@@ -289,9 +289,9 @@ class addMovie(object):
def set_files(self):
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 ( ?, ?, ?, ?, ?, ?)'
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:
sql = 'INSERT OR IGNORE INTO files (idFile, idPath, strFilename, dateAdded) VALUES ( ?, ?, ?, ?)'
params = (self.idFile, self.idPath, self.strFilename, date)
@@ -331,7 +331,7 @@ class addMovie(object):
writer_link_params = []
directors = self.info.get('director', '').split(', ')
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_image = self.info.get('writer_image', [])
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}
self.idFiles = {}
idFile = get_id('idFile', 'files')
# support.dbg()
for episode in self.idEpisodes.keys():
if episode in files.keys():
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:
if self.item.playcount:
if self.episodes[episode]['item'].infoLabels.get('playcount', None):
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:
sql = 'INSERT INTO files (idFile, idPath, strFilename, dateAdded) VALUES ( ?, ?, ?, ?)'
params = (idFile, self.idPath, episode + '.strm', date)

View File

@@ -260,13 +260,8 @@ def run(item=None):
elif item.action == "add_serie_to_library":
from core import videolibrarytools
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":
from core import videolibrarytools
videolibrarytools.add_to_videolibrary(item, channel)

View File

@@ -293,26 +293,28 @@ def dialog_busy(state):
else: xbmc.executebuiltin('Dialog.Close(busydialognocancel)')
def itemlist_refresh(offset=0):
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)
def itemlist_refresh(offset=0, disable=False):
if disable:
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:
pass
while xbmcgui.getCurrentWindowDialogId() == 10138:
pass
while xbmcgui.getCurrentWindowDialogId() != 10138:
pass
while xbmcgui.getCurrentWindowDialogId() == 10138:
pass
ctl.selectItem(pos)
except:
xbmc.executebuiltin("Container.Refresh")
# xbmc.executebuiltin('ReloadSkin()')
ctl.selectItem(pos)
except:
xbmc.executebuiltin("Container.Refresh")
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 = []
position = 0
position = None
with futures.ThreadPoolExecutor() as executor:
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:
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
dirItems.append(('%s?%s' % (sys.argv[0], item_url), listitem, item.folder, len(r_list)))
xbmcplugin.addDirectoryItems(_handle, dirItems)
@@ -466,8 +468,7 @@ def render_items(itemlist, parent_item):
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:
logger.debug('WINDOW ID', xbmcgui.getCurrentWindowDialogId())
xbmc.sleep(100)
@@ -475,7 +476,7 @@ def render_items(itemlist, parent_item):
win = xbmcgui.Window(10025)
cid = win.getFocusId()
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)
@@ -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:
# Add Series to the video library
if item.action in ["episodios", "get_episodios", "get_seasons"] and 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:
if 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))))
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:

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
"""
logger.debug()
# from core.support import dbg;dbg()
conn = sqlite3.connect(get_file_db())
view = 'episode' if item.contentType != 'movie' else 'movie'
path = '%{}%'.format(item.strm_path.split('\\')[0].split('/')[0] if item.strm_path else item.base_name)
if item.contentType == 'movie':
conn = sqlite3.connect(get_file_db())
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 = ''
request_episode = ''
if item.contentType in ['season', 'episode'] and item.contentSeason: request_season = ' and c12= {}'.format(item.contentSeason)
if item.contentType in ['episode'] and item.contentEpisodeNumber: request_episode = ' and strFileName= "{}"'.format(item.strm_path.split('\\')[-1].split('/')[-1])
sql = 'select idFile from {}_view where strPath like "{}"{}{}'.format(view, path, request_episode, request_season)
n, r = execute_sql_kodi(sql)
if r:
payload = {"jsonrpc": "2.0", "method": "VideoLibrary.SetMovieDetails", "params": {"movieid": r[0][0], "playcount": value}, "id": 1}
data = get_data(payload)
n, r = execute_sql_kodi(sql, conn=conn)
if r:
sql = 'update files set playCount= {} where idFile= {}'
sql_actions = [sql.format(value, i[0]) for i in r]
else:
nun_records, records = execute_sql_kodi('SELECT idShow FROM tvshow_view WHERE uniqueid_value LIKE "{}"'.format(item.videolibrary_id))
# delete TV show
if records:
tvshowid = records[0][0]
cursor = conn.cursor()
for sql in sql_actions:
if type(sql) == list:
cursor.executemany(sql)
else:
cursor.execute(sql)
conn.commit()
conn.close()
nun_records, records = execute_sql_kodi('SELECT idFile FROM episode WHERE idShow={}'.format(tvshowid))
sql = 'DELETE FROM files WHERE idFile IN (?)'
params = [record[0] for record in records]
sql = 'DELETE FROM files WHERE idFile IN {}'.format(tuple(params))
execute_sql_kodi(sql)
# 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):