- logger.info -> logger.log

- fix unshortenit kodi 19
This commit is contained in:
Alhaziel01
2020-08-17 11:17:55 +02:00
parent bfb80f6889
commit c7e41f41a2
162 changed files with 1011 additions and 1034 deletions

View File

@@ -214,23 +214,23 @@ def get_setting(name, channel="", server="", default=None):
# Specific channel setting
if channel:
# logger.info("get_setting reading channel setting '"+name+"' from channel json")
# logger.log("get_setting reading channel setting '"+name+"' from channel json")
from core import channeltools
value = channeltools.get_channel_setting(name, channel, default)
# logger.info("get_setting -> '"+repr(value)+"'")
# logger.log("get_setting -> '"+repr(value)+"'")
return value
# Specific server setting
elif server:
# logger.info("get_setting reading server setting '"+name+"' from server json")
# logger.log("get_setting reading server setting '"+name+"' from server json")
from core import servertools
value = servertools.get_server_setting(name, server, default)
# logger.info("get_setting -> '"+repr(value)+"'")
# logger.log("get_setting -> '"+repr(value)+"'")
return value
# Global setting
else:
# logger.info("get_setting reading main setting '"+name+"'")
# logger.log("get_setting reading main setting '"+name+"'")
value = __settings__.getSetting(name)
if not value:
return default

View File

@@ -22,17 +22,17 @@ from platformcode import config, logger
# Download a file and start playing while downloading
def download_and_play(url, file_name, download_path):
# Start thread
logger.info("Active threads " + str(threading.active_count()))
logger.info("" + repr(threading.enumerate()))
logger.info("Starting download thread...")
logger.log("Active threads " + str(threading.active_count()))
logger.log("" + repr(threading.enumerate()))
logger.log("Starting download thread...")
download_thread = DownloadThread(url, file_name, download_path)
download_thread.start()
logger.info("Download thread started")
logger.info("Active threads " + str(threading.active_count()))
logger.info("" + repr(threading.enumerate()))
logger.log("Download thread started")
logger.log("Active threads " + str(threading.active_count()))
logger.log("" + repr(threading.enumerate()))
# Wait
logger.info("Waiting...")
logger.log("Waiting...")
while True:
cancelled = False
@@ -53,7 +53,7 @@ def download_and_play(url, file_name, download_path):
dialog.close()
logger.info("End of waiting")
logger.log("End of waiting")
# Launch the player
player = CustomPlayer()
@@ -61,66 +61,66 @@ def download_and_play(url, file_name, download_path):
player.PlayStream(download_thread.get_file_name())
# End of playback
logger.info("End of playback")
logger.log("End of playback")
if player.is_stopped():
logger.info("Terminated by user")
logger.log("Terminated by user")
break
else:
if not download_thread.isAlive():
logger.info("Download has finished")
logger.log("Download has finished")
break
else:
logger.info("Continua la descarga")
logger.log("Continua la descarga")
# When the player finishes, if you continue downloading it for now
logger.info("Download thread alive=" + str(download_thread.isAlive()))
logger.log("Download thread alive=" + str(download_thread.isAlive()))
if download_thread.isAlive():
logger.info("Killing download thread")
logger.log("Killing download thread")
download_thread.force_stop()
class CustomPlayer(xbmc.Player):
def __init__(self, *args, **kwargs):
logger.info()
logger.log()
self.actualtime = 0
self.totaltime = 0
self.stopped = False
xbmc.Player.__init__(self)
def PlayStream(self, url):
logger.info("url=" + url)
logger.log("url=" + url)
self.play(url)
self.actualtime = 0
self.url = url
while self.isPlaying():
self.actualtime = self.getTime()
self.totaltime = self.getTotalTime()
logger.info("actualtime=" + str(self.actualtime) + " totaltime=" + str(self.totaltime))
logger.log("actualtime=" + str(self.actualtime) + " totaltime=" + str(self.totaltime))
xbmc.sleep(3000)
def set_download_thread(self, download_thread):
logger.info()
logger.log()
self.download_thread = download_thread
def force_stop_download_thread(self):
logger.info()
logger.log()
if self.download_thread.isAlive():
logger.info("Killing download thread")
logger.log("Killing download thread")
self.download_thread.force_stop()
# while self.download_thread.isAlive():
# xbmc.sleep(1000)
def onPlayBackStarted(self):
logger.info("PLAYBACK STARTED")
logger.log("PLAYBACK STARTED")
def onPlayBackEnded(self):
logger.info("PLAYBACK ENDED")
logger.log("PLAYBACK ENDED")
def onPlayBackStopped(self):
logger.info("PLAYBACK STOPPED")
logger.log("PLAYBACK STOPPED")
self.stopped = True
self.force_stop_download_thread()
@@ -131,7 +131,7 @@ class CustomPlayer(xbmc.Player):
# Download in background
class DownloadThread(threading.Thread):
def __init__(self, url, file_name, download_path):
# logger.info(repr(file))
# logger.log(repr(file))
self.url = url
self.download_path = download_path
self.file_name = os.path.join(download_path, file_name)
@@ -148,16 +148,16 @@ class DownloadThread(threading.Thread):
threading.Thread.__init__(self)
def run(self):
logger.info("Download starts...")
logger.log("Download starts...")
if "megacrypter.com" in self.url:
self.download_file_megacrypter()
else:
self.download_file()
logger.info("Download ends")
logger.log("Download ends")
def force_stop(self):
logger.info()
logger.log()
force_stop_file = open(self.force_stop_file_name, "w")
force_stop_file.write("0")
force_stop_file.close()
@@ -181,38 +181,38 @@ class DownloadThread(threading.Thread):
return self.total_size
def download_file_megacrypter(self):
logger.info()
logger.log()
comando = "./megacrypter.sh"
logger.info("command= " + comando)
logger.log("command= " + comando)
oldcwd = os.getcwd()
logger.info("oldcwd= " + oldcwd)
logger.log("oldcwd= " + oldcwd)
cwd = os.path.join(config.get_runtime_path(), "tools")
logger.info("cwd= " + cwd)
logger.log("cwd= " + cwd)
os.chdir(cwd)
logger.info("directory changed to= " + os.getcwd())
logger.log("directory changed to= " + os.getcwd())
logger.info("destination= " + self.download_path)
logger.log("destination= " + self.download_path)
os.system(comando + " '" + self.url + "' \"" + self.download_path + "\"")
# p = subprocess.Popen([comando , self.url , self.download_path], cwd=cwd, stdout=subprocess.PIPE , stderr=subprocess.PIPE )
# out, err = p.communicate()
# logger.info("DownloadThread.download_file out="+out)
# logger.log("DownloadThread.download_file out="+out)
os.chdir(oldcwd)
def download_file(self):
logger.info("Direct download")
logger.log("Direct download")
headers = []
# Ensures that the file can be created
logger.info("filename= " + self.file_name)
logger.log("filename= " + self.file_name)
self.file_name = xbmc.makeLegalFilename(self.file_name)
logger.info("filename= " + self.file_name)
logger.info("url= " + self.url)
logger.log("filename= " + self.file_name)
logger.log("url= " + self.url)
# Create the file
existSize = 0
@@ -228,13 +228,13 @@ class DownloadThread(threading.Thread):
additional_headers = [additional_headers]
for additional_header in additional_headers:
logger.info("additional_header: " + additional_header)
logger.log("additional_header: " + additional_header)
name = re.findall("(.*?)=.*?", additional_header)[0]
value = urllib.parse.unquote_plus(re.findall(".*?=(.*?)$", additional_header)[0])
headers.append([name, value])
self.url = self.url.split("|")[0]
logger.info("url= " + self.url)
logger.log("url= " + self.url)
# Timeout del socket a 60 segundos
socket.setdefaulttimeout(60)
@@ -243,7 +243,7 @@ class DownloadThread(threading.Thread):
h = urllib.request.HTTPHandler(debuglevel=0)
request = urllib.request.Request(self.url)
for header in headers:
logger.info("Header= " + header[0] + ": " + header[1])
logger.log("Header= " + header[0] + ": " + header[1])
request.add_header(header[0], header[1])
# Lanza la petición
@@ -272,18 +272,18 @@ class DownloadThread(threading.Thread):
self.total_size = int(float(totalfichero) / float(1024 * 1024))
logger.info("Content-Length=%s" % totalfichero)
logger.log("Content-Length=%s" % totalfichero)
blocksize = 100 * 1024
bloqueleido = connexion.read(blocksize)
logger.info("Starting file download, blocked= %s" % len(bloqueleido))
logger.log("Starting file download, blocked= %s" % len(bloqueleido))
maxreintentos = 10
while len(bloqueleido) > 0:
try:
if os.path.exists(self.force_stop_file_name):
logger.info("Force_stop file detected, download is interrupted")
logger.log("Force_stop file detected, download is interrupted")
f.close()
xbmc.executebuiltin("XBMC.Notification(%s,%s,300)" % (config.get_localized_string(60319),config.get_localized_string(60320)))
@@ -297,7 +297,7 @@ class DownloadThread(threading.Thread):
# except:
f.write(bloqueleido)
grabado = grabado + len(bloqueleido)
logger.info("grabado=%d de %d" % (grabado, totalfichero))
logger.log("grabado=%d de %d" % (grabado, totalfichero))
percent = int(float(grabado) * 100 / float(totalfichero))
self.progress = percent
totalmb = float(float(totalfichero) / (1024 * 1024))
@@ -323,7 +323,7 @@ class DownloadThread(threading.Thread):
except:
import sys
reintentos = reintentos + 1
logger.info("ERROR in block download, retry %d" % reintentos)
logger.log("ERROR in block download, retry %d" % reintentos)
for line in sys.exc_info():
logger.error("%s" % line)

View File

@@ -344,31 +344,31 @@ def list_env(environment={}):
if environment['debug'] == 'False':
logger.log_enable(True)
logger.info(sep)
logger.info('KoD environment variables: ' + environment['addon_version'] + ' Debug: ' + environment['debug'])
logger.info(sep)
logger.log(sep)
logger.log('KoD environment variables: ' + environment['addon_version'] + ' Debug: ' + environment['debug'])
logger.log(sep)
logger.info(environment['os_name'] + ' ' + environment['prod_model'] + ' ' +
logger.log(environment['os_name'] + ' ' + environment['prod_model'] + ' ' +
environment['os_release'] + ' ' + environment['machine'] + ' ' +
environment['architecture'] + ' ' + environment['language'])
logger.info('Kodi ' + environment['num_version'] + ', Vídeo: ' +
logger.log('Kodi ' + environment['num_version'] + ', Vídeo: ' +
environment['video_db'] + ', Python ' + environment['python_version'])
if environment['cpu_usage']:
logger.info('CPU: ' + environment['cpu_usage'])
logger.log('CPU: ' + environment['cpu_usage'])
if environment['mem_total'] or environment['mem_free']:
logger.info('Memory: Total: ' + environment['mem_total'] + ' MB | Disp.: ' +
logger.log('Memory: Total: ' + environment['mem_total'] + ' MB | Disp.: ' +
environment['mem_free'] + ' MB | Buffers: ' +
str(int(environment['kodi_buffer']) * 3) + ' MB | Buffermode: ' +
environment['kodi_bmode'] + ' | Readfactor: ' +
environment['kodi_rfactor'])
logger.info('Userdata: ' + environment['userdata_path'] + ' - Free: ' +
logger.log('Userdata: ' + environment['userdata_path'] + ' - Free: ' +
environment['userdata_free'].replace('.', ',') + ' GB')
logger.info('Videolibrary: Series/Episodes: ' + environment['videolab_series'] + '/' +
logger.log('Videolibrary: Series/Episodes: ' + environment['videolab_series'] + '/' +
environment['videolab_episodios'] + ' - Pelis: ' +
environment['videolab_pelis'] + ' - Upd: ' +
environment['videolab_update'] + ' - Path: ' +
@@ -380,24 +380,24 @@ def list_env(environment={}):
# if x == 0:
# cliente_alt = cliente.copy()
# del cliente_alt['Torrent_opt']
# logger.info('Torrent: Opt: %s, %s' % (str(cliente['Torrent_opt']), \
# logger.log('Torrent: Opt: %s, %s' % (str(cliente['Torrent_opt']), \
# str(cliente_alt).replace('{', '').replace('}', '') \
# .replace("'", '').replace('_', ' ')))
# elif x == 1 and environment['torrent_error']:
# logger.info('- ' + str(cliente).replace('{', '').replace('}', '') \
# logger.log('- ' + str(cliente).replace('{', '').replace('}', '') \
# .replace("'", '').replace('_', ' '))
# else:
# cliente_alt = cliente.copy()
# del cliente_alt['Plug_in']
# cliente_alt['Libre'] = cliente_alt['Libre'].replace('.', ',') + ' GB'
# logger.info('- %s: %s' % (str(cliente['Plug_in']), str(cliente_alt) \
# logger.log('- %s: %s' % (str(cliente['Plug_in']), str(cliente_alt) \
# .replace('{', '').replace('}', '').replace("'", '') \
# .replace('\\\\', '\\')))
# logger.info('Proxy: ' + environment['proxy_active'])
# logger.log('Proxy: ' + environment['proxy_active'])
logger.info('LOG Size: ' + environment['log_size'].replace('.', ',') + ' MB')
logger.info(sep)
logger.log('LOG Size: ' + environment['log_size'].replace('.', ',') + ' MB')
logger.log(sep)
if environment['debug'] == 'False':
logger.log_enable(False)

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.log()
# 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.log()
if not item:
# Extract item from sys.argv
if sys.argv[2]:
@@ -76,7 +76,7 @@ def run(item=None):
xbmc_videolibrary.ask_set_content(silent=False)
config.set_setting('show_once', True)
logger.info(item.tostring())
logger.log(item.tostring())
try:
if not config.get_setting('tmdb_active'):
@@ -84,7 +84,7 @@ def run(item=None):
# If item has no action, stops here
if item.action == "":
logger.info("Item without action")
logger.log("Item without action")
return
# Action for main menu in channelselector
@@ -154,7 +154,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.log("channel_file= " + channel_file + ' - ' + CHANNELS + ' - ' + item.channel)
channel = None
@@ -164,7 +164,7 @@ def run(item=None):
except ImportError:
exec("import " + CHANNELS + "." + item.channel + " as channel")
logger.info("Running channel %s | %s" % (channel.__name__, channel.__file__))
logger.log("Running channel %s | %s" % (channel.__name__, channel.__file__))
# Special play action
if item.action == "play":
@@ -174,12 +174,12 @@ def run(item=None):
trakt_tools.set_trakt_info(item)
except:
pass
logger.info("item.action=%s" % item.action.upper())
logger.log("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.log("Executing channel 'play' method")
itemlist = channel.play(item)
b_favourite = item.isFavourite
# Play should return a list of playable URLS
@@ -200,7 +200,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.log("Executing core 'play' method")
platformtools.play_video(item)
# Special action for findvideos, where the plugin looks for known urls
@@ -213,7 +213,7 @@ def run(item=None):
# If not, uses the generic findvideos function
else:
logger.info("No channel 'findvideos' method, "
logger.log("No channel 'findvideos' method, "
"executing core method")
itemlist = servertools.find_video_items(item)
@@ -258,7 +258,7 @@ def run(item=None):
else:
filetools.remove(temp_search_file)
logger.info("item.action=%s" % item.action.upper())
logger.log("item.action=%s" % item.action.upper())
from core import channeltools
if config.get_setting('last_search'):
@@ -279,7 +279,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.log("Executing channel '%s' method" % item.action)
itemlist = getattr(channel, item.action)(item)
if config.get_setting('trakt_sync'):
from core import trakt_tools
@@ -361,7 +361,7 @@ def set_search_temp(item):
filetools.write(temp_search_file, f)
def reorder_itemlist(itemlist):
logger.info()
logger.log()
# logger.debug("Inlet itemlist size: %i" % len(itemlist))
new_list = []
@@ -399,7 +399,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.log("Modified Titles:%i |Unmodified:%i" % (modified, not_modified))
if len(new_list) == 0:
new_list = itemlist
@@ -409,7 +409,7 @@ def reorder_itemlist(itemlist):
def limit_itemlist(itemlist):
logger.info()
logger.log()
# logger.debug("Inlet itemlist size: %i" % len(itemlist))
try:
@@ -442,7 +442,7 @@ def play_from_library(item):
itemlist=[]
item.fromLibrary = True
logger.info()
logger.log()
# logger.debug("item: \n" + item.tostring('\n'))
# Try to reproduce an image (this does nothing and also does not give an error)

View File

@@ -3,12 +3,9 @@
# Logger (kodi)
# --------------------------------------------------------------------------------
import inspect
import xbmc
import inspect, sys, os, xbmc
from platformcode import config
import sys
PY3 = False
if sys.version_info[0] >= 3: PY3 = True; unicode = str; unichr = chr; long = int
@@ -105,13 +102,13 @@ def error(texto=""):
def log(*args):
# Function to simplify the log
# Automatically returns File Name and Function Name
import os
string = ''
for arg in args: string += ' '+str(arg)
frame = inspect.stack()[1]
filename = frame[0].f_code.co_filename
filename = os.path.basename(filename)
info("[" + filename + "] - [" + inspect.stack()[1][3] + "] " + string)
if loggeractive:
string = ''
for arg in args: string += ' '+str(arg)
frame = inspect.stack()[1]
filename = frame[0].f_code.co_filename
filename = os.path.basename(filename)
xbmc.log("[" + filename + "] [" + inspect.stack()[1][3] + "] " + string, xbmc.LOGNOTICE)
class WebErrorException(Exception):

View File

@@ -117,7 +117,7 @@ def dialog_browse(_type, heading, shares="files", mask="", useThumbs=False, trea
def itemlist_refresh():
# pos = Item().fromurl(xbmc.getInfoLabel('ListItem.FileNameAndPath')).itemlistPosition
# logger.info('Current position: ' + str(pos))
# logger.log('Current position: ' + str(pos))
xbmc.executebuiltin("Container.Refresh")
# while Item().fromurl(xbmc.getInfoLabel('ListItem.FileNameAndPath')).itemlistPosition != pos:
@@ -138,7 +138,7 @@ def render_items(itemlist, parent_item):
"""
Function used to render itemlist on kodi
"""
logger.info('START render_items')
logger.log('START render_items')
thumb_type = config.get_setting('video_thumbnail_type')
from specials import shortcuts
from core import httptools
@@ -223,7 +223,7 @@ def render_items(itemlist, parent_item):
set_view_mode(itemlist[0], parent_item)
xbmcplugin.endOfDirectory(_handle)
logger.info('END render_items')
logger.log('END render_items')
def getCurrentView(item=None, parent_item=None):
@@ -280,11 +280,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.log('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.log('TYPE: ' + Type + ' - ' + 'CONTENT: ' + content)
def set_infolabels(listitem, item, player=False):
@@ -504,10 +504,10 @@ def is_playing():
def play_video(item, strm=False, force_direct=False, autoplay=False):
logger.info()
logger.log()
logger.debug(item.tostring('\n'))
if item.channel == 'downloads':
logger.info("Play local video: %s [%s]" % (item.title, item.url))
logger.log("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)
@@ -515,7 +515,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.log("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)
@@ -525,8 +525,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.log("selection=%d" % seleccion)
logger.log("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)
@@ -687,7 +687,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.log("handle_wait(time_to_wait=%d)" % time_to_wait)
espera = dialog_progress(' ' + title, "")
secs = 0
@@ -706,15 +706,15 @@ def handle_wait(time_to_wait, title, text):
break
if cancelled:
logger.info('Wait canceled')
logger.log('Wait canceled')
return False
else:
logger.info('Wait finished')
logger.log('Wait finished')
return True
def get_dialogo_opciones(item, default_action, strm, autoplay):
logger.info()
logger.log()
# logger.debug(item.tostring('\n'))
from core import servertools
@@ -798,7 +798,7 @@ def get_dialogo_opciones(item, default_action, strm, autoplay):
def set_opcion(item, seleccion, opciones, video_urls):
logger.info()
logger.log()
# logger.debug(item.tostring('\n'))
salir = False
# You have not chosen anything, most likely because you have given the ESC
@@ -848,7 +848,7 @@ def set_opcion(item, seleccion, opciones, video_urls):
def get_video_seleccionado(item, seleccion, video_urls):
logger.info()
logger.log()
mediaurl = ""
view = False
wait_time = 0
@@ -874,7 +874,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.log("mediaurl=" + mediaurl)
if mediaurl == "":
if item.server == "unknown":
alert_unsopported_server()
@@ -891,7 +891,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.log()
# logger.debug("item:\n" + item.tostring('\n'))
# Moved del conector "torrent" here
if item.server == "torrent":
@@ -908,10 +908,10 @@ def set_player(item, xlistitem, mediaurl, view, strm, nfo_path=None, head_nfo=No
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
elif "megacrypter.com" in mediaurl: player_mode = 3
logger.info("mediaurl=" + mediaurl)
logger.log("mediaurl=" + mediaurl)
if player_mode == 0:
logger.info('Player Mode: Direct')
logger.log('Player Mode: Direct')
# Add the listitem to a playlist
playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
playlist.clear()
@@ -924,24 +924,24 @@ def set_player(item, xlistitem, mediaurl, view, strm, nfo_path=None, head_nfo=No
trakt_tools.wait_for_update_trakt()
elif player_mode == 1:
logger.info('Player Mode: setResolvedUrl')
logger.log('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')
logger.log('Player Mode: Built-In')
xbmc.executebuiltin("PlayMedia(" + mediaurl + ")")
elif player_mode == 3:
logger.info('Player Mode: Download and Play')
logger.log('Player Mode: Download and Play')
from platformcode import download_and_play
download_and_play.download_and_play(mediaurl, "download_and_play.tmp", config.get_setting("downloadpath"))
return
# ALL LOOKING TO REMOVE VIEW
if item.subtitle and view:
logger.info("External subtitles: " + item.subtitle)
logger.log("External subtitles: " + item.subtitle)
xbmc.sleep(2000)
xbmc_player.setSubtitles(item.subtitle)
@@ -967,7 +967,7 @@ def torrent_client_installed(show_tuple=False):
def play_torrent(item, xlistitem, mediaurl):
logger.info()
logger.log()
import time
from servers import torrent
@@ -1087,17 +1087,17 @@ def install_inputstream():
# Check if InputStream add-on exists!
Addon('inputstream.adaptive')
logger.info('InputStream add-on installed from repo.')
logger.log('InputStream add-on installed from repo.')
except RuntimeError:
logger.info('InputStream add-on not installed.')
logger.log('InputStream add-on not installed.')
dialog_ok(config.get_localized_string(20000), config.get_localized_string(30126))
return False
else:
try:
Addon('inputstream.adaptive')
logger.info('InputStream add-on is installed and enabled')
logger.log('InputStream add-on is installed and enabled')
except:
logger.info('enabling InputStream add-on')
logger.log('enabling InputStream add-on')
xbmc.executebuiltin('UpdateLocalAddons')
xbmc.executeJSONRPC('{"jsonrpc": "2.0", "id":1, "method": "Addons.SetAddonEnabled", "params": { "addonid": "inputstream.adaptive", "enabled": true }}')
return True
@@ -1212,13 +1212,13 @@ def best_chromeos_image(devices):
# Select the newest version
from distutils.version import LooseVersion # pylint: disable=import-error,no-name-in-module,useless-suppression
if LooseVersion(device['version']) > LooseVersion(best['version']):
logger.info('%s (%s) is newer than %s (%s)' % (device['hwid'], device['version'], best['hwid'], best['version']))
logger.log('%s (%s) is newer than %s (%s)' % (device['hwid'], device['version'], best['hwid'], best['version']))
best = device
# Select the smallest image (disk space requirement)
elif LooseVersion(device['version']) == LooseVersion(best['version']):
if int(device['filesize']) + int(device['zipfilesize']) < int(best['filesize']) + int(best['zipfilesize']):
logger.info('%s (%d) is smaller than %s (%d)' % (device['hwid'], int(device['filesize']) + int(device['zipfilesize']), best['hwid'], int(best['filesize']) + int(best['zipfilesize'])))
logger.log('%s (%d) is smaller than %s (%d)' % (device['hwid'], int(device['filesize']) + int(device['zipfilesize']), best['hwid'], int(best['filesize']) + int(best['zipfilesize'])))
best = device
return best

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.log(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

@@ -84,7 +84,7 @@ def regex_tvshow(compare, file, sub=""):
def set_Subtitle():
logger.info()
logger.log()
exts = [".srt", ".sub", ".txt", ".smi", ".ssa", ".ass"]
subtitle_folder_path = filetools.join(config.get_data_path(), "subtitles")
@@ -93,7 +93,7 @@ def set_Subtitle():
if subtitle_type == "2":
subtitle_path = config.get_setting("subtitlepath_file")
logger.info("Con subtitulo : " + subtitle_path)
logger.log("Con subtitulo : " + subtitle_path)
xbmc.Player().setSubtitles(subtitle_path)
else:
if subtitle_type == "0":
@@ -106,7 +106,7 @@ def set_Subtitle():
long_v = len(subtitle_path)
if long_v > 0:
if subtitle_path.startswith("http") or subtitle_path[long_v - 4, long] in exts:
logger.info("Con subtitulo : " + subtitle_path)
logger.log("Con subtitulo : " + subtitle_path)
xbmc.Player().setSubtitles(subtitle_path)
return
else:
@@ -125,7 +125,7 @@ def set_Subtitle():
Subnames = glob.glob(filetools.join(subtitle_path, "Movies", subtitle_name + "*.??.???"))
for Subname in Subnames:
if os.path.splitext(Subname)[1] in exts:
logger.info("Con subtitulo : " + filetools.split(Subname)[1])
logger.log("Con subtitulo : " + filetools.split(Subname)[1])
xbmc.Player().setSubtitles((Subname))
except:
logger.error("error al cargar subtitulos")
@@ -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.log(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.log("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.log()
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.log('sub invalid')
else:
logger.info('sub invalid')
logger.log('sub invalid')
return sub
@@ -328,7 +328,7 @@ def extract_file_online(path, filename):
:return:
"""
logger.info()
logger.log()
url = "http://online.b1.org/rest/online/upload"

View File

@@ -98,7 +98,7 @@ thumb_dict = {"movies": "https://s10.postimg.cc/fxtqzdog9/peliculas.png",
def set_genre(string):
# logger.info()
# logger.log()
genres_dict = {'accion': ['accion', 'action', 'accion y aventura', 'action & adventure'],
'adultos': ['adultos', 'adultos +', 'adulto'],
@@ -140,7 +140,7 @@ def set_genre(string):
def remove_format(string):
# logger.info()
# logger.log()
# logger.debug('enter remove: %s' % string)
string = string.rstrip()
string = re.sub(r'(\[|\[\/)(?:color|COLOR|b|B|i|I).*?\]|\[|\]|\(|\)|\:|\.', '', string)
@@ -156,7 +156,7 @@ def normalize(string):
def simplify(string):
# logger.info()
# logger.log()
# logger.debug('enter simplify: %s'%string)
string = remove_format(string)
string = string.replace('-', ' ').replace('_', ' ')
@@ -175,7 +175,7 @@ def simplify(string):
def add_languages(title, languages):
# logger.info()
# logger.log()
if isinstance(languages, list):
for language in languages:
@@ -186,7 +186,7 @@ def add_languages(title, languages):
def add_info_plot(plot, languages, quality):
# logger.info()
# logger.log()
last = '[/I][/B]\n'
if languages:
@@ -221,7 +221,7 @@ def add_info_plot(plot, languages, quality):
def set_color(title, category):
# logger.info()
# logger.log()
from core import jsontools
styles_path = os.path.join(config.get_runtime_path(), 'resources', 'color_styles.json')
@@ -262,7 +262,7 @@ def set_color(title, category):
def set_lang(language):
# logger.info()
# logger.log()
cast = ['castellano', 'español', 'espanol', 'cast', 'esp', 'espaol', 'es', 'zc', 'spa', 'spanish', 'vc']
ita = ['italiano', 'italian', 'ita', 'it']
@@ -303,7 +303,7 @@ def set_lang(language):
def title_format(item):
# logger.info()
# logger.log()
lang = False
valid = True
@@ -567,7 +567,7 @@ def title_format(item):
def thumbnail_type(item):
# logger.info()
# logger.log()
# Check what type of thumbnail will be used in findvideos, Poster or Logo of the server
thumb_type = config.get_setting('video_thumbnail_type')

View File

@@ -34,7 +34,7 @@ changelogFile = "special://profile/addon_data/plugin.video.kod/changelog.txt"
def loadCommits(page=1):
apiLink = 'https://api.github.com/repos/' + user + '/' + repo + '/commits?sha=' + branch + "&page=" + str(page)
logger.info(apiLink)
logger.log(apiLink)
# riprova ogni secondo finchè non riesce (ad esempio per mancanza di connessione)
for n in range(10):
try:
@@ -54,7 +54,7 @@ def loadCommits(page=1):
def check(background=False):
if not addon.getSetting('addon_update_enabled'):
return False, False
logger.info('Cerco aggiornamenti..')
logger.log('Cerco aggiornamenti..')
commits = loadCommits()
if not commits:
return False, False
@@ -66,7 +66,7 @@ def check(background=False):
localCommitFile = open(os.path.join(addonDir, trackingFile), 'r+')
localCommitSha = localCommitFile.read()
localCommitSha = localCommitSha.replace('\n', '') # da testare
logger.info('Commit locale: ' + localCommitSha)
logger.log('Commit locale: ' + localCommitSha)
updated = False
serviceChanged = False
@@ -91,7 +91,7 @@ def check(background=False):
# evitiamo di applicare i merge commit
if 'Merge' in commitJson['commit']['message']:
continue
logger.info('aggiornando a ' + commitJson['sha'])
logger.log('aggiornando a ' + commitJson['sha'])
alreadyApplied = True
# major update
@@ -108,7 +108,7 @@ def check(background=False):
if file["filename"] == trackingFile: # il file di tracking non si modifica
continue
else:
logger.info(file["filename"])
logger.log(file["filename"])
if 'resources/language' in file["filename"]:
poFilesChanged = True
if 'service.py' in file["filename"]:
@@ -138,7 +138,7 @@ def check(background=False):
localFile.writelines(patched)
localFile.close()
else: # nel caso ci siano stati problemi
logger.info('lo sha non corrisponde, scarico il file')
logger.log('lo sha non corrisponde, scarico il file')
localFile.close()
urllib.urlretrieve(file['raw_url'], os.path.join(addonDir, file['filename']))
else: # è un file NON testuale, lo devo scaricare
@@ -191,7 +191,7 @@ def check(background=False):
elif changelog:
platformtools.dialog_ok(config.get_localized_string(20000), config.get_localized_string(80041) + changelog)
else:
logger.info('Nessun nuovo aggiornamento')
logger.log('Nessun nuovo aggiornamento')
return updated, serviceChanged
@@ -207,7 +207,7 @@ def showSavedChangelog():
def calcCurrHash():
treeHash = githash.tree_hash(addonDir).hexdigest()
logger.info('tree hash: ' + treeHash)
logger.log('tree hash: ' + treeHash)
commits = loadCommits()
lastCommitSha = commits[0]['sha']
page = 1
@@ -227,7 +227,7 @@ def calcCurrHash():
if found:
break
else:
logger.info('Non sono riuscito a trovare il commit attuale, scarico lo zip')
logger.log('Non sono riuscito a trovare il commit attuale, scarico lo zip')
hash = updateFromZip()
# se ha scaricato lo zip si trova di sicuro all'ultimo commit
localCommitFile = open(os.path.join(xbmc.translatePath("special://home/addons/"), 'plugin.video.kod', trackingFile), 'w')
@@ -294,9 +294,9 @@ def updateFromZip(message=config.get_localized_string(80050)):
destpathname = xbmc.translatePath("special://home/addons/")
extractedDir = filetools.join(destpathname, "addon-" + branch)
logger.info("remotefilename=%s" % remotefilename)
logger.info("localfilename=%s" % localfilename)
logger.info('extract dir: ' + extractedDir)
logger.log("remotefilename=%s" % remotefilename)
logger.log("localfilename=%s" % localfilename)
logger.log('extract dir: ' + extractedDir)
# pulizia preliminare
remove(localfilename)
@@ -307,24 +307,24 @@ def updateFromZip(message=config.get_localized_string(80050)):
lambda nb, bs, fs, url=remotefilename: _pbhook(nb, bs, fs, url, dp))
except Exception as e:
platformtools.dialog_ok(config.get_localized_string(20000), config.get_localized_string(80031))
logger.info('Non sono riuscito a scaricare il file zip')
logger.info(e)
logger.log('Non sono riuscito a scaricare il file zip')
logger.log(e)
dp.close()
return False
# Lo descomprime
logger.info("decompressione...")
logger.info("destpathname=%s" % destpathname)
logger.log("decompressione...")
logger.log("destpathname=%s" % destpathname)
if os.path.isfile(localfilename):
logger.info('il file esiste')
logger.log('il file esiste')
dp.update(80, config.get_localized_string(20000) + '\n' + config.get_localized_string(80032))
import zipfile
try:
hash = fixZipGetHash(localfilename)
logger.info(hash)
logger.log(hash)
with zipfile.ZipFile(filetools.file_open(localfilename, 'rb', vfs=False)) as zip:
size = sum([zinfo.file_size for zinfo in zip.filelist])
@@ -335,7 +335,7 @@ def updateFromZip(message=config.get_localized_string(80050)):
dp.update(int(80 + cur_size * 15 / size))
except Exception as e:
logger.info('Non sono riuscito ad estrarre il file zip')
logger.log('Non sono riuscito ad estrarre il file zip')
logger.error(e)
import traceback
logger.error(traceback.print_exc())
@@ -355,7 +355,7 @@ def updateFromZip(message=config.get_localized_string(80050)):
rename(extractedDir, 'plugin.video.kod')
addonDir = filetools.join(destpathname, 'plugin.video.kod')
logger.info("Cancellando il file zip...")
logger.log("Cancellando il file zip...")
remove(localfilename)
dp.update(100)
@@ -384,7 +384,7 @@ def remove(file):
try:
os.remove(file)
except:
logger.info('File ' + file + ' NON eliminato')
logger.log('File ' + file + ' NON eliminato')
def onerror(func, path, exc_info):
@@ -411,7 +411,7 @@ def removeTree(dir):
try:
shutil.rmtree(dir, ignore_errors=False, onerror=onerror)
except Exception as e:
logger.info('Cartella ' + dir + ' NON eliminata')
logger.log('Cartella ' + dir + ' NON eliminata')
logger.error(e)
@@ -419,7 +419,7 @@ def rename(dir1, dir2):
try:
filetools.rename(dir1, dir2, silent=True, vfs=False)
except:
logger.info('cartella ' + dir1 + ' NON rinominata')
logger.log('cartella ' + dir1 + ' NON rinominata')
# https://stackoverflow.com/questions/3083235/unzipping-file-results-in-badzipfile-file-is-not-a-zip-file

View File

@@ -261,7 +261,7 @@ class InfoWindow(xbmcgui.WindowXMLDialog):
return self.return_value
def onClick(self, _id):
logger.info("onClick id=" + repr(_id))
logger.log("onClick id=" + repr(_id))
if _id == ID_BUTTON_PREVIOUS and self.indexList > 0:
self.indexList -= 1
self.get_scraper_data(self.listData[self.indexList])
@@ -281,7 +281,7 @@ class InfoWindow(xbmcgui.WindowXMLDialog):
self.return_value = None
def onAction(self, action):
logger.info("action=" + repr(action.getId()))
logger.log("action=" + repr(action.getId()))
action = action.getId()
# Find Focus

View File

@@ -17,7 +17,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.log()
# logger.debug("item:\n" + item.tostring('\n'))
time_limit = time.time() + 30
@@ -99,7 +99,7 @@ def sync_trakt_addon(path_folder):
"""
Updates the values of episodes seen if
"""
logger.info()
logger.log()
# if the addon exists we do the search
if xbmc.getCondVisibility('System.HasAddon("script.trakt")'):
# we import dependencies
@@ -225,7 +225,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.log("Synchronization with Trakt started")
if notificacion:
platformtools.dialog_notification(config.get_localized_string(20000), config.get_localized_string(60045), sound=False, time=2000)
@@ -239,7 +239,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.log()
# logger.debug("item:\n" + item.tostring('\n'))
payload_f = ''
@@ -311,7 +311,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.log()
# 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
@@ -345,7 +345,7 @@ def mark_content_as_watched_on_kod(path):
@type str: path
@param path: content folder to mark
"""
logger.info()
logger.log()
#logger.debug("path: " + path)
FOLDER_MOVIES = config.get_setting("folder_movies")
@@ -435,7 +435,7 @@ def get_data(payload):
:return:
"""
import urllib.request, urllib.error
logger.info("payload: %s" % payload)
logger.log("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'}
@@ -452,7 +452,7 @@ def get_data(payload):
response = f.read()
f.close()
logger.info("get_data: response %s" % response)
logger.log("get_data: response %s" % response)
data = jsontools.load(response)
except Exception as ex:
template = "An exception of type %s occured. Arguments:\n%r"
@@ -468,7 +468,7 @@ def get_data(payload):
logger.error("error en xbmc.executeJSONRPC: %s" % message)
data = ["error"]
logger.info("data: %s" % data)
logger.log("data: %s" % data)
return data
@@ -482,7 +482,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.log(folder)
payload = {
"jsonrpc": "2.0",
@@ -546,7 +546,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.log()
continuar = True
msg_text = ""
videolibrarypath = config.get_setting("videolibrarypath")
@@ -572,7 +572,7 @@ def set_content(content_type, silent=False, custom=False):
try:
# Install metadata.themoviedb.org
xbmc.executebuiltin('xbmc.installaddon(metadata.themoviedb.org)', True)
logger.info("Instalado el Scraper de películas de TheMovieDB")
logger.log("Instalado el Scraper de películas de TheMovieDB")
except:
pass
@@ -626,7 +626,7 @@ def set_content(content_type, silent=False, custom=False):
try:
# Install metadata.tvdb.com
xbmc.executebuiltin('xbmc.installaddon(metadata.tvdb.com)', True)
logger.info("The TVDB series Scraper installed ")
logger.log("The TVDB series Scraper installed ")
except:
pass
@@ -721,7 +721,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.log("%s: %s" % (content_type, path_settings + " doesn't exist"))
return continuar
settings_data = filetools.read(path_settings)
strSettings = ' '.join(settings_data.split()).replace("> <", "><")
@@ -740,7 +740,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.log("%s: %s" % (content_type, path_settings + " doesn't exist"))
return continuar
settings_data = filetools.read(path_settings)
strSettings = ' '.join(settings_data.split()).replace("> <", "><")
@@ -750,7 +750,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.log("%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)
@@ -792,15 +792,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.log("%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.log()
logger.log('path: ' + path + ', old: ' + old + ', new: ' + new)
if new.startswith("special://") or '://' in new: sep = '/'
else: sep = os.sep
@@ -811,7 +811,7 @@ def update_db(old_path, new_path, old_movies_folder, new_movies_folder, old_tvsh
return path
logger.info()
logger.log()
sql_old_path = old_path
if sql_old_path.startswith("special://"):
@@ -823,10 +823,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.log('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.log('sql: ' + sql)
nun_records, records = execute_sql_kodi(sql)
# change main path
@@ -834,7 +834,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.log('sql: ' + sql)
nun_records, records = execute_sql_kodi(sql)
else:
progress.update(100)
@@ -851,7 +851,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.log('sql: ' + sql)
nun_records, records = execute_sql_kodi(sql)
# Change Main Sub Folder
@@ -860,13 +860,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.log('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.log('sql: ' + sql)
nun_records, records = execute_sql_kodi(sql)
#Change Sub Folder in all paths
@@ -875,7 +875,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.log('sql: ' + sql)
nun_records, records = execute_sql_kodi(sql)
@@ -883,27 +883,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.log('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.log('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.log('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.log('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))
@@ -928,26 +928,26 @@ def clean(path_list=[]):
return path, sep
logger.info()
logger.log()
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.log('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.log('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.log('sql: ' + sql)
nun_records, records = execute_sql_kodi(sql)
sql = 'DELETE from path WHERE idParentPath=%s' % idPath
logger.info('sql: ' + sql)
logger.log('sql: ' + sql)
nun_records, records = execute_sql_kodi(sql)
from core import videolibrarytools
@@ -961,7 +961,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.log('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)))
@@ -971,13 +971,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.log('path: ' + path)
logger.log('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.log('sql: ' + sql)
nun_records, records = execute_sql_kodi(sql)
# delete movie
if records:
@@ -986,7 +986,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.log('sql: ' + sql)
nun_records, records = execute_sql_kodi(sql)
# delete TV show
if records:
@@ -995,7 +995,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.log('sql: ' + sql)
nun_records, records = execute_sql_kodi(sql)
# delete movie
if records:
@@ -1004,7 +1004,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.log('sql: ' + sql)
nun_records, records = execute_sql_kodi(sql)
# delete episode
if records:
@@ -1023,7 +1023,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.log('sql: ' + sql)
nun_records, records = execute_sql_kodi(sql)
if records:
ret = True
@@ -1040,7 +1040,7 @@ def execute_sql_kodi(sql):
@return: list with the query result
@rtype records: list of tuples
"""
logger.info()
logger.log()
file_db = ""
nun_records = 0
records = None
@@ -1061,14 +1061,14 @@ def execute_sql_kodi(sql):
break
if file_db:
logger.info("DB file: %s" % file_db)
logger.log("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.log("Running sql: %s" % sql)
cursor.execute(sql)
conn.commit()
@@ -1082,7 +1082,7 @@ def execute_sql_kodi(sql):
nun_records = conn.total_changes
conn.close()
logger.info("Query executed. Records: %s" % nun_records)
logger.log("Query executed. Records: %s" % nun_records)
except:
logger.error("Error executing sql query")
@@ -1102,7 +1102,7 @@ def check_sources(new_movies_path='', new_tvshows_path=''):
if not path.endswith(sep): path += sep
return path
logger.info()
logger.log()
new_movies_path = format_path(new_movies_path)
new_tvshows_path = format_path(new_tvshows_path)
@@ -1132,7 +1132,7 @@ def check_sources(new_movies_path='', new_tvshows_path=''):
def update_sources(new='', old=''):
logger.info()
logger.log()
if new == old: return
SOURCES_PATH = xbmc.translatePath("special://userdata/sources.xml")
@@ -1174,9 +1174,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.log("The path %s already exists in sources.xml" % new)
return
logger.info("The path %s does not exist in sources.xml" % new)
logger.log("The path %s does not exist in sources.xml" % new)
# if the path does not exist we create one
source_node = xmldoc.createElement("source")
@@ -1215,7 +1215,7 @@ def update_sources(new='', old=''):
def ask_set_content(silent=False):
logger.info()
logger.log()
logger.debug("videolibrary_kodi %s" % config.get_setting("videolibrary_kodi"))
def do_config(custom=False):
@@ -1272,7 +1272,7 @@ def ask_set_content(silent=False):
def next_ep(item):
from core.item import Item
logger.info()
logger.log()
item.next_ep = False
# check if next file exist
@@ -1288,7 +1288,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.log('Next File:' + str(next_file))
# start next episode window afther x time
if next_file: