KoD 0.9.1

- fix vari ed eventuali
This commit is contained in:
marco
2020-04-20 23:49:45 +02:00
parent dc3d2d4d2a
commit ca0b5a8c56
28 changed files with 1048 additions and 798 deletions

View File

@@ -8,7 +8,7 @@ standard_library.install_aliases()
import sys
PY3 = False
if sys.version_info[0] >= 3: PY3 = True; unicode = str; unichr = chr; long = int
import os
import threading
import time
@@ -216,7 +216,6 @@ def sync_trakt_kodi(silent=True):
if notificacion:
platformtools.dialog_notification(config.get_localized_string(20000),
config.get_localized_string(60045),
icon=0,
time=2000)
@@ -334,7 +333,7 @@ def mark_season_as_watched_on_kodi(item, value=1):
def mark_content_as_watched_on_alfa(path):
from specials import videolibrary
from core import videolibrarytools
"""
marca toda la serie o película como vista o no vista en la Videoteca de Alfa basado en su estado en la Videoteca de Kodi
@type str: path
@@ -342,7 +341,7 @@ def mark_content_as_watched_on_alfa(path):
"""
logger.info()
#logger.debug("path: " + path)
FOLDER_MOVIES = config.get_setting("folder_movies")
FOLDER_TVSHOWS = config.get_setting("folder_tvshows")
VIDEOLIBRARY_PATH = config.get_videolibrary_config_path()
@@ -353,7 +352,7 @@ def mark_content_as_watched_on_alfa(path):
# en caso de compartir BBDD esta funcionalidad no funcionara
#if config.get_setting("db_mode", "videolibrary"):
# return
path2 = ''
if "special://" in VIDEOLIBRARY_PATH:
if FOLDER_TVSHOWS in path:
@@ -376,7 +375,7 @@ def mark_content_as_watched_on_alfa(path):
path2 = path1.replace("\\", "/") #Formato no Windows
else:
path2 = path2.replace(nfo_name, '')
else:
contentType = "movie_view" #Marco la tabla de BBDD de Kodi Video
path1 = path.replace("\\\\", "\\") #Formato Windows
@@ -386,7 +385,7 @@ def mark_content_as_watched_on_alfa(path):
path1 = path1.replace(nfo_name, '') #para la SQL solo necesito la carpeta
path2 = path2.replace(nfo_name, '') #para la SQL solo necesito la carpeta
path2 = filetools.remove_smb_credential(path2) #Si el archivo está en un servidor SMB, quitamos las credenciales
#Ejecutmos la sentencia SQL
sql = 'select strFileName, playCount from %s where (strPath like "%s" or strPath like "%s")' % (contentType, path1, path2)
nun_records = 0
@@ -395,7 +394,7 @@ def mark_content_as_watched_on_alfa(path):
if nun_records == 0: #hay error?
logger.error("Error en la SQL: " + sql + ": 0 registros")
return #salimos: o no está catalogado en Kodi, o hay un error en la SQL
for title, playCount in records: #Ahora recorremos todos los registros obtenidos
if contentType == "episode_view":
title_plain = title.replace('.strm', '') #Si es Serie, quitamos el sufijo .strm
@@ -419,10 +418,10 @@ def mark_content_as_watched_on_alfa(path):
item = videolibrary.check_season_playcount(item, season_num) #llamamos al método que actualiza Temps. y Series
filetools.write(path, head_nfo + item.tojson())
#logger.debug(item)
def get_data(payload):
"""
obtiene la información de la llamada JSON-RPC con la información pasada en payload
@@ -512,7 +511,7 @@ def update(folder_content=config.get_setting("folder_tvshows"), folder=""):
data = get_data(payload)
xbmc.executebuiltin('XBMC.ReloadSkin()')
#xbmc.executebuiltin('XBMC.ReloadSkin()')
def search_library_path():
@@ -701,7 +700,7 @@ def set_content(content_type, silent=False, custom=False):
if seleccion == -1 or seleccion == 0:
strScraper = 'metadata.themoviedb.org'
path_settings = xbmc.translatePath("special://profile/addon_data/metadata.themoviedb.org/settings.xml")
elif seleccion == 1:
elif seleccion == 1:
strScraper = 'metadata.universal'
path_settings = xbmc.translatePath("special://profile/addon_data/metadata.universal/settings.xml")
if not os.path.exists(path_settings):
@@ -720,7 +719,7 @@ def set_content(content_type, silent=False, custom=False):
if seleccion == -1 or seleccion == 0:
strScraper = 'metadata.tvdb.com'
path_settings = xbmc.translatePath("special://profile/addon_data/metadata.tvdb.com/settings.xml")
elif seleccion == 1:
elif seleccion == 1:
strScraper = 'metadata.tvshows.themoviedb.org'
path_settings = xbmc.translatePath("special://profile/addon_data/metadata.tvshows.themoviedb.org/settings.xml")
if not os.path.exists(path_settings):
@@ -878,7 +877,7 @@ def update_db(old_path, new_path, old_movies_folder, new_movies_folder, old_tvsh
xbmc.executebuiltin('XBMC.ReloadSkin()')
def clean(path=''):
def clean(path_list=[]):
def sql_format(path):
if path.startswith("special://"):
path = path.replace('/profile/', '/%/').replace('/home/userdata/', '/%/')
@@ -894,127 +893,125 @@ def clean(path=''):
logger.info()
idParentPath = 0
sql_path = ''
sql_movies_path = ''
sql_tvshows_path = ''
sql_episodes_path = ''
path, sep = sql_format(path)
movies_folder = config.get_setting("folder_movies")
tvshows_folder = config.get_setting("folder_tvshows")
# delete episode/movie (downloads.py move_to_libray)
if path.endswith(".strm"):
if movies_folder in path:
sql_movies_path = path
else:
sql_episodes_path = path
# delete movie
elif movies_folder in path:
if not path.endswith(sep): path += sep
sql_movies_path = path + '%'
# delete tvshow
elif tvshows_folder in path:
if not path.endswith(sep): path += sep
sql_tvshows_path = path + '%'
sql_episodes_path = sql_tvshows_path
# delete video library
else:
if not path.endswith(sep): path += sep
sql_path = path
sql_movies_path = sql_path + movies_folder
if not sql_movies_path.endswith(sep): sql_movies_path += sep
sql_movies_path += '%'
sql_tvshows_path = sql_path + tvshows_folder
if not sql_tvshows_path.endswith(sep): sql_tvshows_path += sep
sql_tvshows_path += '%'
sql_episodes_path = sql_tvshows_path
progress = platformtools.dialog_progress_bg(config.get_localized_string(20000), config.get_localized_string(80025))
progress.update(0)
if sql_path:
# search video library path in the DB
sql = 'SELECT idPath FROM path where strPath LIKE "%s"' % sql_path
nun_records, records = execute_sql_kodi(sql)
# delete video library path
if records:
idPath = records[0][0]
idParentPath = idPath
if not config.get_setting("videolibrary_kodi"):
sql = 'DELETE from path WHERE idPath=%s' % idPath
nun_records, records = execute_sql_kodi(sql)
progress.update(10)
if sql_movies_path:
# search movies in the DB
sql = 'SELECT idMovie FROM movie where c22 LIKE "%s"' % sql_movies_path
nun_records, records = execute_sql_kodi(sql)
# delete movies
if records:
for record in records:
idMovie = record[0]
sql = 'DELETE from movie WHERE idMovie=%s' % idMovie
nun_records, records = execute_sql_kodi(sql)
for path in path_list:
progress.update(28)
if sql_movies_path:
# search movies path and folders in the DB
sql = 'SELECT idPath, idParentPath FROM path where strPath LIKE "%s"' % sql_movies_path
nun_records, records = execute_sql_kodi(sql)
# delete movies path and folders
if records:
for record in records:
if record[1] == idParentPath and config.get_setting("videolibrary_kodi"):
continue
idPath = record[0]
sql = 'DELETE from path WHERE idPath=%s' % idPath
nun_records, records = execute_sql_kodi(sql)
idParentPath = 0
sql_path = ''
sql_movies_path = ''
sql_tvshows_path = ''
sql_episodes_path = ''
progress.update(46)
if sql_tvshows_path:
# search TV shows in the DB
sql = 'SELECT idShow FROM tvshow_view where strPath LIKE "%s"' % sql_tvshows_path
nun_records, records = execute_sql_kodi(sql)
# delete TV shows
if records:
for record in records:
idShow = record[0]
sql = 'DELETE from tvshow WHERE idShow=%s' % idShow
nun_records, records = execute_sql_kodi(sql)
path, sep = sql_format(path)
movies_folder = config.get_setting("folder_movies")
tvshows_folder = config.get_setting("folder_tvshows")
progress.update(64)
if sql_episodes_path:
# search episodes in the DB
sql = 'SELECT idEpisode FROM episode where c18 LIKE "%s"' % sql_episodes_path
nun_records, records = execute_sql_kodi(sql)
# delete episodes
if records:
for record in records:
idEpisode = record[0]
sql = 'DELETE from episode WHERE idEpisode=%s' % idEpisode
nun_records, records = execute_sql_kodi(sql)
# delete episode/movie (downloads.py move_to_libray)
if path.endswith(".strm"):
if movies_folder in path:
sql_movies_path = path
else:
sql_episodes_path = path
# delete movie
elif movies_folder in path:
if not path.endswith(sep): path += sep
progress.update(82)
if sql_tvshows_path:
# search TV shows path and folders in the DB
sql = 'SELECT idPath, idParentPath FROM path where strPath LIKE "%s"' % sql_tvshows_path
nun_records, records = execute_sql_kodi(sql)
# delete tvshows path and folders
if records:
for record in records:
if record[1] == idParentPath and config.get_setting("videolibrary_kodi"):
continue
idPath = record[0]
sql = 'DELETE from path WHERE idPath=%s' % idPath
nun_records, records = execute_sql_kodi(sql)
sql_movies_path = path + '%'
# delete tvshow
elif tvshows_folder in path:
if not path.endswith(sep): path += sep
sql_tvshows_path = path + '%'
sql_episodes_path = sql_tvshows_path
# delete video library
else:
if not path.endswith(sep): path += sep
sql_path = path
sql_movies_path = sql_path + movies_folder
if not sql_movies_path.endswith(sep): sql_movies_path += sep
sql_movies_path += '%'
sql_tvshows_path = sql_path + tvshows_folder
if not sql_tvshows_path.endswith(sep): sql_tvshows_path += sep
sql_tvshows_path += '%'
sql_episodes_path = sql_tvshows_path
if sql_path:
# search video library path in the DB
sql = 'SELECT idPath FROM path where strPath LIKE "%s"' % sql_path
nun_records, records = execute_sql_kodi(sql)
# delete video library path
if records:
idPath = records[0][0]
idParentPath = idPath
if not config.get_setting("videolibrary_kodi"):
sql = 'DELETE from path WHERE idPath=%s' % idPath
nun_records, records = execute_sql_kodi(sql)
if sql_movies_path:
# search movies in the DB
sql = 'SELECT idMovie FROM movie where c22 LIKE "%s"' % sql_movies_path
nun_records, records = execute_sql_kodi(sql)
# delete movies
if records:
for record in records:
idMovie = record[0]
sql = 'DELETE from movie WHERE idMovie=%s' % idMovie
nun_records, records = execute_sql_kodi(sql)
if sql_movies_path:
# search movies path and folders in the DB
sql = 'SELECT idPath, idParentPath FROM path where strPath LIKE "%s"' % sql_movies_path
nun_records, records = execute_sql_kodi(sql)
# delete movies path and folders
if records:
for record in records:
if record[1] == idParentPath and config.get_setting("videolibrary_kodi"):
continue
idPath = record[0]
sql = 'DELETE from path WHERE idPath=%s' % idPath
nun_records, records = execute_sql_kodi(sql)
if sql_tvshows_path:
# search TV shows in the DB
sql = 'SELECT idShow FROM tvshow_view where strPath LIKE "%s"' % sql_tvshows_path
nun_records, records = execute_sql_kodi(sql)
# delete TV shows
if records:
for record in records:
idShow = record[0]
sql = 'DELETE from tvshow WHERE idShow=%s' % idShow
nun_records, records = execute_sql_kodi(sql)
if sql_episodes_path:
# search episodes in the DB
sql = 'SELECT idEpisode FROM episode where c18 LIKE "%s"' % sql_episodes_path
nun_records, records = execute_sql_kodi(sql)
# delete episodes
if records:
for record in records:
idEpisode = record[0]
sql = 'DELETE from episode WHERE idEpisode=%s' % idEpisode
nun_records, records = execute_sql_kodi(sql)
if sql_tvshows_path:
# search TV shows path and folders in the DB
sql = 'SELECT idPath, idParentPath FROM path where strPath LIKE "%s"' % sql_tvshows_path
nun_records, records = execute_sql_kodi(sql)
# delete tvshows path and folders
if records:
for record in records:
if record[1] == idParentPath and config.get_setting("videolibrary_kodi"):
continue
idPath = record[0]
sql = 'DELETE from path WHERE idPath=%s' % idPath
nun_records, records = execute_sql_kodi(sql)
progress.update(100)
xbmc.sleep(1000)