Merge remote-tracking branch 'origin/master'

This commit is contained in:
marco
2020-04-13 10:09:20 +02:00
9 changed files with 168 additions and 87 deletions

View File

@@ -108,35 +108,27 @@ def newest(categoria):
def findvideos(item):
log()
log(item)
if item.args != 'update':
data = item.url
return support.server(item, data=data)
return support.server(item, data=item.url)
else:
itemlist = []
item.infoLabels['mediatype'] = 'episode'
data = httptools.downloadpage(item.url, headers=headers).data
data = re.sub('\n|\t', ' ', data)
data = re.sub(r'>\s+<', '> <', data)
url_video = scrapertools.find_single_match(data, r'<div class="item"> <a data-id="[^"]+" data-href="([^"]+)" data-original="[^"]+"[^>]+> <div> <div class="title">Episodio \d+', -1)
url_serie = scrapertools.find_single_match(data, r'<link rel="canonical" href="([^"]+)"\s?/>')
goseries = support.typo(">> Vai alla Serie:", ' bold')
series = support.typo(item.contentSerieName, ' bold color kod')
data = support.match(item).data
urls_video = support.match(data, patron=r'<a data-id="[^"]+" data-(href=".*?)</iframe>').matches[-1]
url_serie = support.match(data, patron=r'<link rel="canonical" href="([^"]+)"\s?/>').match
itemlist = support.server(item, data=url_video)
itemlist = support.server(item, data=urls_video)
itemlist.append(
Item(channel=item.channel,
title=goseries + series,
title=support.typo("Vai alla Serie Completa: " + item.fulltitle, ' bold'),
fulltitle=item.fulltitle,
show=item.show,
contentType='tvshow',
contentSerieName=item.contentSerieName,
url=url_serie,
action='episodios',
contentTitle=item.contentSerieName,
plot = goseries + series + "con tutte le puntate",
thumbnail = support.thumb(thumb='tvshow.png')
))

View File

@@ -245,7 +245,7 @@ def open_settings():
if not settings_pre.get("videolibrary_kodi", None) and settings_post.get("videolibrary_kodi", None):
xbmc_videolibrary.ask_set_content(silent=True)
elif settings_pre.get("videolibrary_kodi", None) and not settings_post.get("videolibrary_kodi", None):
xbmc_videolibrary.clean_db()
xbmc_videolibrary.clean(get_setting('videolibrarypath'))
def get_setting(name, channel="", server="", default=None):

View File

@@ -515,15 +515,19 @@ def update(folder_content=config.get_setting("folder_tvshows"), folder=""):
xbmc.executebuiltin('XBMC.ReloadSkin()')
def clean(mostrar_dialogo=False):
def clean(path=''):
"""
limpia la libreria de elementos que no existen
@param mostrar_dialogo: muestra el cuadro de progreso mientras se limpia la videoteca
@type mostrar_dialogo: bool
"""
logger.info()
if path:
clean_db(path)
return True
payload = {"jsonrpc": "2.0", "method": "VideoLibrary.Clean", "id": 1,
"params": {"showdialogs": mostrar_dialogo}}
"params": {"showdialogs": False}}
data = get_data(payload)
if data.get('result', False) == 'OK':
@@ -810,13 +814,18 @@ def update_db(old_path, new_path, old_movies_folder, new_movies_folder, old_tvsh
logger.info()
if old_path.startswith("special://") or '://' in old_path: sep = '/'
sql_old_path = old_path
if sql_old_path.startswith("special://"):
sql_old_path = sql_old_path.replace('/profile/', '/%/').replace('/home/userdata/', '/%/')
sep = '/'
elif '://' in sql_old_path:
sep = '/'
else: sep = os.sep
if not old_path.endswith(sep):
old_path += sep
if not sql_old_path.endswith(sep):
sql_old_path += sep
# search MAIN path in the DB
sql = 'SELECT idPath, strPath FROM path where strPath LIKE "%s"' % old_path
sql = 'SELECT idPath, strPath FROM path where strPath LIKE "%s"' % sql_old_path
nun_records, records = execute_sql_kodi(sql)
# change main path
@@ -830,11 +839,11 @@ def update_db(old_path, new_path, old_movies_folder, new_movies_folder, old_tvsh
progress.update(p, config.get_localized_string(20000), config.get_localized_string(80013))
for OldFolder, NewFolder in [[old_movies_folder, new_movies_folder], [old_tvshows_folder, new_tvshows_folder]]:
old = old_path + OldFolder
if not old.endswith(sep): old += sep
sql_old_folder = sql_old_path + OldFolder
if not sql_old_folder.endswith(sep): sql_old_folder += sep
# Search Main Sub Folder
sql = 'SELECT idPath, strPath FROM path where strPath LIKE "%s"' % old
sql = 'SELECT idPath, strPath FROM path where strPath LIKE "%s"' % sql_old_folder
nun_records, records = execute_sql_kodi(sql)
# Change Main Sub Folder
@@ -842,12 +851,12 @@ def update_db(old_path, new_path, old_movies_folder, new_movies_folder, old_tvsh
for record in records:
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)
sql = 'UPDATE path SET strPath="%s" WHERE idPath=%s' % (strPath, idPath)
nun_records, records = execute_sql_kodi(sql)
# Search if Sub Folder exixt in all paths
old += '%'
sql = 'SELECT idPath, strPath FROM path where strPath LIKE "%s"' % old
sql_old_folder += '%'
sql = 'SELECT idPath, strPath FROM path where strPath LIKE "%s"' % sql_old_folder
nun_records, records = execute_sql_kodi(sql)
#Change Sub Folder in all paths
@@ -855,14 +864,14 @@ def update_db(old_path, new_path, old_movies_folder, new_movies_folder, old_tvsh
for record in records:
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)
sql = 'UPDATE path SET strPath="%s" WHERE idPath=%s' % (strPath, idPath)
nun_records, records = execute_sql_kodi(sql)
if OldFolder == old_movies_folder:
# if is Movie Folder
# search and modify in "movie"
sql = 'SELECT idMovie, c22 FROM movie where c22 LIKE "%s"' % old
sql = 'SELECT idMovie, c22 FROM movie where c22 LIKE "%s"' % sql_old_folder
nun_records, records = execute_sql_kodi(sql)
if records:
for record in records:
@@ -873,7 +882,7 @@ def update_db(old_path, new_path, old_movies_folder, new_movies_folder, old_tvsh
else:
# if is TV Show Folder
# search and modify in "episode"
sql = 'SELECT idEpisode, c18 FROM episode where c18 LIKE "%s"' % old
sql = 'SELECT idEpisode, c18 FROM episode where c18 LIKE "%s"' % sql_old_folder
nun_records, records = execute_sql_kodi(sql)
if records:
for record in records:
@@ -890,61 +899,39 @@ def update_db(old_path, new_path, old_movies_folder, new_movies_folder, old_tvsh
xbmc.executebuiltin('XBMC.ReloadSkin()')
def clean_db():
def clean_db(path=''):
logger.info()
progress = platformtools.dialog_progress_bg(config.get_localized_string(20000), config.get_localized_string(80025))
progress.update(0)
config.set_setting('videolibrary_kodi', False)
path = config.get_setting('videolibrarypath')
# rename main path for search in the DB
if path.startswith("special://") or '://' in path: sep = '/'
if path.startswith("special://"):
path = path.replace('/profile/', '/%/').replace('/home/userdata/', '/%/')
sep = '/'
elif '://' in path:
sep = '/'
else: sep = os.sep
if not path.endswith(sep):
path += sep
# search main path in the DB
progress = platformtools.dialog_progress_bg(config.get_localized_string(20000), config.get_localized_string(80025))
progress.update(0)
idParentPath = 0
# search video library path in the DB
sql = 'SELECT idPath FROM path where strPath LIKE "%s"' % path
nun_records, records = execute_sql_kodi(sql)
# delete main path
# delete video library path
if records:
idPath = records[0][0]
sql = 'DELETE from path WHERE idPath=%s' % idPath
nun_records, records = execute_sql_kodi(sql)
progress.update(20)
path += '%'
# search sub folders in the DB
sql = 'SELECT idPath FROM path where strPath LIKE "%s"' % path
nun_records, records = execute_sql_kodi(sql)
# search TV shows in the DB
sql = 'SELECT idShow FROM tvshow_view where strPath LIKE "%s"' % path
nun_records, records_tvshow = execute_sql_kodi(sql)
# delete sub folders and files
if records:
for record in records:
idPath = record[0]
idParentPath = idPath
if not config.get_setting("videolibrary_kodi"):
sql = 'DELETE from path WHERE idPath=%s' % idPath
nun_records, records = execute_sql_kodi(sql)
sql = 'DELETE from files WHERE idPath=%s' % idPath
nun_records, records = execute_sql_kodi(sql)
progress.update(40)
# delete TV shows
if records_tvshow:
for record in records_tvshow:
idShow = record[0]
sql = 'DELETE from tvshow WHERE idShow=%s' % idShow
nun_records, records_tvshow = execute_sql_kodi(sql)
progress.update(60)
progress.update(10)
movies_path = path + config.get_setting("folder_movies")
if not movies_path.endswith(sep): movies_path += sep
movies_path += '%'
# search movies in the DB
sql = 'SELECT idMovie FROM movie where c22 LIKE "%s"' % path
sql = 'SELECT idMovie FROM movie where c22 LIKE "%s"' % movies_path
nun_records, records = execute_sql_kodi(sql)
# delete movies
if records:
@@ -952,10 +939,38 @@ def clean_db():
idMovie = record[0]
sql = 'DELETE from movie WHERE idMovie=%s' % idMovie
nun_records, records = execute_sql_kodi(sql)
progress.update(80)
progress.update(28)
# search movies path and folders in the DB
sql = 'SELECT idPath, idParentPath FROM path where strPath LIKE "%s"' % movies_path
nun_records, records = execute_sql_kodi(sql)
# delete movies path and folders
if records:
for record in records:
if record[1] == idParentPath and config.get_setting("videolibrary_kodi"):
continue
idPath = record[0]
sql = 'DELETE from path WHERE idPath=%s' % idPath
nun_records, records = execute_sql_kodi(sql)
progress.update(46)
tvshows_path = path + config.get_setting("folder_tvshows")
if not tvshows_path.endswith(sep): tvshows_path += sep
tvshows_path += '%'
# search TV shows in the DB
sql = 'SELECT idShow FROM tvshow_view where strPath LIKE "%s"' % tvshows_path
nun_records, records = execute_sql_kodi(sql)
# delete TV shows
if records:
for record in records:
idShow = record[0]
sql = 'DELETE from tvshow WHERE idShow=%s' % idShow
nun_records, records = execute_sql_kodi(sql)
progress.update(64)
# search episodes in the DB
sql = 'SELECT idEpisode FROM episode where c18 LIKE "%s"' % path
sql = 'SELECT idEpisode FROM episode where c18 LIKE "%s"' % tvshows_path
nun_records, records = execute_sql_kodi(sql)
# delete episodes
if records:
@@ -963,6 +978,20 @@ def clean_db():
idEpisode = record[0]
sql = 'DELETE from episode WHERE idEpisode=%s' % idEpisode
nun_records, records = execute_sql_kodi(sql)
progress.update(82)
# search TV shows path and folders in the DB
sql = 'SELECT idPath, idParentPath FROM path where strPath LIKE "%s"' % tvshows_path
nun_records, records = execute_sql_kodi(sql)
# delete tvshows path and folders
if records:
for record in records:
if record[1] == idParentPath and config.get_setting("videolibrary_kodi"):
continue
idPath = record[0]
sql = 'DELETE from path WHERE idPath=%s' % idPath
nun_records, records = execute_sql_kodi(sql)
progress.update(100)
xbmc.sleep(1000)
progress.close()

View File

@@ -120,7 +120,7 @@ msgid "SetResolvedUrl"
msgstr ""
msgctxt "#30028"
msgid "Built-In"
msgid "Built-in"
msgstr ""
msgctxt "#30029"
@@ -6095,7 +6095,7 @@ msgstr ""
msgctxt "#80007"
msgid "Importing video library..."
msgstr "Importazione videoteca..."
msgstr ""
msgctxt "#80008"
msgid "The video library has been imported"
@@ -6207,4 +6207,20 @@ msgstr ""
msgctxt "#80035"
msgid "master (beta version under development)"
msgstr ""
msgctxt "#80036"
msgid "Delete video library"
msgstr ""
msgctxt "#80037"
msgid "Attention, the entire video library will be deleted. Proceed anyway?"
msgstr ""
msgctxt "#80038"
msgid "Deleting video library..."
msgstr ""
msgctxt "#80039"
msgid "The video library has been deleted"
msgstr ""

View File

@@ -113,15 +113,15 @@ msgstr "Mostra impostazioni KoD"
msgctxt "#30026"
msgid "Direct"
msgstr "Direct"
msgstr "Diretta"
msgctxt "#30027"
msgid "SetResolvedUrl"
msgstr "SetResolvedUrl"
msgstr "Segnalibro"
msgctxt "#30028"
msgid "Built-In"
msgstr "Built-In"
msgid "Built-in"
msgstr "Built-in"
msgctxt "#30029"
msgid "Download and play"
@@ -6207,4 +6207,20 @@ msgstr "release (versione stabile)"
msgctxt "#80035"
msgid "master (beta version under development)"
msgstr "master (versione beta in fase di sviluppo)"
msgstr "master (versione beta in fase di sviluppo)"
msgctxt "#80036"
msgid "Delete video library"
msgstr "Elimina videoteca"
msgctxt "#80037"
msgid "Attention, the entire video library will be deleted. Proceed anyway?"
msgstr "Attenzione, l'intera videoteca verrà eliminata. Procedere comunque?"
msgctxt "#80038"
msgid "Deleting video library..."
msgstr "Eliminazione videoteca..."
msgctxt "#80039"
msgid "The video library has been deleted"
msgstr "La videoteca è stata eliminata"

View File

@@ -43,6 +43,7 @@
<setting id="vidolibrary_preferences" type="action" label="60542" action="RunPlugin(plugin://plugin.video.kod/?ew0KICAgICJhY3Rpb24iOiAiY2hhbm5lbF9jb25maWciLA0KICAgICJjaGFubmVsIjogInZpZGVvbGlicmFyeSINCn0==)"/>
<setting id="vidolibrary_export" type="action" label="80000" action="RunPlugin(plugin://plugin.video.kod/?ew0KICAgICJhY3Rpb24iOiAiZXhwb3J0X3ZpZGVvbGlicmFyeSIsDQogICAgImNoYW5uZWwiOiAiYmFja3VwIg0KfQ==)"/>
<setting id="vidolibrary_import" type="action" label="80001" action="RunPlugin(plugin://plugin.video.kod/?ew0KICAgICJhY3Rpb24iOiAiaW1wb3J0X3ZpZGVvbGlicmFyeSIsDQogICAgImNoYW5uZWwiOiAiYmFja3VwIg0KfQ==)"/>
<setting id="vidolibrary_delete" type="action" label="80036" action="RunPlugin(plugin://plugin.video.kod/?ew0KICAgICJhY3Rpb24iOiAiZGVsZXRlX3ZpZGVvbGlicmFyeSIsDQogICAgImNoYW5uZWwiOiAidmlkZW9saWJyYXJ5Ig0KfQ==)"/>
<setting id="vidolibrary_restore" type="action" label="60567" action="RunPlugin(plugin://plugin.video.kod/?ew0KICAgICJhY3Rpb24iOiAicmVzdG9yZV90b29scyIsDQogICAgImNoYW5uZWwiOiAic2V0dGluZyINCn0=)"/>
<setting id="vidolibrary_update" type="action" label="60568" action="RunPlugin(plugin://plugin.video.kod/?ew0KICAgICJhY3Rpb24iOiAidXBkYXRlX3ZpZGVvbGlicmFyeSIsDQogICAgImNoYW5uZWwiOiAidmlkZW9saWJyYXJ5Ig0KfQ==)"/>
</category>

View File

@@ -59,6 +59,8 @@ def get_video_url(page_url, premium=False, user="", password="", video_password=
video_urls.append(['%s [%s]' % (key['type'].replace('video/', ''), key['label']),
key['src'].replace('https', 'http') + '|' + _headers])
else:
if not 'src' in key and 'file' in key: key['src'] = key['file']
if key['file'].split('.')[-1] == 'mpd': pass
video_urls.append([key['src'].split('.')[-1], key['src'].replace('https', 'http') + '|' + _headers])
except:
pass

View File

@@ -44,9 +44,9 @@ def export_videolibrary(item):
filetools.rmdirtree(temp_path)
p_dialog.update(100)
xbmc.sleep(2000)
xbmc.sleep(1000)
p_dialog.close()
platformtools.dialog_ok(config.get_localized_string(20000), config.get_localized_string(80004))
platformtools.dialog_notification(config.get_localized_string(20000), config.get_localized_string(80004), icon=0, time=5000, sound=False)
def import_videolibrary(item):
@@ -69,11 +69,11 @@ def import_videolibrary(item):
unzipper.extract(zip_file, temp_path)
p_dialog.update(25)
filetools.rmdirtree(videolibrarytools.VIDEOLIBRARY_PATH)
filetools.rmdirtree(videolibrarytools.MOVIES_PATH)
filetools.rmdirtree(videolibrarytools.TVSHOWS_PATH)
p_dialog.update(50)
if config.is_xbmc() and config.get_setting("videolibrary_kodi"):
xbmc.sleep(5000)
xbmc_videolibrary.clean()
xbmc_videolibrary.clean(config.get_setting('videolibrarypath'))
config.verify_directories_created()
if filetools.exists(movies_path):
@@ -85,9 +85,9 @@ def import_videolibrary(item):
filetools.rmdirtree(temp_path)
p_dialog.update(100)
xbmc.sleep(2000)
xbmc.sleep(1000)
p_dialog.close()
platformtools.dialog_ok(config.get_localized_string(20000), config.get_localized_string(80008))
platformtools.dialog_notification(config.get_localized_string(20000), config.get_localized_string(80008), icon=0, time=5000, sound=False)
if platformtools.dialog_yesno(config.get_localized_string(20000), config.get_localized_string(80009)):
import service

View File

@@ -749,6 +749,31 @@ def move_videolibrary(current_path, new_path, current_movies_folder, new_movies_
platformtools.dialog_notification(config.get_localized_string(20000), config.get_localized_string(80014), icon=0, time=5000, sound=False)
def delete_videolibrary(item):
logger.info()
if not platformtools.dialog_yesno(config.get_localized_string(20000), config.get_localized_string(80037)):
return
p_dialog = platformtools.dialog_progress_bg(config.get_localized_string(20000), config.get_localized_string(80038))
p_dialog.update(0)
filetools.rmdirtree(videolibrarytools.MOVIES_PATH)
p_dialog.update(40)
filetools.rmdirtree(videolibrarytools.TVSHOWS_PATH)
p_dialog.update(80)
if config.is_xbmc() and config.get_setting("videolibrary_kodi"):
from platformcode import xbmc_videolibrary
xbmc_videolibrary.clean(config.get_setting('videolibrarypath'))
p_dialog.update(90)
config.verify_directories_created()
p_dialog.update(100)
xbmc.sleep(1000)
p_dialog.close()
platformtools.dialog_notification(config.get_localized_string(20000), config.get_localized_string(80039), icon=0, time=5000, sound=False)
# metodos de menu contextual
def update_tvshow(item):
logger.info()