Minori informazioni con log disabilitato

This commit is contained in:
Alhaziel01
2020-11-25 17:54:25 +01:00
parent 9f11eac225
commit 4f498a05f8
157 changed files with 720 additions and 726 deletions

View File

@@ -25,14 +25,14 @@ TYPE = "Type"
# helper Functions
def check(item):
logger.info()
logger.debug()
dict_series = load(item)
title = item.fulltitle.rstrip()
if title in dict_series: title = dict_series[title]
return True if ID in title and EPISODE in title else False
def filename(item):
logger.info()
logger.debug()
name_file = item.channel + "_data.json"
path = filetools.join(config.get_data_path(), "settings_channels")
fname = filetools.join(path, name_file)
@@ -40,7 +40,7 @@ def filename(item):
def load(item):
logger.info()
logger.debug()
try:
json_file = open(filename(item), "r").read()
json = jsontools.load(json_file)[TVSHOW_RENUMERATE]
@@ -52,7 +52,7 @@ def load(item):
def write(item, json):
logger.info()
logger.debug()
json_file = open(filename(item), "r").read()
js = jsontools.load(json_file)
js[TVSHOW_RENUMERATE] = json
@@ -71,7 +71,7 @@ def b64(json, mode = 'encode'):
def RepresentsInt(s):
# Controllo Numro Stagione
logger.info()
logger.debug()
try:
int(s)
return True
@@ -79,7 +79,7 @@ def RepresentsInt(s):
return False
def find_episodes(item):
logger.info()
logger.debug()
ch = __import__('channels.' + item.channel, fromlist=["channels.%s" % item.channel])
itemlist = ch.episodios(item)
return itemlist
@@ -705,7 +705,7 @@ class SelectreNumerationWindow(xbmcgui.WindowXMLDialog):
items.append(item)
self.seasons[item.getLabel()] = '%sx%s' % (item.getProperty('season'), item.getProperty('episode'))
self.items = items
logger.info('SELF',self.seasons)
logger.debug('SELF',self.seasons)
def addseasons(self):
seasonlist = []

View File

@@ -59,7 +59,7 @@ SERVERLIST = 300
class SearchWindow(xbmcgui.WindowXML):
def start(self, item):
logger.info()
logger.debug()
self.exit = False
self.item = item
self.lastSearch()
@@ -81,7 +81,7 @@ class SearchWindow(xbmcgui.WindowXML):
self.doModal()
def lastSearch(self):
logger.info()
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 = ''
@@ -89,7 +89,7 @@ class SearchWindow(xbmcgui.WindowXML):
if self.item.text: channeltools.set_channel_setting('Last_searched', self.item.text, 'search')
def select(self):
logger.info()
logger.debug()
self.PROGRESS.setVisible(False)
items = []
if self.persons:
@@ -122,7 +122,7 @@ class SearchWindow(xbmcgui.WindowXML):
self.NORESULTS.setVisible(True)
def actors(self):
logger.info()
logger.debug()
self.PROGRESS.setVisible(False)
items = []
@@ -174,7 +174,7 @@ class SearchWindow(xbmcgui.WindowXML):
self.NORESULTS.setVisible(True)
def get_channels(self):
logger.info()
logger.debug()
channels_list = []
all_channels = channelselector.filterchannels('all')
@@ -196,12 +196,12 @@ class SearchWindow(xbmcgui.WindowXML):
if config.get_setting("include_in_global_search", channel) and ch_param.get("active", False):
channels_list.append(channel)
logger.info('search in channels:',channels_list)
logger.debug('search in channels:',channels_list)
return channels_list
def getModule(self, channel):
logger.info()
logger.debug()
try:
module = __import__('channels.%s' % channel, fromlist=["channels.%s" % channel])
mainlist = getattr(module, 'mainlist')(Item(channel=channel, global_search=True))
@@ -233,7 +233,7 @@ class SearchWindow(xbmcgui.WindowXML):
executor.submit(self.get_channel_results, self.item, self.moduleDict, searchAction)
def get_channel_results(self, item, module_dict, search_action):
logger.info()
logger.debug()
channel = search_action.channel
results = []
valid = []
@@ -266,7 +266,7 @@ class SearchWindow(xbmcgui.WindowXML):
else: self.update(channel, valid + other)
def makeItem(self, item):
logger.info()
logger.debug()
thumb = item.thumbnail if item.thumbnail else 'Infoplus/' + item.contentType.replace('show','')
it = xbmcgui.ListItem(item.title)
it.setProperty('thumb', thumb)
@@ -282,7 +282,7 @@ class SearchWindow(xbmcgui.WindowXML):
return it
def update(self, channel, results):
logger.info('Search on channel', channel)
logger.debug('Search on channel', channel)
if results:
channelParams = channeltools.get_channel_parameters(channel)
name = channelParams['title']

View File

@@ -19,7 +19,7 @@ def start():
Within this function all calls should go to
functions that we want to execute as soon as we open the plugin.
"""
logger.info()
logger.debug()
# config.set_setting('show_once', True)
# Test if all the required directories are created
config.verify_directories_created()
@@ -37,7 +37,7 @@ def start():
updater.showSavedChangelog()
def run(item=None):
logger.info()
logger.debug()
if not item:
# Extract item from sys.argv
if sys.argv[2]:
@@ -94,7 +94,7 @@ def run(item=None):
# If item has no action, stops here
if item.action == "":
logger.info("Item without action")
logger.debug("Item without action")
return
# Action for main menu in channelselector
@@ -193,7 +193,7 @@ def run(item=None):
channel_file = os.path.join(config.get_runtime_path(), CHANNELS, item.channel + ".py")
logger.info("channel_file= " + channel_file + ' - ' + CHANNELS + ' - ' + item.channel)
logger.debug("channel_file= " + channel_file + ' - ' + CHANNELS + ' - ' + item.channel)
channel = None
@@ -213,12 +213,12 @@ def run(item=None):
trakt_tools.set_trakt_info(item)
except:
pass
logger.info("item.action=%s" % item.action.upper())
logger.debug("item.action=%s" % item.action.upper())
# logger.debug("item_toPlay: " + "\n" + item.tostring('\n'))
# First checks if channel has a "play" function
if hasattr(channel, 'play'):
logger.info("Executing channel 'play' method")
logger.debug("Executing channel 'play' method")
itemlist = channel.play(item)
b_favourite = item.isFavourite
# Play should return a list of playable URLS
@@ -239,7 +239,7 @@ def run(item=None):
# If player don't have a "play" function, not uses the standard play from platformtools
else:
logger.info("Executing core 'play' method")
logger.debug("Executing core 'play' method")
platformtools.play_video(item)
# Special action for findvideos, where the plugin looks for known urls
@@ -252,8 +252,7 @@ def run(item=None):
# If not, uses the generic findvideos function
else:
logger.info("No channel 'findvideos' method, "
"executing core method")
logger.debug("No channel 'findvideos' method, " "executing core method")
itemlist = servertools.find_video_items(item)
if config.get_setting("max_links", "videolibrary") != 0:
@@ -297,7 +296,7 @@ def run(item=None):
else:
filetools.remove(temp_search_file)
logger.info("item.action=%s" % item.action.upper())
logger.debug("item.action=%s" % item.action.upper())
from core import channeltools
if config.get_setting('last_search'):
@@ -318,7 +317,7 @@ def run(item=None):
# For all other actions
else:
# import web_pdb; web_pdb.set_trace()
logger.info("Executing channel '%s' method" % item.action)
logger.debug("Executing channel '%s' method" % item.action)
itemlist = getattr(channel, item.action)(item)
if config.get_setting('trakt_sync'):
from core import trakt_tools
@@ -399,7 +398,7 @@ def set_search_temp(item):
filetools.write(temp_search_file, f)
def reorder_itemlist(itemlist):
logger.info()
logger.debug()
# logger.debug("Inlet itemlist size: %i" % len(itemlist))
new_list = []
@@ -437,7 +436,7 @@ def reorder_itemlist(itemlist):
new_list.extend(mod_list)
new_list.extend(not_mod_list)
logger.info("Modified Titles:%i |Unmodified:%i" % (modified, not_modified))
logger.debug("Modified Titles:%i |Unmodified:%i" % (modified, not_modified))
if len(new_list) == 0:
new_list = itemlist
@@ -447,7 +446,7 @@ def reorder_itemlist(itemlist):
def limit_itemlist(itemlist):
logger.info()
logger.debug()
# logger.debug("Inlet itemlist size: %i" % len(itemlist))
try:
@@ -480,7 +479,7 @@ def play_from_library(item):
itemlist=[]
item.fromLibrary = True
logger.info()
logger.debug()
# logger.debug("item: \n" + item.tostring('\n'))
# Try to reproduce an image (this does nothing and also does not give an error)

View File

@@ -206,7 +206,7 @@ def render_items(itemlist, parent_item):
"""
Function used to render itemlist on kodi
"""
logger.info('START render_items')
logger.debug('START render_items')
thumb_type = config.get_setting('video_thumbnail_type')
from platformcode import shortcuts
# from core import httptools
@@ -291,7 +291,7 @@ def render_items(itemlist, parent_item):
set_view_mode(itemlist[0], parent_item)
xbmcplugin.endOfDirectory(_handle)
logger.info('END render_items')
logger.debug('END render_items')
def getCurrentView(item=None, parent_item=None):
@@ -348,11 +348,11 @@ def set_view_mode(item, parent_item):
if content:
mode = int(config.get_setting('view_mode_%s' % content).split(',')[-1])
if mode == 0:
logger.info('default mode')
logger.debug('default mode')
mode = 55
xbmcplugin.setContent(handle=int(sys.argv[1]), content=Type)
xbmc.executebuiltin('Container.SetViewMode(%s)' % mode)
logger.info('TYPE: ' + Type + ' - ' + 'CONTENT: ' + content)
logger.debug('TYPE: ' + Type + ' - ' + 'CONTENT: ' + content)
def set_infolabels(listitem, item, player=False):
@@ -572,10 +572,10 @@ def is_playing():
def play_video(item, strm=False, force_direct=False, autoplay=False):
logger.info()
logger.debug()
logger.debug(item.tostring('\n'))
if item.channel == 'downloads':
logger.info("Play local video: %s [%s]" % (item.title, item.url))
logger.debug("Play local video: %s [%s]" % (item.title, item.url))
xlistitem = xbmcgui.ListItem(path=item.url)
xlistitem.setArt({"thumb": item.thumbnail})
set_infolabels(xlistitem, item, True)
@@ -583,7 +583,7 @@ def play_video(item, strm=False, force_direct=False, autoplay=False):
return
default_action = config.get_setting("default_action")
logger.info("default_action=%s" % default_action)
logger.debug("default_action=%s" % default_action)
# Open the selection dialog to see the available options
opciones, video_urls, seleccion, salir = get_dialogo_opciones(item, default_action, strm, autoplay)
@@ -593,8 +593,8 @@ def play_video(item, strm=False, force_direct=False, autoplay=False):
seleccion = get_seleccion(default_action, opciones, seleccion, video_urls)
if seleccion < 0: return # Canceled box
logger.info("selection=%d" % seleccion)
logger.info("selection=%s" % opciones[seleccion])
logger.debug("selection=%d" % seleccion)
logger.debug("selection=%s" % opciones[seleccion])
# run the available option, jdwonloader, download, favorites, add to the video library ... IF IT IS NOT PLAY
salir = set_opcion(item, seleccion, opciones, video_urls)
@@ -755,7 +755,7 @@ def alert_unsopported_server():
def handle_wait(time_to_wait, title, text):
logger.info("handle_wait(time_to_wait=%d)" % time_to_wait)
logger.debug("handle_wait(time_to_wait=%d)" % time_to_wait)
espera = dialog_progress(' ' + title, "")
secs = 0
@@ -774,15 +774,15 @@ def handle_wait(time_to_wait, title, text):
break
if cancelled:
logger.info('Wait canceled')
logger.debug('Wait canceled')
return False
else:
logger.info('Wait finished')
logger.debug('Wait finished')
return True
def get_dialogo_opciones(item, default_action, strm, autoplay):
logger.info()
logger.debug()
# logger.debug(item.tostring('\n'))
from core import servertools
@@ -866,7 +866,7 @@ def get_dialogo_opciones(item, default_action, strm, autoplay):
def set_opcion(item, seleccion, opciones, video_urls):
logger.info()
logger.debug()
# logger.debug(item.tostring('\n'))
salir = False
# You have not chosen anything, most likely because you have given the ESC
@@ -916,7 +916,7 @@ def set_opcion(item, seleccion, opciones, video_urls):
def get_video_seleccionado(item, seleccion, video_urls):
logger.info()
logger.debug()
mediaurl = ""
view = False
wait_time = 0
@@ -942,7 +942,7 @@ def get_video_seleccionado(item, seleccion, video_urls):
mpd = True
# If there is no mediaurl it is because the video is not there :)
logger.info("mediaurl=" + mediaurl)
logger.debug("mediaurl=" + mediaurl)
if mediaurl == "":
if item.server == "unknown":
alert_unsopported_server()
@@ -959,7 +959,7 @@ def get_video_seleccionado(item, seleccion, video_urls):
def set_player(item, xlistitem, mediaurl, view, strm, nfo_path=None, head_nfo=None, item_nfo=None):
logger.info()
logger.debug()
# logger.debug("item:\n" + item.tostring('\n'))
# Moved del conector "torrent" here
if item.server == "torrent":
@@ -1046,7 +1046,7 @@ def torrent_client_installed(show_tuple=False):
def play_torrent(item, xlistitem, mediaurl):
logger.info()
logger.debug()
import time
from servers import torrent

View File

@@ -65,7 +65,7 @@ class Recaptcha(xbmcgui.WindowXMLDialog):
data = httptools.downloadpage(self.url, post=post, headers=self.headers).data
from platformcode import logger
logger.info(data)
logger.debug(data)
self.result = scrapertools.find_single_match(data, '<div class="fbc-verification-token">.*?>([^<]+)<')
if self.result:
platformtools.dialog_notification("Captcha corretto", "Verifica conclusa")

View File

@@ -126,7 +126,7 @@ def SettingOnPosition(item):
xbmc.executebuiltin('Addon.OpenSettings(plugin.video.kod)')
category = item.category if item.category else 0
setting = item.setting if item.setting else 0
logger.info('SETTING= ' + str(setting))
logger.debug('SETTING= ' + str(setting))
xbmc.executebuiltin('SetFocus(%i)' % (category - 100))
xbmc.executebuiltin('SetFocus(%i)' % (setting - 80))

View File

@@ -43,7 +43,7 @@ def set_menu_settings(item):
jsontools.update_node(menu_node, 'menu_settings_data.json', "menu")
def check_user_home(item):
logger.info()
logger.debug()
if os.path.exists(menu_settings_path):
menu_node = jsontools.get_node_from_file('menu_settings_data.json', 'menu')
if 'user_home' in menu_node:
@@ -55,7 +55,7 @@ def check_user_home(item):
return item
def set_custom_start(item):
logger.info()
logger.debug()
if os.path.exists(menu_settings_path):
menu_node = jsontools.get_node_from_file('menu_settings_data.json', 'menu')
else:
@@ -69,7 +69,7 @@ def set_custom_start(item):
jsontools.update_node(menu_node, 'menu_settings_data.json', "menu")
def get_start_page():
logger.info()
logger.debug()
dictCategory = {
config.get_localized_string(70137): 'peliculas',
@@ -355,7 +355,7 @@ class Main(xbmcgui.WindowXMLDialog):
self.focus -= 1
def run_action(self, item):
logger.info()
logger.debug()
if item.menu != True:
self.close()
xbmc.executebuiltin("Container.update(%s)"%launcher.run(item))

View File

@@ -84,7 +84,7 @@ def regex_tvshow(compare, file, sub=""):
def set_Subtitle():
logger.info()
logger.debug()
exts = [".srt", ".sub", ".txt", ".smi", ".ssa", ".ass"]
subtitle_folder_path = filetools.join(config.get_data_path(), "subtitles")
@@ -216,7 +216,7 @@ def searchSubtitle(item):
filetools.mkdir(full_path_tvshow) # title_new + ".mp4"
full_path_video_new = xbmc.translatePath(
filetools.join(full_path_tvshow, "%s %sx%s.mp4" % (tvshow_title, season, episode)))
logger.info(full_path_video_new)
logger.debug(full_path_video_new)
listitem = xbmcgui.ListItem(title_new, iconImage="DefaultVideo.png", thumbnailImage="")
listitem.setInfo("video", {"Title": title_new, "Genre": "Tv shows", "episode": int(episode), "season": int(season), "tvshowtitle": tvshow_title})
@@ -230,7 +230,7 @@ def searchSubtitle(item):
try:
filetools.copy(path_video_temp, full_path_video_new)
copy = True
logger.info("nuevo path =" + full_path_video_new)
logger.debug("nuevo path =" + full_path_video_new)
time.sleep(2)
playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
playlist.clear()
@@ -288,7 +288,7 @@ def get_from_subdivx(sub_url):
:return: The path to the unzipped subtitle
"""
logger.info()
logger.debug()
sub = ''
sub_dir = os.path.join(config.get_data_path(), 'temp_subs')
@@ -312,9 +312,9 @@ def get_from_subdivx(sub_url):
filetools.write(filename, data_dl)
sub = extract_file_online(sub_dir, filename)
except:
logger.info('sub invalid')
logger.debug('sub invalid')
else:
logger.info('sub invalid')
logger.debug('sub invalid')
return sub
@@ -328,7 +328,7 @@ def extract_file_online(path, filename):
:return:
"""
logger.info()
logger.debug()
url = "http://online.b1.org/rest/online/upload"

View File

@@ -32,7 +32,7 @@ class InfoWindow(xbmcgui.WindowXMLDialog):
self.scraper = scraper
self.doModal()
logger.info('RESPONSE',self.response)
logger.debug('RESPONSE',self.response)
return self.response
def make_items(self, i, result):
@@ -52,7 +52,7 @@ class InfoWindow(xbmcgui.WindowXMLDialog):
self.setCoordinateResolution(2)
with futures.ThreadPoolExecutor() as executor:
for i, result in enumerate(self.results):
logger.info(result)
logger.debug(result)
if ('seriesName' in result and result['seriesName']) or ('name' in result and result['name']) or ('title' in result and result['title']):
self.items += [executor.submit(self.make_items, i, result).result()]
self.items.sort(key=lambda it: int(it.getProperty('position')))

View File

@@ -22,7 +22,7 @@ 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):
logger.info()
logger.debug()
# logger.debug("item:\n" + item.tostring('\n'))
time_limit = time.time() + 30
@@ -53,7 +53,7 @@ def mark_auto_as_watched(item, nfo_path=None, head_nfo=None, item_nfo=None):
# Mark as Watched
if actual_time > mark_time and not marked:
logger.debug("Marked as Watched")
logger.info("Marked as Watched")
item.playcount = 1
marked = True
show_server = False
@@ -104,7 +104,7 @@ def sync_trakt_addon(path_folder):
"""
Updates the values of episodes seen if
"""
logger.info()
logger.debug()
# if the addon exists we do the search
if xbmc.getCondVisibility('System.HasAddon("script.trakt")'):
# we import dependencies
@@ -230,7 +230,7 @@ def sync_trakt_kodi(silent=True):
notificacion = False
xbmc.executebuiltin('RunScript(script.trakt,action=sync,silent=%s)' % silent)
logger.info("Synchronization with Trakt started")
logger.debug("Synchronization with Trakt started")
if notificacion:
platformtools.dialog_notification(config.get_localized_string(20000), config.get_localized_string(60045), sound=False, time=2000)
@@ -244,7 +244,7 @@ def mark_content_as_watched_on_kodi(item, value=1):
@type value: int
@param value: > 0 for seen, 0 for not seen
"""
logger.info()
logger.debug()
# logger.debug("item:\n" + item.tostring('\n'))
payload_f = ''
@@ -316,7 +316,7 @@ def mark_season_as_watched_on_kodi(item, value=1):
@type value: int
@param value: > 0 for seen, 0 for not seen
"""
logger.info()
logger.debug()
# logger.debug("item:\n" + item.tostring('\n'))
# We can only mark the season as seen in the Kodi database if the database is local, in case of sharing database this functionality will not work
@@ -350,7 +350,7 @@ def mark_content_as_watched_on_kod(path):
@type str: path
@param path: content folder to mark
"""
logger.info()
logger.debug()
#logger.debug("path: " + path)
FOLDER_MOVIES = config.get_setting("folder_movies")
@@ -443,7 +443,7 @@ def get_data(payload):
import urllib.request as urllib
except ImportError:
import urllib
logger.info("payload: %s" % payload)
logger.debug("payload: %s" % payload)
# Required header for XBMC JSON-RPC calls, otherwise you'll get a 415 HTTP response code - Unsupported media type
headers = {'content-type': 'application/json'}
@@ -460,7 +460,7 @@ def get_data(payload):
response = f.read()
f.close()
logger.info("get_data: response %s" % response)
logger.debug("get_data: response %s" % response)
data = jsontools.load(response)
except Exception as ex:
template = "An exception of type %s occured. Arguments:\n%r"
@@ -476,7 +476,7 @@ def get_data(payload):
logger.error("error en xbmc.executeJSONRPC: %s" % message)
data = ["error"]
logger.info("data: %s" % data)
logger.debug("data: %s" % data)
return data
@@ -490,7 +490,7 @@ def update(folder_content=config.get_setting("folder_tvshows"), folder=""):
@type folder: str
@param folder: name of the folder to scan.
"""
logger.info(folder)
logger.debug(folder)
payload = {
"jsonrpc": "2.0",
@@ -554,7 +554,7 @@ def set_content(content_type, silent=False, custom=False):
@type content_type: str ('movie' o 'tvshow')
@param content_type: content type to configure, series or movies
"""
logger.info()
logger.debug()
continuar = True
msg_text = ""
videolibrarypath = config.get_setting("videolibrarypath")
@@ -580,7 +580,7 @@ def set_content(content_type, silent=False, custom=False):
try:
# Install metadata.themoviedb.org
xbmc.executebuiltin('InstallAddon(metadata.themoviedb.org)', True)
logger.info("Instalado el Scraper de películas de TheMovieDB")
logger.debug("Instalado el Scraper de películas de TheMovieDB")
except:
pass
@@ -634,7 +634,7 @@ def set_content(content_type, silent=False, custom=False):
try:
# Install metadata.tvdb.com
xbmc.executebuiltin('InstallAddon(metadata.tvdb.com)', True)
logger.info("The TVDB series Scraper installed ")
logger.debug("The TVDB series Scraper installed ")
except:
pass
@@ -729,7 +729,7 @@ def set_content(content_type, silent=False, custom=False):
strScraper = 'metadata.universal'
path_settings = xbmc.translatePath("special://profile/addon_data/metadata.universal/settings.xml")
if not os.path.exists(path_settings):
logger.info("%s: %s" % (content_type, path_settings + " doesn't exist"))
logger.debug("%s: %s" % (content_type, path_settings + " doesn't exist"))
return continuar
settings_data = filetools.read(path_settings)
strSettings = ' '.join(settings_data.split()).replace("> <", "><")
@@ -748,7 +748,7 @@ def set_content(content_type, silent=False, custom=False):
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):
logger.info("%s: %s" % (content_type, path_settings + " doesn't exist"))
logger.debug("%s: %s" % (content_type, path_settings + " doesn't exist"))
return continuar
settings_data = filetools.read(path_settings)
strSettings = ' '.join(settings_data.split()).replace("> <", "><")
@@ -758,7 +758,7 @@ def set_content(content_type, silent=False, custom=False):
videolibrarypath += sep
strPath = videolibrarypath + config.get_setting("folder_tvshows") + sep
logger.info("%s: %s" % (content_type, strPath))
logger.debug("%s: %s" % (content_type, strPath))
# We check if strPath already exists in the DB to avoid duplicates
sql = 'SELECT idPath FROM path where strPath="%s"' % strPath
nun_records, records = execute_sql_kodi(sql)
@@ -800,15 +800,15 @@ def set_content(content_type, silent=False, custom=False):
heading = config.get_localized_string(70103) % content_type
msg_text = config.get_localized_string(70104)
logger.info("%s: %s" % (heading, msg_text))
logger.debug("%s: %s" % (heading, msg_text))
return continuar
def update_db(old_path, new_path, old_movies_folder, new_movies_folder, old_tvshows_folder, new_tvshows_folder, progress):
def path_replace(path, old, new):
logger.info()
logger.info('path: ' + path + ', old: ' + old + ', new: ' + new)
logger.debug()
logger.debug('path: ' + path + ', old: ' + old + ', new: ' + new)
if new.startswith("special://") or '://' in new: sep = '/'
else: sep = os.sep
@@ -819,7 +819,7 @@ def update_db(old_path, new_path, old_movies_folder, new_movies_folder, old_tvsh
return path
logger.info()
logger.debug()
sql_old_path = old_path
if sql_old_path.startswith("special://"):
@@ -831,10 +831,10 @@ def update_db(old_path, new_path, old_movies_folder, new_movies_folder, old_tvsh
if not sql_old_path.endswith(sep):
sql_old_path += sep
logger.info('sql_old_path: ' + sql_old_path)
logger.debug('sql_old_path: ' + sql_old_path)
# search MAIN path in the DB
sql = 'SELECT idPath, strPath FROM path where strPath LIKE "%s"' % sql_old_path
logger.info('sql: ' + sql)
logger.debug('sql: ' + sql)
nun_records, records = execute_sql_kodi(sql)
# change main path
@@ -842,7 +842,7 @@ def update_db(old_path, new_path, old_movies_folder, new_movies_folder, old_tvsh
idPath = records[0][0]
strPath = path_replace(records[0][1], old_path, new_path)
sql = 'UPDATE path SET strPath="%s" WHERE idPath=%s' % (strPath, idPath)
logger.info('sql: ' + sql)
logger.debug('sql: ' + sql)
nun_records, records = execute_sql_kodi(sql)
else:
progress.update(100)
@@ -859,7 +859,7 @@ def update_db(old_path, new_path, old_movies_folder, new_movies_folder, old_tvsh
# Search Main Sub Folder
sql = 'SELECT idPath, strPath FROM path where strPath LIKE "%s"' % sql_old_folder
logger.info('sql: ' + sql)
logger.debug('sql: ' + sql)
nun_records, records = execute_sql_kodi(sql)
# Change Main Sub Folder
@@ -868,13 +868,13 @@ def update_db(old_path, new_path, old_movies_folder, new_movies_folder, old_tvsh
idPath = record[0]
strPath = path_replace(record[1], filetools.join(old_path, OldFolder), filetools.join(new_path, NewFolder))
sql = 'UPDATE path SET strPath="%s" WHERE idPath=%s' % (strPath, idPath)
logger.info('sql: ' + sql)
logger.debug('sql: ' + sql)
nun_records, records = execute_sql_kodi(sql)
# Search if Sub Folder exixt in all paths
sql_old_folder += '%'
sql = 'SELECT idPath, strPath FROM path where strPath LIKE "%s"' % sql_old_folder
logger.info('sql: ' + sql)
logger.debug('sql: ' + sql)
nun_records, records = execute_sql_kodi(sql)
#Change Sub Folder in all paths
@@ -883,7 +883,7 @@ def update_db(old_path, new_path, old_movies_folder, new_movies_folder, old_tvsh
idPath = record[0]
strPath = path_replace(record[1], filetools.join(old_path, OldFolder), filetools.join(new_path, NewFolder))
sql = 'UPDATE path SET strPath="%s" WHERE idPath=%s' % (strPath, idPath)
logger.info('sql: ' + sql)
logger.debug('sql: ' + sql)
nun_records, records = execute_sql_kodi(sql)
@@ -891,27 +891,27 @@ def update_db(old_path, new_path, old_movies_folder, new_movies_folder, old_tvsh
# if is Movie Folder
# search and modify in "movie"
sql = 'SELECT idMovie, c22 FROM movie where c22 LIKE "%s"' % sql_old_folder
logger.info('sql: ' + sql)
logger.debug('sql: ' + sql)
nun_records, records = execute_sql_kodi(sql)
if records:
for record in records:
idMovie = record[0]
strPath = path_replace(record[1], filetools.join(old_path, OldFolder), filetools.join(new_path, NewFolder))
sql = 'UPDATE movie SET c22="%s" WHERE idMovie=%s' % (strPath, idMovie)
logger.info('sql: ' + sql)
logger.debug('sql: ' + sql)
nun_records, records = execute_sql_kodi(sql)
else:
# if is TV Show Folder
# search and modify in "episode"
sql = 'SELECT idEpisode, c18 FROM episode where c18 LIKE "%s"' % sql_old_folder
logger.info('sql: ' + sql)
logger.debug('sql: ' + sql)
nun_records, records = execute_sql_kodi(sql)
if records:
for record in records:
idEpisode = record[0]
strPath = path_replace(record[1], filetools.join(old_path, OldFolder), filetools.join(new_path, NewFolder))
sql = 'UPDATE episode SET c18="%s" WHERE idEpisode=%s' % (strPath, idEpisode)
logger.info('sql: ' + sql)
logger.debug('sql: ' + sql)
nun_records, records = execute_sql_kodi(sql)
p += 5
progress.update(p, config.get_localized_string(20000) + '\n' + config.get_localized_string(80013))
@@ -936,26 +936,26 @@ def clean(path_list=[]):
return path, sep
logger.info()
logger.debug()
progress = platformtools.dialog_progress_bg(config.get_localized_string(20000), config.get_localized_string(80025))
progress.update(0)
# if the path list is empty, clean the entire video library
if not path_list:
logger.info('the path list is empty, clean the entire video library')
logger.debug('the path list is empty, clean the entire video library')
if not config.get_setting("videolibrary_kodi"):
sql_path, sep = sql_format(config.get_setting("videolibrarypath"))
if not sql_path.endswith(sep): sql_path += sep
sql = 'SELECT idPath FROM path where strPath LIKE "%s"' % sql_path
logger.info('sql: ' + sql)
logger.debug('sql: ' + sql)
nun_records, records = execute_sql_kodi(sql)
idPath = records[0][0]
sql = 'DELETE from path WHERE idPath=%s' % idPath
logger.info('sql: ' + sql)
logger.debug('sql: ' + sql)
nun_records, records = execute_sql_kodi(sql)
sql = 'DELETE from path WHERE idParentPath=%s' % idPath
logger.info('sql: ' + sql)
logger.debug('sql: ' + sql)
nun_records, records = execute_sql_kodi(sql)
from core import videolibrarytools
@@ -969,7 +969,7 @@ def clean(path_list=[]):
if filetools.exists(tvshow_nfo):
path_list.append(filetools.join(config.get_setting("videolibrarypath"), videolibrarytools.FOLDER_TVSHOWS, folder))
logger.info('path_list: ' + str(path_list))
logger.debug('path_list: ' + str(path_list))
if path_list: t = float(100) / len(path_list)
for i, path in enumerate(path_list):
progress.update(int(math.ceil((i + 1) * t)))
@@ -979,13 +979,13 @@ def clean(path_list=[]):
sql_path, sep = sql_format(path)
if filetools.isdir(path) and not sql_path.endswith(sep): sql_path += sep
logger.info('path: ' + path)
logger.info('sql_path: ' + sql_path)
logger.debug('path: ' + path)
logger.debug('sql_path: ' + sql_path)
if filetools.isdir(path):
# search movie in the DB
sql = 'SELECT idMovie FROM movie where c22 LIKE "%s"' % (sql_path + '%')
logger.info('sql: ' + sql)
logger.debug('sql: ' + sql)
nun_records, records = execute_sql_kodi(sql)
# delete movie
if records:
@@ -994,7 +994,7 @@ def clean(path_list=[]):
continue
# search TV show in the DB
sql = 'SELECT idShow FROM tvshow_view where strPath LIKE "%s"' % sql_path
logger.info('sql: ' + sql)
logger.debug('sql: ' + sql)
nun_records, records = execute_sql_kodi(sql)
# delete TV show
if records:
@@ -1003,7 +1003,7 @@ def clean(path_list=[]):
elif config.get_setting("folder_movies") in sql_path:
# search movie in the DB
sql = 'SELECT idMovie FROM movie where c22 LIKE "%s"' % sql_path
logger.info('sql: ' + sql)
logger.debug('sql: ' + sql)
nun_records, records = execute_sql_kodi(sql)
# delete movie
if records:
@@ -1012,7 +1012,7 @@ def clean(path_list=[]):
else:
# search episode in the DB
sql = 'SELECT idEpisode FROM episode where c18 LIKE "%s"' % sql_path
logger.info('sql: ' + sql)
logger.debug('sql: ' + sql)
nun_records, records = execute_sql_kodi(sql)
# delete episode
if records:
@@ -1031,7 +1031,7 @@ def check_db(path):
ret = False
sql_path = '%' + sep + path.split(sep)[-1] + sep + '%'
sql = 'SELECT idShow FROM tvshow_view where strPath LIKE "%s"' % sql_path
logger.info('sql: ' + sql)
logger.debug('sql: ' + sql)
nun_records, records = execute_sql_kodi(sql)
if records:
ret = True
@@ -1048,7 +1048,7 @@ def execute_sql_kodi(sql):
@return: list with the query result
@rtype records: list of tuples
"""
logger.info()
logger.debug()
file_db = ""
nun_records = 0
records = None
@@ -1069,14 +1069,14 @@ def execute_sql_kodi(sql):
break
if file_db:
logger.info("DB file: %s" % file_db)
logger.debug("DB file: %s" % file_db)
conn = None
try:
import sqlite3
conn = sqlite3.connect(file_db)
cursor = conn.cursor()
logger.info("Running sql: %s" % sql)
logger.debug("Running sql: %s" % sql)
cursor.execute(sql)
conn.commit()
@@ -1090,7 +1090,7 @@ def execute_sql_kodi(sql):
nun_records = conn.total_changes
conn.close()
logger.info("Query executed. Records: %s" % nun_records)
logger.debug("Query executed. Records: %s" % nun_records)
except:
logger.error("Error executing sql query")
@@ -1110,7 +1110,7 @@ def check_sources(new_movies_path='', new_tvshows_path=''):
if not path.endswith(sep): path += sep
return path
logger.info()
logger.debug()
new_movies_path = format_path(new_movies_path)
new_tvshows_path = format_path(new_tvshows_path)
@@ -1140,7 +1140,7 @@ def check_sources(new_movies_path='', new_tvshows_path=''):
def update_sources(new='', old=''):
logger.info()
logger.debug()
if new == old: return
SOURCES_PATH = xbmc.translatePath("special://userdata/sources.xml")
@@ -1182,9 +1182,9 @@ def update_sources(new='', old=''):
# create new path
list_path = [p.firstChild.data for p in paths_node]
if new in list_path:
logger.info("The path %s already exists in sources.xml" % new)
logger.debug("The path %s already exists in sources.xml" % new)
return
logger.info("The path %s does not exist in sources.xml" % new)
logger.debug("The path %s does not exist in sources.xml" % new)
# if the path does not exist we create one
source_node = xmldoc.createElement("source")
@@ -1223,7 +1223,7 @@ def update_sources(new='', old=''):
def ask_set_content(silent=False):
logger.info()
logger.debug()
logger.debug("videolibrary_kodi %s" % config.get_setting("videolibrary_kodi"))
def do_config(custom=False):
@@ -1280,7 +1280,7 @@ def ask_set_content(silent=False):
def next_ep(item):
from core.item import Item
logger.info()
logger.debug()
item.next_ep = False
# check if next file exist
@@ -1296,7 +1296,7 @@ def next_ep(item):
nextIndex = fileList.index(current_filename) + 1
if nextIndex == 0 or nextIndex == len(fileList): next_file = None
else: next_file = fileList[nextIndex]
logger.info('Next File:' + str(next_file))
logger.debug('Next File:' + str(next_file))
# start next episode window afther x time
if next_file: