Supporto episodi locali + revisione metodo clean + alcuni fix + revisione strings.po

This commit is contained in:
axlt2002
2020-05-08 18:09:51 +02:00
parent b794133b1a
commit ad59f4e03f
11 changed files with 548 additions and 408 deletions
+7 -10
View File
@@ -10,6 +10,7 @@ import xbmc
from core import ziptools, videolibrarytools, filetools
from platformcode import logger, config, platformtools, xbmc_videolibrary
from distutils.dir_util import copy_tree
from specials import videolibrary
temp_path = xbmc.translatePath("special://userdata/addon_data/plugin.video.kod/temp/")
movies_path = os.path.join(temp_path, "movies")
@@ -67,15 +68,14 @@ def import_videolibrary(item):
unzipper = ziptools.ziptools()
unzipper.extract(zip_file, temp_path)
p_dialog.update(25)
p_dialog.update(20)
if config.is_xbmc() and config.get_setting("videolibrary_kodi"):
xbmc_videolibrary.clean()
p_dialog.update(30)
filetools.rmdirtree(videolibrarytools.MOVIES_PATH)
filetools.rmdirtree(videolibrarytools.TVSHOWS_PATH)
p_dialog.update(50)
if config.is_xbmc() and config.get_setting("videolibrary_kodi"):
strm_list = []
strm_list.append(config.get_setting('videolibrarypath'))
xbmc_videolibrary.clean(strm_list)
config.verify_directories_created()
if filetools.exists(movies_path):
@@ -91,9 +91,6 @@ def import_videolibrary(item):
p_dialog.close()
platformtools.dialog_notification(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)):
import service
service.check_for_update(overwrite=True)
videolibrary.update_videolibrary()
if config.is_xbmc() and config.get_setting("videolibrary_kodi"):
xbmc_videolibrary.update()
xbmc_videolibrary.update()
+2 -3
View File
@@ -433,9 +433,8 @@ def move_to_libray(item):
if config.is_xbmc() and config.get_setting("videolibrary_kodi"):
from platformcode import xbmc_videolibrary
if clean == True:
strm_list = []
strm_list.append(file_strm_path)
xbmc_videolibrary.clean(strm_list)
path_list = [file_strm_path]
xbmc_videolibrary.clean(path_list)
xbmc_videolibrary.update(FOLDER, path_title)
+4 -4
View File
@@ -8,12 +8,12 @@ def context():
# original
# if config.get_setting('quick_menu'): context.append((config.get_localized_string(60360).upper(), "XBMC.RunPlugin(plugin://plugin.video.kod/?%s)" % Item(channel='shortcuts', action="shortcut_menu").tourl()))
# if config.get_setting('side_menu'): context.append((config.get_localized_string(70737).upper(), "XBMC.RunPlugin(plugin://plugin.video.kod/?%s)" % Item(channel='shortcuts',action="side_menu").tourl()))
# if config.get_setting('kod_menu'): context.append((config.get_localized_string(30025), "XBMC.RunPlugin(plugin://plugin.video.kod/?%s)" % Item(channel='shortcuts', action="settings_menu").tourl()))
# if config.get_setting('kod_menu'): context.append((config.get_localized_string(60026), "XBMC.RunPlugin(plugin://plugin.video.kod/?%s)" % Item(channel='shortcuts', action="settings_menu").tourl()))
# pre-serialised
if config.get_setting('quick_menu'): context.append((config.get_localized_string(60360).upper(), 'XBMC.RunPlugin(plugin://plugin.video.kod/?ewogICAgImFjdGlvbiI6ICJzaG9ydGN1dF9tZW51IiwgCiAgICAiY2hhbm5lbCI6ICJzaG9ydGN1dHMiLCAKICAgICJpbmZvTGFiZWxzIjoge30KfQ%3D%3D)'))
if config.get_setting('side_menu'): context.append((config.get_localized_string(70737).upper(), 'XBMC.RunPlugin(plugin://plugin.video.kod/?ewogICAgImFjdGlvbiI6ICJzaWRlX21lbnUiLCAKICAgICJjaGFubmVsIjogInNob3J0Y3V0cyIsIAogICAgImluZm9MYWJlbHMiOiB7fQp9)'))
if config.get_setting('kod_menu'): context.append((config.get_localized_string(30025), 'XBMC.RunPlugin(plugin://plugin.video.kod/?ewogICAgImFjdGlvbiI6ICJzZXR0aW5nc19tZW51IiwgCiAgICAiY2hhbm5lbCI6ICJzaG9ydGN1dHMiLCAKICAgICJpbmZvTGFiZWxzIjoge30KfQ%3D%3D)'))
if config.get_setting('quick_menu'): context.append((config.get_localized_string(60360), 'XBMC.RunPlugin(plugin://plugin.video.kod/?ewogICAgImFjdGlvbiI6ICJzaG9ydGN1dF9tZW51IiwgCiAgICAiY2hhbm5lbCI6ICJzaG9ydGN1dHMiLCAKICAgICJpbmZvTGFiZWxzIjoge30KfQ%3D%3D)'))
if config.get_setting('side_menu'): context.append((config.get_localized_string(70737), 'XBMC.RunPlugin(plugin://plugin.video.kod/?ewogICAgImFjdGlvbiI6ICJzaWRlX21lbnUiLCAKICAgICJjaGFubmVsIjogInNob3J0Y3V0cyIsIAogICAgImluZm9MYWJlbHMiOiB7fQp9)'))
if config.get_setting('kod_menu'): context.append((config.get_localized_string(60026), 'XBMC.RunPlugin(plugin://plugin.video.kod/?ewogICAgImFjdGlvbiI6ICJzZXR0aW5nc19tZW51IiwgCiAgICAiY2hhbm5lbCI6ICJzaG9ydGN1dHMiLCAKICAgICJpbmZvTGFiZWxzIjoge30KfQ%3D%3D)'))
return context
+70 -67
View File
@@ -4,6 +4,76 @@
"active": false,
"language": ["*"],
"settings": [
{
"id": "update",
"type": "list",
"label": "@60601",
"default": 1,
"visible": true,
"lvalues": [
"@60602",
"@60603",
"@60604",
"@60605"
]
},
{
"id": "update_wait",
"type": "list",
"label": "@60606",
"default": 0,
"enabled": "eq(-1,@60603)|eq(-1,@60605)",
"lvalues": [
"No",
"@60609",
"@60610",
"@60611",
"@60612"
]
},
{
"id": "everyday_delay",
"type": "list",
"label": "@60613",
"default": 1,
"enabled": "eq(-2,@60604)|eq(-2,@60605)",
"lvalues": [
"00:00",
"04:00",
"08:00",
"12:00",
"16:00",
"20:00"
]
},
{
"id": "updatetvshows_interval",
"type": "list",
"label": "@60614",
"default": 0,
"enabled": "!eq(-3,@60615)",
"lvalues": [
"@60616",
"@60617"
]
},
{
"id": "search_new_content",
"type": "list",
"label": "@60618",
"default": 0,
"enabled": "!eq(-4,@60615)",
"lvalues": [
"@60619",
"@60620"
]
},
{
"id": "local_episodes",
"type": "bool",
"label": "@80042",
"default": false
},
{
"id": "lab_1",
"type": "label",
@@ -55,73 +125,6 @@
"pt"
]
},
{
"id": "update",
"type": "list",
"label": "@60601",
"default": 1,
"visible": true,
"lvalues": [
"@60602",
"@60603",
"@60604",
"@60605"
]
},
{
"id": "update_wait",
"type": "list",
"label": "@60606",
"default": 0,
"visible": true,
"enabled": "eq(-1,@60603)|eq(-1,@60605)",
"lvalues": [
"No",
"@60609",
"@60610",
"@60611",
"@60612"
]
},
{
"id": "everyday_delay",
"type": "list",
"label": "@60613",
"default": 1,
"visible": true,
"enabled": "eq(-2,@60604)|eq(-2,@60605)",
"lvalues": [
"00:00",
"04:00",
"08:00",
"12:00",
"16:00",
"20:00"
]
},
{
"id": "updatetvshows_interval",
"type": "list",
"label": "@60614",
"default": 0,
"visible": true,
"enabled": "!eq(-3,@60615)",
"lvalues": [
"@60616",
"@60617"
]
},
{
"id": "search_new_content",
"type": "list",
"label": "@60618",
"default": 0,
"enabled": "!eq(-4,@60615)",
"lvalues": [
"@60619",
"@60620"
]
},
{
"id": "window_type",
"type": "list",
+113 -56
View File
@@ -306,6 +306,14 @@ def list_tvshows(item):
{"title": config.get_localized_string(70269),
"action": "update_tvshow",
"channel": "videolibrary"}]
if item_tvshow.local_episodes_path == "":
item_tvshow.context.append({"title": config.get_localized_string(80048),
"action": "add_local_episodes",
"channel": "videolibrary"})
else:
item_tvshow.context.append({"title": config.get_localized_string(80049),
"action": "remove_local_episodes",
"channel": "videolibrary"})
# ,{"title": "Cambiar contenido (PENDIENTE)",
# "action": "",
# "channel": "videolibrary"}]
@@ -322,7 +330,7 @@ def list_tvshows(item):
itemlist = sorted(itemlist, key=lambda it: it.title.lower())
itemlist.append(Item(channel=item.channel, action="update_videolibrary", thumbnail=item.thumbnail,
title=config.get_localized_string(60026), folder=False))
title=typo(config.get_localized_string(70269), 'bold color kod'), folder=False))
return itemlist
@@ -679,7 +687,7 @@ def play(item):
return itemlist
def update_videolibrary(item):
def update_videolibrary(item=''):
logger.info()
# Actualizar las series activas sobreescribiendo
@@ -768,17 +776,15 @@ def delete_videolibrary(item):
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
strm_list = []
strm_list.append(config.get_setting('videolibrarypath'))
xbmc_videolibrary.clean(strm_list)
xbmc_videolibrary.clean()
p_dialog.update(10)
filetools.rmdirtree(videolibrarytools.MOVIES_PATH)
p_dialog.update(50)
filetools.rmdirtree(videolibrarytools.TVSHOWS_PATH)
p_dialog.update(90)
config.verify_directories_created()
p_dialog.update(100)
xbmc.sleep(1000)
@@ -796,12 +802,59 @@ def update_tvshow(item):
p_dialog.update(0, heading, item.contentSerieName)
import service
if service.update(item.path, p_dialog, 1, 1, item, False) and config.is_xbmc() and config.get_setting("videolibrary_kodi"):
if service.update(item.path, p_dialog, 0, 100, item, False) and config.is_xbmc() and config.get_setting("videolibrary_kodi"):
from platformcode import xbmc_videolibrary
xbmc_videolibrary.update(folder=filetools.basename(item.path))
p_dialog.close()
# check if the TV show is ended or has been canceled and ask the user to remove it from the video library update
nfo_path = filetools.join(item.path, "tvshow.nfo")
head_nfo, item_nfo = videolibrarytools.read_nfo(nfo_path)
if item.active and not item_nfo.active:
if not platformtools.dialog_yesno(config.get_localized_string(60037).replace('...',''), config.get_localized_string(70268) % item.contentSerieName):
item_nfo.active = 1
filetools.write(nfo_path, head_nfo + item_nfo.tojson())
platformtools.itemlist_refresh()
def add_local_episodes(item):
logger.info()
done, local_episodes_path = videolibrarytools.config_local_episodes_path(item.path, item.contentSerieName)
if done < 0:
logger.info("An issue has occurred while configuring local episodes")
elif local_episodes_path:
nfo_path = filetools.join(item.path, "tvshow.nfo")
head_nfo, item_nfo = videolibrarytools.read_nfo(nfo_path)
item_nfo.local_episodes_path = local_episodes_path
if not item_nfo.active:
item_nfo.active = 1
filetools.write(nfo_path, head_nfo + item_nfo.tojson())
update_tvshow(item)
platformtools.itemlist_refresh()
def remove_local_episodes(item):
logger.info()
nfo_path = filetools.join(item.path, "tvshow.nfo")
head_nfo, item_nfo = videolibrarytools.read_nfo(nfo_path)
for season_episode in item_nfo.local_episodes_list:
filetools.remove(filetools.join(item.path, season_episode + '.strm'))
item_nfo.local_episodes_list = []
item_nfo.local_episodes_path = ''
filetools.write(nfo_path, head_nfo + item_nfo.tojson())
update_tvshow(item)
platformtools.itemlist_refresh()
def verify_playcount_series(item, path):
logger.info()
@@ -1025,22 +1078,24 @@ def delete(item):
for file in filetools.listdir(_item.path):
if file.endswith(".strm") or file.endswith(".nfo") or file.endswith(".json")or file.endswith(".torrent"):
filetools.remove(filetools.join(_item.path, file))
raiz, carpeta_serie, ficheros = next(filetools.walk(_item.path))
if ficheros == []:
filetools.rmdir(_item.path)
if _item.contentType == 'movie':
heading = config.get_localized_string(70084)
else:
if _item.contentType == 'movie':
heading = config.get_localized_string(70084)
else:
heading = config.get_localized_string(70085)
if platformtools.dialog_yesno(heading, config.get_localized_string(70081)):
filetools.rmdirtree(_item.path)
heading = config.get_localized_string(70085)
if config.is_xbmc() and config.get_setting("videolibrary_kodi"):
from platformcode import xbmc_videolibrary
strm_list = []
strm_list.append(_item.extra)
xbmc_videolibrary.clean(strm_list)
if _item.local_episodes_path:
platformtools.dialog_ok(heading, config.get_localized_string(80047) % _item.infoLabels['title'])
path_list = [_item.extra]
xbmc_videolibrary.clean(path_list)
raiz, carpeta_serie, ficheros = next(filetools.walk(_item.path))
if ficheros == []:
filetools.rmdir(_item.path)
elif platformtools.dialog_yesno(heading, config.get_localized_string(70081) % os.path.basename(_item.path)):
filetools.rmdirtree(_item.path)
logger.info("All links removed")
xbmc.sleep(1000)
@@ -1068,8 +1123,8 @@ def delete(item):
if index == 0:
# Seleccionado Eliminar pelicula/serie
canal = None
delete_all(item)
return
elif index > 0:
# Seleccionado Eliminar canal X
@@ -1080,41 +1135,43 @@ def delete(item):
else:
canal = item.dead
if canal:
num_enlaces = 0
strm_list = []
for fd in filetools.listdir(item.path):
if fd.endswith(canal + '].json') or scrapertools.find_single_match(fd, '%s]_\d+.torrent' % canal):
if filetools.remove(filetools.join(item.path, fd)):
num_enlaces += 1
# Remove strm and nfo if no other channel
episode = fd.replace(' [' + canal + '].json', '')
found_ch = False
for ch in channels:
if filetools.exists(filetools.join(item.path, episode + ' [' + ch + '].json')):
found_ch = True
break
if found_ch == False:
filetools.remove(filetools.join(item.path, episode + '.nfo'))
filetools.remove(filetools.join(item.path, episode + '.strm'))
strm_list.append(filetools.join(item.extra, episode + '.strm'))
num_enlaces = 0
path_list = []
for fd in filetools.listdir(item.path):
if fd.endswith(canal + '].json') or scrapertools.find_single_match(fd, '%s]_\d+.torrent' % canal):
if filetools.remove(filetools.join(item.path, fd)):
num_enlaces += 1
# Remove strm and nfo if no other channel
episode = fd.replace(' [' + canal + '].json', '')
found_ch = False
for ch in channels:
if filetools.exists(filetools.join(item.path, episode + ' [' + ch + '].json')):
found_ch = True
break
if found_ch == False:
filetools.remove(filetools.join(item.path, episode + '.nfo'))
strm_path = filetools.join(item.path, episode + '.strm')
# if it is a local episode, do not delete the strm
if 'plugin://plugin.video.kod/?' in filetools.read(strm_path):
filetools.remove(strm_path)
path_list.append(filetools.join(item.extra, episode + '.strm'))
if config.is_xbmc() and config.get_setting("videolibrary_kodi") and strm_list:
from platformcode import xbmc_videolibrary
xbmc_videolibrary.clean(strm_list)
if config.is_xbmc() and config.get_setting("videolibrary_kodi") and path_list:
from platformcode import xbmc_videolibrary
xbmc_videolibrary.clean(path_list)
if num_enlaces > 0:
# Actualizar .nfo
head_nfo, item_nfo = videolibrarytools.read_nfo(item.nfo)
del item_nfo.library_urls[canal]
if item_nfo.emergency_urls and item_nfo.emergency_urls.get(canal, False):
del item_nfo.emergency_urls[canal]
filetools.write(item.nfo, head_nfo + item_nfo.tojson())
if num_enlaces > 0:
# Actualizar .nfo
head_nfo, item_nfo = videolibrarytools.read_nfo(item.nfo)
del item_nfo.library_urls[canal]
if item_nfo.emergency_urls and item_nfo.emergency_urls.get(canal, False):
del item_nfo.emergency_urls[canal]
filetools.write(item.nfo, head_nfo + item_nfo.tojson())
msg_txt = config.get_localized_string(70087) % (num_enlaces, canal)
logger.info(msg_txt)
platformtools.dialog_notification(heading, msg_txt)
platformtools.itemlist_refresh()
msg_txt = config.get_localized_string(70087) % (num_enlaces, canal)
logger.info(msg_txt)
platformtools.dialog_notification(heading, msg_txt)
platformtools.itemlist_refresh()
else:
if platformtools.dialog_yesno(heading, config.get_localized_string(70088) % item.infoLabels['title']):