KoD 0.9.1

- fix vari ed eventuali
This commit is contained in:
marco
2020-04-20 23:49:45 +02:00
parent dc3d2d4d2a
commit ca0b5a8c56
28 changed files with 1048 additions and 798 deletions
+39 -85
View File
@@ -61,8 +61,7 @@ def mainlist(item):
# Comprobamos que la serie no este ya en el itemlist
if not [x for x in itemlist if x.contentSerieName == i.contentSerieName and x.contentChannel == i.contentChannel]:
title = TITLE_TVSHOW % (
STATUS_COLORS[i.downloadStatus], i.downloadProgress, i.contentSerieName, i.contentChannel)
title = TITLE_TVSHOW % (STATUS_COLORS[i.downloadStatus], i.downloadProgress, i.contentSerieName, i.contentChannel)
itemlist.append(Item(title=title, channel="downloads", action="mainlist", contentType="tvshow",
contentSerieName=i.contentSerieName, contentChannel=i.contentChannel,
@@ -78,8 +77,7 @@ def mainlist(item):
STATUS_CODES.completed, STATUS_CODES.stoped]:
s.downloadStatus = i.downloadStatus
s.title = TITLE_TVSHOW % (
STATUS_COLORS[s.downloadStatus], downloadProgress, i.contentSerieName, i.contentChannel)
s.title = TITLE_TVSHOW % (STATUS_COLORS[s.downloadStatus], downloadProgress, i.contentSerieName, i.contentChannel)
# Peliculas
elif i.contentType == "movie" or i.contentType == "video":
@@ -89,8 +87,7 @@ def mainlist(item):
# Listado dentro de una serie
else:
if i.contentType == "episode" and i.contentSerieName == item.contentSerieName and i.contentChannel == item.contentChannel:
i.title = TITLE_FILE % (STATUS_COLORS[i.downloadStatus], i.downloadProgress,
"%dx%0.2d: %s" % (i.contentSeason, i.contentEpisodeNumber, i.contentTitle))
i.title = TITLE_FILE % (STATUS_COLORS[i.downloadStatus], i.downloadProgress, "%dx%0.2d: %s" % (i.contentSeason, i.contentEpisodeNumber, i.contentTitle))
itemlist.append(i)
estados = [i.downloadStatus for i in itemlist]
@@ -186,11 +183,13 @@ def clean_all(item):
for fichero in sorted(filetools.listdir(DOWNLOAD_LIST_PATH)):
if fichero.endswith(".json"):
download_item = Item().fromjson(filetools.read(filetools.join(DOWNLOAD_LIST_PATH, fichero)))
if not item.contentType == "tvshow" or (
item.contentSerieName == download_item.contentSerieName and item.contentChannel == download_item.contentChannel):
if not item.contentType == "tvshow" or ( item.contentSerieName == download_item.contentSerieName and item.contentChannel == download_item.contentChannel):
filetools.remove(filetools.join(DOWNLOAD_LIST_PATH, fichero))
if removeFiles:
filetools.remove(filetools.join(DOWNLOAD_PATH, download_item.downloadFilename))
dirName = filetools.join(DOWNLOAD_PATH, filetools.dirname(download_item.downloadFilename))
if len(filetools.listdir(dirName)) == 0:
filetools.rmdir(dirName)
xbmc.sleep(100)
platformtools.itemlist_refresh()
@@ -208,7 +207,7 @@ def stop_all(item=None):
download_item = Item().fromjson(filetools.read(filetools.join(DOWNLOAD_LIST_PATH, fichero)))
if download_item.downloadStatus == 4:
update_json(filetools.join(DOWNLOAD_LIST_PATH, fichero), {"downloadStatus": STATUS_CODES.stoped})
xbmc.sleep(100)
xbmc.sleep(300)
if item:
platformtools.itemlist_refresh()
@@ -218,8 +217,7 @@ def clean_ready(item):
for fichero in sorted(filetools.listdir(DOWNLOAD_LIST_PATH)):
if fichero.endswith(".json"):
download_item = Item().fromjson(filetools.read(filetools.join(DOWNLOAD_LIST_PATH, fichero)))
if not item.contentType == "tvshow" or (
item.contentSerieName == download_item.contentSerieName and item.contentChannel == download_item.contentChannel):
if not item.contentType == "tvshow" or ( item.contentSerieName == download_item.contentSerieName and item.contentChannel == download_item.contentChannel):
if download_item.downloadStatus == STATUS_CODES.completed:
filetools.remove(filetools.join(DOWNLOAD_LIST_PATH, fichero))
@@ -232,8 +230,7 @@ def restart_error(item):
if fichero.endswith(".json"):
download_item = Item().fromjson(filetools.read(filetools.join(DOWNLOAD_LIST_PATH, fichero)))
if not item.contentType == "tvshow" or (
item.contentSerieName == download_item.contentSerieName and item.contentChannel == download_item.contentChannel):
if not item.contentType == "tvshow" or ( item.contentSerieName == download_item.contentSerieName and item.contentChannel == download_item.contentChannel):
if download_item.downloadStatus == STATUS_CODES.error:
if filetools.isfile(
filetools.join(DOWNLOAD_PATH, download_item.downloadFilename)):
@@ -259,8 +256,7 @@ def download_all_background(item):
download_item = Item(path=filetools.join(DOWNLOAD_LIST_PATH, fichero)).fromjson(
filetools.read(filetools.join(DOWNLOAD_LIST_PATH, fichero)))
if not item.contentType == "tvshow" or (
item.contentSerieName == download_item.contentSerieName and item.contentChannel == download_item.contentChannel):
if not item.contentType == "tvshow" or ( item.contentSerieName == download_item.contentSerieName and item.contentChannel == download_item.contentChannel):
if download_item.downloadStatus in [STATUS_CODES.stoped, STATUS_CODES.canceled]:
res = start_download(download_item)
# platformtools.itemlist_refresh()
@@ -361,14 +357,14 @@ def move_to_libray(item):
move_path = filetools.join(config.get_videolibrary_path(), FOLDER)
download_path = filetools.join(DOWNLOAD_PATH, item.downloadFilename)
library_path = filetools.join(move_path, *filetools.split(item.downloadFilename))
library_path = filetools.join(move_path, *filetools.split(item.downloadFilename))
final_path = download_path
if item.contentType == "movie" and item.infoLabels["tmdb_id"]:
contentTitle = item.contentTitle if item.contentTitle else item.fulltitle
library_item = Item(title= filetools.split(item.downloadFilename)[-1], channel="downloads", contentTitle = contentTitle,
fulltitle = item.fulltitle,action="findvideos", infoLabels=item.infoLabels, url=library_path)
videolibrarytools.save_movie(library_item)
videolibrarytools.save_movie(library_item, silent=True)
elif item.contentType == "episode" and item.infoLabels["tmdb_id"]:
contentSerieName = item.contentSerieName if item.contentSerieName else item.fulltitle
@@ -376,7 +372,7 @@ def move_to_libray(item):
fulltitle = item.fulltitle, action="findvideos", infoLabels=item.infoLabels, url=library_path)
tvshow = Item(channel="downloads", contentType="tvshow", contentSerieName = contentSerieName,
fulltitle = item.fulltitle, infoLabels={"tmdb_id": item.infoLabels["tmdb_id"]})
videolibrarytools.save_tvshow(tvshow, [library_item])
videolibrarytools.save_tvshow(tvshow, [library_item], silent=True)
if not filetools.isdir(filetools.dirname(library_path)):
filetools.mkdir(filetools.dirname(library_path))
@@ -410,61 +406,11 @@ def move_to_libray(item):
if config.is_xbmc() and config.get_setting("videolibrary_kodi"):
from platformcode import xbmc_videolibrary
if clean == True:
xbmc_videolibrary.clean(file_strm_path)
strm_list = []
strm_list.append(file_strm_path)
xbmc_videolibrary.clean(strm_list)
xbmc_videolibrary.update(FOLDER, path_title)
"""if config.get_setting("library_add") == True and config.get_setting("library_move") == True:
if not filetools.isdir(filetools.dirname(library_path)):
filetools.mkdir(filetools.dirname(library_path))
if filetools.isfile(library_path) and filetools.isfile(download_path):
filetools.remove(library_path)
if filetools.isfile(download_path):
if filetools.move(download_path, library_path):
final_path = library_path
if len(filetools.listdir(filetools.dirname(download_path))) == 0:
filetools.rmdir(filetools.dirname(download_path))
logger.info('ITEM = ' + str(item))
name = item.contentTitle if item.contentType == 'movie' else str(item.infoLabels['season']) + 'x' + str(item.infoLabels['episode']).zfill(2)
list_item = filetools.listdir(filetools.join(config.get_videolibrary_path(), FOLDER, path_title))
clean = False
for File in list_item:
filename = File.lower()
name = name.lower()
if filename.startswith(name) and (filename.endswith('.strm') or filename.endswith('.json') or filename.endswith('.nfo')):
clean = True
logger.info('Delete File: ' + str(filetools.join(config.get_videolibrary_path(), FOLDER, path_title, File)))
filetools.remove(filetools.join(config.get_videolibrary_path(), FOLDER, path_title, File))
if config.get_setting("videolibrary_kodi"):
from platformcode import xbmc_videolibrary
xbmc_videolibrary.update(FOLDER)
if clean == True:
import xbmc
while xbmc.getCondVisibility('Library.IsScanningVideo()'):
xbmc.sleep(500)
xbmc_videolibrary.clean()
if config.get_setting("library_add") == True and config.get_setting("library_move") == False:
if filetools.isfile(final_path):
if item.contentType == "movie" and item.infoLabels["tmdb_id"]:
library_item = Item(title=config.get_localized_string(70228) % item.downloadFilename, channel="downloads",
action="findvideos", infoLabels=item.infoLabels, url=final_path)
videolibrarytools.save_movie(library_item)
elif item.contentType == "episode" and item.infoLabels["tmdb_id"]:
library_item = Item(title=config.get_localized_string(70228) % item.downloadFilename, channel="downloads",
action="findvideos", infoLabels=item.infoLabels, url=final_path)
tvshow = Item(channel="downloads", contentType="tvshow",
infoLabels={"tmdb_id": item.infoLabels["tmdb_id"]})
videolibrarytools.save_tvshow(tvshow, [library_item])"""
def update_json(path, params):
item = Item().fromjson(filetools.read(path))
@@ -550,8 +496,7 @@ def get_match_list(data, match_list, order_list=None, only_ascii=False, ignoreca
# Si ascii = True, eliminamos todos los accentos y Ñ
if only_ascii:
data = ''.join((c for c in unicodedata.normalize('NFD', data) if unicodedata.category(c) != 'Mn'))
match_dict = dict((''.join((c for c in unicodedata.normalize('NFD', key) if unicodedata.category(c) != 'Mn')),
match_dict[key]) for key in match_dict)
match_dict = dict((''.join((c for c in unicodedata.normalize('NFD', key) if unicodedata.category(c) != 'Mn')), match_dict[key]) for key in match_dict)
# Ordenamos el listado de mayor tamaño a menor y buscamos.
for match in sorted(match_dict, key=lambda x: len(x), reverse=True):
@@ -836,7 +781,13 @@ def select_server(item):
if not i.server and hasattr(channel, "play"):
play_items[x] = getattr(channel, "play")(i)
seleccion = platformtools.dialog_select(config.get_localized_string(70192), ["Auto"] + [s.title for s in play_items])
if len(play_items) == 1:
# if there is only one server select it
seleccion = 1
else:
# altrimenti mostra la finestra di selezione
seleccion = platformtools.dialog_select(config.get_localized_string(70192), ["Auto"] + [s.title for s in play_items])
if seleccion >= 1:
update_json(item.path, {
"downloadServer": {"url": play_items[seleccion - 1].url, "server": play_items[seleccion - 1].server}})
@@ -959,8 +910,7 @@ def write_json(item):
if not item.contentThumbnail:
item.contentThumbnail = item.thumbnail
for name in ["text_bold", "text_color", "text_italic", "context", "totalItems", "viewmode", "title", "contentTitle",
"thumbnail"]:
for name in ["text_bold", "text_color", "text_italic", "context", "totalItems", "viewmode", "title", "contentTitle", "thumbnail"]:
if name in item.__dict__:
item.__dict__.pop(name)
@@ -996,7 +946,10 @@ def save_download_background(item):
if item.channel == 'videolibrary':
from specials import videolibrary
parent = Item().fromurl(item.parent)
if not item.parent:
parent = item
else:
parent = Item().fromurl(item.parent)
parent.contentChannel = 'videolibrary'
if item.downloadItemlist: # episode
parent.downloadItemlist = item.downloadItemlist
@@ -1047,15 +1000,13 @@ def save_download_video(item):
write_json(item)
if not platformtools.dialog_yesno(config.get_localized_string(30101), config.get_localized_string(70189)):
platformtools.dialog_ok(config.get_localized_string(30101), item.contentTitle,
config.get_localized_string(30109))
platformtools.dialog_ok(config.get_localized_string(30101), item.contentTitle, config.get_localized_string(30109))
else:
start_download(item)
def save_download_movie(item):
logger.info("contentAction: %s | contentChannel: %s | contentTitle: %s" % (
item.contentAction, item.contentChannel, item.contentTitle))
logger.info("contentAction: %s | contentChannel: %s | contentTitle: %s" % ( item.contentAction, item.contentChannel, item.contentTitle))
progreso = platformtools.dialog_progress_bg(config.get_localized_string(30101), config.get_localized_string(70191))
@@ -1068,7 +1019,7 @@ def save_download_movie(item):
progreso.update(0, config.get_localized_string(60062))
item.downloadFilename = filetools.validate_path("%s [%s] [%s]" % (item.contentTitle.strip(), item.contentChannel, item.infoLabels['IMDBNumber']))
item.downloadFilename = filetools.validate_path("%s [%s]" % (item.contentTitle.strip(), item.infoLabels['IMDBNumber']))
write_json(item)
@@ -1096,11 +1047,15 @@ def save_download_tvshow(item):
try:
item.show = item.fulltitle
scraper.find_and_set_infoLabels(item)
if not item.contentSerieName: item.contentSerieName = item.fulltitle
item.downloadFilename = filetools.validate_path("%s [%s]" % (item.contentSerieName, item.infoLabels['IMDBNumber']))
if item.strm_path: item.downloadFilename = filetools.validate_path(item.strm_path.split(os.sep)[-2])
else: item.downloadFilename = filetools.validate_path("%s [%s]" % (item.contentSerieName, item.infoLabels['IMDBNumber']))
if config.get_setting("lowerize_title", "videolibrary"):
item.downloadFilename = item.downloadFilename.lower()
progreso.update(0, config.get_localized_string(70186), config.get_localized_string(70180) % item.contentChannel)
episodes = get_episodes(item)
@@ -1108,8 +1063,7 @@ def save_download_tvshow(item):
progreso.update(0, config.get_localized_string(70190), " ")
for x, i in enumerate(episodes):
progreso.update(old_div(x * 100, len(episodes)),
"%dx%0.2d: %s" % (i.contentSeason, i.contentEpisodeNumber, i.contentTitle))
progreso.update(old_div(x * 100, len(episodes)), "%dx%0.2d: %s" % (i.contentSeason, i.contentEpisodeNumber, i.contentTitle))
write_json(i)
finally:
progreso.close()