Spostamento videoteca (rivisto)

This commit is contained in:
axlt2002
2020-03-24 12:41:37 +01:00
parent cf78aa4a04
commit 4172933d7f
7 changed files with 119 additions and 30 deletions
+9 -6
View File
@@ -172,7 +172,7 @@ def get_all_settings_addon():
infile.close() infile.close()
ret = {} ret = {}
matches = scrapertools.find_multiple_matches(data, '<setting id="([^"]*)" value="([^"]*)') matches = scrapertools.find_multiple_matches(data, '<setting id=\"([^\"]+)\"[^>]*>([^<]*)</setting>')
for _id, value in matches: for _id, value in matches:
ret[_id] = get_setting(_id) ret[_id] = get_setting(_id)
@@ -221,12 +221,15 @@ def open_settings():
# si se ha cambiado la ruta de la videoteca llamamos a comprobar directorios para que lo cree y pregunte # si se ha cambiado la ruta de la videoteca llamamos a comprobar directorios para que lo cree y pregunte
# automaticamente si configurar la videoteca # automaticamente si configurar la videoteca
if settings_pre.get("videolibrarypath", None) != settings_post.get("videolibrarypath", None) or \ """if settings_pre.get("videolibrarypath", None) != settings_post.get("videolibrarypath", None) or \
settings_pre.get("folder_movies", None) != settings_post.get("folder_movies", None) or \ settings_pre.get("folder_movies", None) != settings_post.get("folder_movies", None) or \
settings_pre.get("folder_tvshows", None) != settings_post.get("folder_tvshows", None): settings_pre.get("folder_tvshows", None) != settings_post.get("folder_tvshows", None):
verify_directories_created() verify_directories_created()"""
from specials import move_videolibrary
move_videolibrary.move_videolibrary(settings_pre.get("videolibrarypath", None), settings_post.get("videolibrarypath", None),
settings_pre.get("folder_movies", None), settings_post.get("folder_movies", None),
settings_pre.get("folder_tvshows", None), settings_post.get("folder_tvshows", None))
else:
# si se ha puesto que se quiere autoconfigurar y se había creado el directorio de la videoteca # si se ha puesto que se quiere autoconfigurar y se había creado el directorio de la videoteca
if not settings_pre.get("videolibrary_kodi", None) and settings_post.get("videolibrary_kodi", None) \ if not settings_pre.get("videolibrary_kodi", None) and settings_post.get("videolibrary_kodi", None) \
and settings_post.get("videolibrary_kodi_flag", None) == 1: and settings_post.get("videolibrary_kodi_flag", None) == 1:
@@ -465,8 +468,8 @@ def verify_directories_created():
logger.debug("Creating %s: %s" % (path, saved_path)) logger.debug("Creating %s: %s" % (path, saved_path))
filetools.mkdir(saved_path) filetools.mkdir(saved_path)
config_paths = [["folder_movies", "CINE"], config_paths = [["folder_movies", "Film"],
["folder_tvshows", "SERIES"]] ["folder_tvshows", "Serie TV"]]
for path, default in config_paths: for path, default in config_paths:
saved_path = get_setting(path) saved_path = get_setting(path)
+1 -1
View File
@@ -777,7 +777,7 @@ def set_content(content_type, silent=False):
if not continuar: if not continuar:
heading = config.get_localized_string(70102) % content_type heading = config.get_localized_string(70102) % content_type
elif content_type == 'SERIES' and not xbmc.getCondVisibility( elif content_type == 'tvshow' and not xbmc.getCondVisibility(
'System.HasAddon(metadata.tvshows.themoviedb.org)'): 'System.HasAddon(metadata.tvshows.themoviedb.org)'):
heading = config.get_localized_string(70103) % content_type heading = config.get_localized_string(70103) % content_type
msg_text = config.get_localized_string(60058) msg_text = config.get_localized_string(60058)
+20
View File
@@ -6082,3 +6082,23 @@ msgstr ""
msgctxt "#80009" msgctxt "#80009"
msgid "Would you like to search for new episodes and update video library?" msgid "Would you like to search for new episodes and update video library?"
msgstr "" msgstr ""
msgctxt "#80010"
msgid "Select the video library path"
msgstr ""
msgctxt "#80011"
msgid "Verifying folders..."
msgstr ""
msgctxt "#80012"
msgid "Moving video library..."
msgstr ""
msgctxt "#80013"
msgid "Updating database..."
msgstr ""
msgctxt "#80014"
msgid "The video library has been moved"
msgstr ""
+20
View File
@@ -6082,3 +6082,23 @@ msgstr "La videoteca è stata importata"
msgctxt "#80009" msgctxt "#80009"
msgid "Would you like to search for new episodes and update video library?" msgid "Would you like to search for new episodes and update video library?"
msgstr "Vuoi cercare i nuovi episodi ed aggiornare la videoteca?" msgstr "Vuoi cercare i nuovi episodi ed aggiornare la videoteca?"
msgctxt "#80010"
msgid "Select the video library path"
msgstr "Seleziona il percorso della videoteca"
msgctxt "#80011"
msgid "Verifying folders..."
msgstr "Verifica cartelle..."
msgctxt "#80012"
msgid "Moving video library..."
msgstr "Spostamento videoteca..."
msgctxt "#80013"
msgid "Updating database..."
msgstr "Aggiornamento database..."
msgctxt "#80014"
msgid "The video library has been moved"
msgstr "La videoteca è stata spostata"
+4 -4
View File
@@ -27,10 +27,10 @@
<!-- Videolibrary --> <!-- Videolibrary -->
<category label="30131"> <category label="30131">
<setting label="30501" type="lsep"/> <setting label="30501" type="lsep"/>
<setting id="videolibrarypath" type="action" label="30067" action="RunPlugin(plugin://plugin.video.kod/?ew0KCSJjaGFubmVsIjoibW92ZV92aWRlb2xpYnJhcnkiLA0KCSJhY3Rpb24iOiJzZXRfdmlkZW9saWJyYXJ5X3BhdGgiDQp9)" default="special://profile/addon_data/plugin.video.kod/videolibrary"/> <!-- <setting id="videolibrarypath" type="action" label="30067" action="RunPlugin(plugin://plugin.video.kod/?ew0KCSJjaGFubmVsIjoibW92ZV92aWRlb2xpYnJhcnkiLA0KCSJhY3Rpb24iOiJzZXRfdmlkZW9saWJyYXJ5X3BhdGgiDQp9)" default="special://profile/addon_data/plugin.video.kod/videolibrary"/> -->
<!-- <setting id="videolibrarypath" type="folder" label="30067" default="special://profile/addon_data/plugin.video.kod/videolibrary"/> --> <setting id="videolibrarypath" type="folder" label="30067" default="special://profile/addon_data/plugin.video.kod/videolibrary" option="writeable"/>
<setting id="folder_tvshows" type="text" label="70118" default="SERIES"/> <setting id="folder_tvshows" type="text" label="70118" default="Serie TV"/>
<setting id="folder_movies" type="text" label="70119" default="CINE"/> <setting id="folder_movies" type="text" label="70119" default="Film"/>
<setting label="59997" type="lsep"/> <setting label="59997" type="lsep"/>
<setting id="videolibrary_kodi_flag" type="number" label="" default="0" visible="false"/> <setting id="videolibrary_kodi_flag" type="number" label="" default="0" visible="false"/>
+4 -6
View File
@@ -24,7 +24,7 @@ def export_videolibrary(item):
return return
zip_file = xbmc.translatePath(zip_file_folder + "KoD_video_library-" + str(datetime.date.today()) + ".zip") zip_file = xbmc.translatePath(zip_file_folder + "KoD_video_library-" + str(datetime.date.today()) + ".zip")
p_dialog = platformtools.dialog_progress_bg(config.get_localized_string(80003), config.get_localized_string(20000)) p_dialog = platformtools.dialog_progress_bg(config.get_localized_string(20000), config.get_localized_string(80003))
p_dialog.update(0) p_dialog.update(0)
if filetools.exists(temp_path): if filetools.exists(temp_path):
@@ -46,8 +46,7 @@ def export_videolibrary(item):
p_dialog.update(100) p_dialog.update(100)
xbmc.sleep(2000) xbmc.sleep(2000)
p_dialog.close() p_dialog.close()
platformtools.dialog_notification(config.get_localized_string(20000), config.get_localized_string(80004), icon=3, platformtools.dialog_ok(config.get_localized_string(20000), config.get_localized_string(80004))
time=5000, sound=False)
def import_videolibrary(item): def import_videolibrary(item):
@@ -59,7 +58,7 @@ def import_videolibrary(item):
if not platformtools.dialog_yesno(config.get_localized_string(20000), config.get_localized_string(80006)): if not platformtools.dialog_yesno(config.get_localized_string(20000), config.get_localized_string(80006)):
return return
p_dialog = platformtools.dialog_progress_bg(config.get_localized_string(80007), config.get_localized_string(20000)) p_dialog = platformtools.dialog_progress_bg(config.get_localized_string(20000), config.get_localized_string(80007))
p_dialog.update(0) p_dialog.update(0)
if filetools.exists(temp_path): if filetools.exists(temp_path):
@@ -88,8 +87,7 @@ def import_videolibrary(item):
p_dialog.update(100) p_dialog.update(100)
xbmc.sleep(2000) xbmc.sleep(2000)
p_dialog.close() p_dialog.close()
platformtools.dialog_notification(config.get_localized_string(20000), config.get_localized_string(80008), icon=3, platformtools.dialog_ok(config.get_localized_string(20000), config.get_localized_string(80008))
time=5000, sound=False)
if platformtools.dialog_yesno(config.get_localized_string(20000), config.get_localized_string(80009)): if platformtools.dialog_yesno(config.get_localized_string(20000), config.get_localized_string(80009)):
import videolibrary_service import videolibrary_service
+55 -7
View File
@@ -7,14 +7,14 @@ from core.support import log, dbg
from distutils import dir_util, file_util from distutils import dir_util, file_util
from xml.dom import minidom from xml.dom import minidom
global p """global p
p = 0 p = 0
progress = platformtools.dialog_progress('Spostamento Videoteca','Spostamento File') progress = platformtools.dialog_progress('Spostamento Videoteca','Spostamento File')"""
def set_videolibrary_path(item): """def set_videolibrary_path(item):
log() log()
global p global p
previous_path = config.get_setting('videolibrarypath') previous_path = config.get_setting('videolibrarypath')
@@ -45,9 +45,57 @@ def move_videolibrary(new, old):
dir_util.remove_tree(od,1) dir_util.remove_tree(od,1)
global p global p
p += 30 p += 30
progress.update(p, '') progress.update(p)"""
def move_db(new, old): def move_videolibrary(current_path, new_path, current_movies_folder, new_movies_folder, current_tvshows_folder, new_tvshows_folder):
log()
log('current video library path:', current_path)
log('new video library path:', new_path)
log('current movies folder:', current_movies_folder)
log('new movies folder:', new_movies_folder)
log('current tvshows folder:', current_tvshows_folder)
log('new tvshows folder:', new_tvshows_folder)
if current_path != new_path or current_movies_folder != new_movies_folder or current_tvshows_folder != new_tvshows_folder:
notify = False
progress = platformtools.dialog_progress_bg(config.get_localized_string(20000), config.get_localized_string(80011))
current_path = xbmc.translatePath(current_path)
new_path = xbmc.translatePath(new_path)
current_movies_path = filetools.join(current_path, current_movies_folder)
new_movies_path = filetools.join(new_path, new_movies_folder)
current_tvshows_path = os.path.join(current_path, current_tvshows_folder)
new_tvshows_path = os.path.join(new_path, new_tvshows_folder)
config.verify_directories_created()
progress.update(10, config.get_localized_string(20000), config.get_localized_string(80012))
if current_movies_path != new_movies_path:
if filetools.listdir(current_movies_path):
dir_util.copy_tree(current_movies_path, new_movies_path)
notify = True
filetools.rmdirtree(current_movies_path)
progress.update(40)
if current_tvshows_path != new_tvshows_path:
if filetools.listdir(current_tvshows_path):
dir_util.copy_tree(current_tvshows_path, new_tvshows_path)
notify = True
filetools.rmdirtree(current_tvshows_path)
progress.update(70)
if current_path != new_path and not filetools.listdir(current_path) and not "plugin.video.kod\\videolibrary" in current_path:
filetools.rmdirtree(current_path)
progress.update(90, config.get_localized_string(20000), config.get_localized_string(80013))
if config.is_xbmc() and config.get_setting("videolibrary_kodi"):
set_new_path(new_path, current_path)
update_db(new_path, current_path)
clear_cache()
progress.update(100)
progress.close()
if notify:
platformtools.dialog_notification(config.get_localized_string(20000), config.get_localized_string(80014), icon=0,
time=5000, sound=False)
def update_db(new, old):
NEW = new NEW = new
OLD = old OLD = old
@@ -102,9 +150,9 @@ def move_db(new, old):
strPath = record[1].replace(OLD, NEW) strPath = record[1].replace(OLD, NEW)
sql = 'UPDATE episode SET c18="%s" WHERE idEpisode=%s' % (strPath, idEpisode) sql = 'UPDATE episode SET c18="%s" WHERE idEpisode=%s' % (strPath, idEpisode)
nun_records, records = xbmc_videolibrary.execute_sql_kodi(sql) nun_records, records = xbmc_videolibrary.execute_sql_kodi(sql)
global p """global p
p += 30 p += 30
progress.update(p, '') progress.update(p)"""
def set_new_path(new, old): def set_new_path(new, old):
write = False write = False