From 6a3dde4ba0f32fd53a346ce56b303f2f333a06dd Mon Sep 17 00:00:00 2001 From: marco Date: Sun, 29 Mar 2020 17:13:14 +0200 Subject: [PATCH] Migliorie varie download e videolibrary_service rinominato in service --- addon.xml | 2 +- core/support.py | 6 +- core/videolibrarytools.py | 4 +- lib/generictools.py | 12 +- platformcode/custom_code.py | 2 +- platformcode/platformtools.py | 9 +- platformcode/updater.py | 4 +- resources/language/English/strings.po | 6 +- resources/language/Italian/strings.po | 12 +- videolibrary_service.py => service.py | 4 + specials/backup.py | 4 +- specials/downloads.py | 223 +++++++++++++++----------- specials/setting.py | 4 +- specials/videolibrary.py | 8 +- 14 files changed, 164 insertions(+), 136 deletions(-) rename videolibrary_service.py => service.py (99%) diff --git a/addon.xml b/addon.xml index e4a66104..543c9151 100644 --- a/addon.xml +++ b/addon.xml @@ -34,6 +34,6 @@ https://t.me/kodiondemand https://github.com/kodiondemand/addon - + diff --git a/core/support.py b/core/support.py index 5d26494f..cd27f35e 100755 --- a/core/support.py +++ b/core/support.py @@ -910,7 +910,7 @@ def download(itemlist, item, typography='', function_level=1, function=''): contentSerieName=item.contentSerieName if item.contentSerieName else '' contentTitle=item.contentTitle if item.contentTitle else '' - serverItemlist = [i.tourl() for i in itemlist] + downloadItemlist = [i.tourl() for i in itemlist] if itemlist and item.contentChannel != 'videolibrary': itemlist.append( @@ -927,7 +927,7 @@ def download(itemlist, item, typography='', function_level=1, function=''): contentTitle=contentTitle, path=item.path, thumbnail=thumb(thumb='downloads.png'), - serverItemlist=serverItemlist + downloadItemlist=downloadItemlist )) if from_action == 'episodios': itemlist.append( @@ -944,7 +944,7 @@ def download(itemlist, item, typography='', function_level=1, function=''): contentTitle=contentTitle, download='season', thumbnail=thumb(thumb='downloads.png'), - serverItemlist=serverItemlist + downloadItemlist=downloadItemlist )) return itemlist diff --git a/core/videolibrarytools.py b/core/videolibrarytools.py index 5c87c17d..f1bfb8e2 100644 --- a/core/videolibrarytools.py +++ b/core/videolibrarytools.py @@ -537,7 +537,7 @@ def save_tvshow(item, episodelist): item_tvshow.library_filter_show = {item.channel: item.show} if item.channel != "downloads": - item_tvshow.active = 1 # para que se actualice a diario cuando se llame a videolibrary_service + item_tvshow.active = 1 # para que se actualice a diario cuando se llame a service filetools.write(tvshow_path, head_nfo + item_tvshow.tojson()) @@ -601,7 +601,7 @@ def save_episodes(path, episodelist, serie, silent=False, overwrite=True): nostrm_episodelist.append(season_episode) nostrm_episodelist = sorted(set(nostrm_episodelist)) - # Silent es para no mostrar progreso (para videolibrary_service) + # Silent es para no mostrar progreso (para service) if not silent: # progress dialog p_dialog = platformtools.dialog_progress(config.get_localized_string(20000), config.get_localized_string(60064)) diff --git a/lib/generictools.py b/lib/generictools.py index e93a1b1e..bca3395e 100644 --- a/lib/generictools.py +++ b/lib/generictools.py @@ -1822,11 +1822,11 @@ def redirect_clone_newpct1(item, head_nfo=None, it=None, path=False, overwrite=F # - patron5: expresión Regex aplicable a la url (opcional) # - content_inc: contenido al que aplica esta entrada, o * (item.contentType o item.extra) # - content_exc: contenido que se excluye de esta entrada (item.contentType) (opcional). opción para 'emerg' - # - ow_force: indicador para la acción de "videolibrary_service.py". Puede crear la variable item.ow_force: - # - force: indica al canal que analize toda la serie y que videolibrary_service la reescriba - # - auto: indica a videolibrary_service que la reescriba - # - no: no acción para videolibrary_service, solo redirige en visionado de videolibrary - # - del: borra las estrucuturas de un determinado canal en videolibrary_service, quizás creadas por errores de un canal + # - ow_force: indicador para la acción de "service.py". Puede crear la variable item.ow_force: + # - force: indica al canal que analize toda la serie y que service la reescriba + # - auto: indica a service que la reescriba + # - no: no acción para service, solo redirige en visionado de videolibrary + # - del: borra las estrucuturas de un determinado canal en service, quizás creadas por errores de un canal # - emerg: funcionalidad muy similar a la de "del". se general dinámicamente cada vez que entra un canal con el estado activado en el .json de "emergency_urls". Permite cargar las urls de emergencia en todos los elementos existentes de la Videoteca para canal afectado # ejemplos: # ('1', 'mejortorrent', 'mejortorrent1', 'http://www.mejortorrent.com/', 'https://mejortorrent1.com/', '(http.?:\/\/.*?\/)', 'http.?:\/\/.*?\/.*?-torrent.?-[^-]+-(?:[^-]+-)([^0-9]+-)', 'http.?:\/\/.*?\/.*?-torrent.?-[^-]+-(?:[^-]+-)[^0-9]+-\\d+-(Temporada-).html', 'http.?:\/\/.*?\/.*?-torrent.?-[^-]+-(?:[^-]+-)[^0-9]+-(\\d+)-', '', 'tvshow, season', '', 'force'), @@ -1835,7 +1835,7 @@ def redirect_clone_newpct1(item, head_nfo=None, it=None, path=False, overwrite=F # ('1', 'newpct1', '', '', '', '', '', '', '', '', '*', '', 'del'), # ('1', 'torrentrapid', 'torrentrapid', '', '', '', '', '', '', '', '*', '1 ó 2', 'emerg'), # - # La llamada recibe el parámetro Item, el .nfo y los devuleve actualizados, así como opcionalmente el parámetro "overwrite· que puede forzar la reescritura de todos los archivos de la serie, y el parámetro "path" si viene de videolibrary_service. Por último, recibe opcionalmente el parámetro "lookup" si se quiere solo averigurar si habrá migración para ese título, pero sin realizarla. + # La llamada recibe el parámetro Item, el .nfo y los devuleve actualizados, así como opcionalmente el parámetro "overwrite· que puede forzar la reescritura de todos los archivos de la serie, y el parámetro "path" si viene de service. Por último, recibe opcionalmente el parámetro "lookup" si se quiere solo averigurar si habrá migración para ese título, pero sin realizarla. # # """ # #logger.debug(item) diff --git a/platformcode/custom_code.py b/platformcode/custom_code.py index 073cf03f..46ce5009 100644 --- a/platformcode/custom_code.py +++ b/platformcode/custom_code.py @@ -37,7 +37,7 @@ def init(): Los pasos que sigue esta función, son los siguientes: - 1.- La función se llama desde videolibrary_service.py, desde la función inicial: + 1.- La función se llama desde service.py, desde la función inicial: # Copia Custom code a las carpetas de Alfa desde la zona de Userdata from platformcode import custom_code custom_code.init() diff --git a/platformcode/platformtools.py b/platformcode/platformtools.py index ca94d8f2..a6d0a61a 100644 --- a/platformcode/platformtools.py +++ b/platformcode/platformtools.py @@ -1077,14 +1077,7 @@ def set_opcion(item, seleccion, opciones, video_urls): # "Descargar" elif opciones[seleccion] == config.get_localized_string(30153): from specials import downloads - import xbmcaddon - import xbmcgui - __addon__ = xbmcaddon.Addon() - __addonname__ = __addon__.getAddonInfo('name') - line1 = config.get_localized_string(70690) - line2 = config.get_localized_string(70691) - line3 = config.get_localized_string(70692) - xbmcgui.Dialog().ok(__addonname__, line1, line2, line3) + downloads.show_disclaimer() if item.contentType == "list" or item.contentType == "tvshow": item.contentType = "video" diff --git a/platformcode/updater.py b/platformcode/updater.py index 1c7e4c8f..cfcb379e 100644 --- a/platformcode/updater.py +++ b/platformcode/updater.py @@ -49,7 +49,7 @@ def loadCommits(page=1): return ret -# ret -> aggiornato, necessita reload videolibrary_service +# ret -> aggiornato, necessita reload service def check(background=False): if not addon.getSetting('addon_update_enabled'): return False, False @@ -109,7 +109,7 @@ def check(background=False): logger.info(file["filename"]) if 'resources/language' in file["filename"]: poFilesChanged = True - if 'videolibrary_service.py' in file["filename"]: + if 'service.py' in file["filename"]: serviceChanged = True if file['status'] == 'modified' or file['status'] == 'added': if 'patch' in file: diff --git a/resources/language/English/strings.po b/resources/language/English/strings.po index f9f56d2b..6e55ffd3 100644 --- a/resources/language/English/strings.po +++ b/resources/language/English/strings.po @@ -623,7 +623,7 @@ msgid "No links available that meets the requirements of the Black list. Try aga msgstr "" msgctxt "#60003" -msgid "Connessione con %s" +msgid "" msgstr "" msgctxt "#60004" @@ -631,7 +631,7 @@ msgid "No connector for the server %s" msgstr "" msgctxt "#60005" -msgid "Connecting with %s" +msgid "" msgstr "" msgctxt "#60006" @@ -3527,7 +3527,7 @@ msgid "Getting episodes..." msgstr "" msgctxt "#70187" -msgid "connecting with %s..." +msgid "" msgstr "" msgctxt "#70188" diff --git a/resources/language/Italian/strings.po b/resources/language/Italian/strings.po index 0d421573..21baec32 100644 --- a/resources/language/Italian/strings.po +++ b/resources/language/Italian/strings.po @@ -622,16 +622,16 @@ msgid "No links available that meets the requirements of the Black list. Try aga msgstr "Nessun collegamento disponibile che soddisfi i requisiti della Black list. Riprova modificando il filtro in 'Configurazione Server" msgctxt "#60003" -msgid "Connessione con %s" -msgstr "Connessione con %s" +msgid "" +msgstr "" msgctxt "#60004" msgid "No connector for the server %s" msgstr "Non c'è nessun connettore per il server %s" msgctxt "#60005" -msgid "Connecting with %s" -msgstr "Connessione con %s" +msgid "" +msgstr "" msgctxt "#60006" msgid "An error has occurred in %s" @@ -3526,8 +3526,8 @@ msgid "Getting episodes..." msgstr "Ottenimento episodi..." msgctxt "#70187" -msgid "connecting with %s..." -msgstr "connessione con %s..." +msgid "" +msgstr "" msgctxt "#70188" msgid "Obtaining data for the TV show" diff --git a/videolibrary_service.py b/service.py similarity index 99% rename from videolibrary_service.py rename to service.py index 3ec1f245..fb61d9c5 100644 --- a/videolibrary_service.py +++ b/service.py @@ -382,6 +382,10 @@ if __name__ == "__main__": import xbmc import time + # mark as stopped all downloads (if we are here, probably kodi just started) + from specials.downloads import stop_all + stop_all() + # modo adulto: # sistema actual 0: Nunca, 1:Siempre, 2:Solo hasta que se reinicie Kodi # si es == 2 lo desactivamos. diff --git a/specials/backup.py b/specials/backup.py index d50d5c61..6073929a 100644 --- a/specials/backup.py +++ b/specials/backup.py @@ -90,8 +90,8 @@ def import_videolibrary(item): platformtools.dialog_ok(config.get_localized_string(20000), config.get_localized_string(80008)) if platformtools.dialog_yesno(config.get_localized_string(20000), config.get_localized_string(80009)): - import videolibrary_service - videolibrary_service.check_for_update(overwrite=True) + import service + service.check_for_update(overwrite=True) if config.is_xbmc() and config.get_setting("videolibrary_kodi"): xbmc_videolibrary.update() diff --git a/specials/downloads.py b/specials/downloads.py index 62be01ff..d9775c3d 100644 --- a/specials/downloads.py +++ b/specials/downloads.py @@ -96,13 +96,6 @@ def mainlist(item): estados = [i.downloadStatus for i in itemlist] - # if there's at least one downloading - if 4 in estados: - itemlist.insert(0, Item(channel=item.channel, action="stop_all", title= support.typo(config.get_localized_string(60222),'bold'), - contentType=item.contentType, contentChannel=item.contentChannel, - contentSerieName=item.contentSerieName, thumbnail=get_thumb('stop.png'), - text_color=STATUS_COLORS[STATUS_CODES.downloading])) - # Si hay alguno completado if 2 in estados: itemlist.insert(0, Item(channel=item.channel, action="clean_ready", title=config.get_localized_string(70218), @@ -126,6 +119,13 @@ def mainlist(item): contentType=item.contentType, contentChannel=item.contentChannel, thumbnail=get_thumb('delete.png'), contentSerieName=item.contentSerieName)) + # if there's at least one downloading + if 4 in estados: + itemlist.insert(0, Item(channel=item.channel, action="stop_all", title=config.get_localized_string(60222), + contentType=item.contentType, contentChannel=item.contentChannel, + contentSerieName=item.contentSerieName, thumbnail=get_thumb('stop.png'), + text_color=STATUS_COLORS[STATUS_CODES.downloading])) + if not item.contentType == "tvshow" and config.get_setting("browser") == True: itemlist.insert(0, Item(channel=item.channel, action="browser", title=support.typo(config.get_localized_string(70222),'bold'), thumbnail=get_thumb('search.png'), url=DOWNLOAD_PATH)) @@ -179,7 +179,7 @@ def del_dir(item): def clean_all(item): logger.info() - stop_all(item) + stop_all() for fichero in sorted(filetools.listdir(DOWNLOAD_LIST_PATH)): if fichero.endswith(".json"): @@ -188,14 +188,14 @@ def clean_all(item): item.contentSerieName == download_item.contentSerieName and item.contentChannel == download_item.contentChannel): filetools.remove(filetools.join(DOWNLOAD_LIST_PATH, fichero)) xbmc.sleep(100) - platformtools.itemlist_update(item, True) + platformtools.itemlist_refresh() def reload(item): - platformtools.itemlist_update(item, True) + platformtools.itemlist_refresh() -def stop_all(item): +def stop_all(item=None): logger.info() for fichero in sorted(filetools.listdir(DOWNLOAD_LIST_PATH)): @@ -204,7 +204,8 @@ def stop_all(item): if download_item.downloadStatus == 4: update_json(filetools.join(DOWNLOAD_LIST_PATH, fichero), {"downloadStatus": STATUS_CODES.stoped}) xbmc.sleep(100) - platformtools.itemlist_update(item, True) + if item: + platformtools.itemlist_refresh() def clean_ready(item): @@ -217,7 +218,7 @@ def clean_ready(item): if download_item.downloadStatus == STATUS_CODES.completed: filetools.remove(filetools.join(DOWNLOAD_LIST_PATH, fichero)) - platformtools.itemlist_update(item, True) + platformtools.itemlist_refresh() def restart_error(item): @@ -237,14 +238,14 @@ def restart_error(item): update_json(item.path, {"downloadStatus": STATUS_CODES.stoped, "downloadComplete": 0, "downloadProgress": 0}) - platformtools.itemlist_update(item, True) + platformtools.itemlist_refresh() def download_all(item): time.sleep(0.5) item.action = "download_all_background" xbmc.executebuiltin("RunPlugin(plugin://plugin.video.kod/?" + item.tourl() + ")") - platformtools.itemlist_update(item, True) + platformtools.itemlist_refresh() def download_all_background(item): @@ -333,10 +334,10 @@ def menu(item): update_json(item.path, {"downloadStatus": STATUS_CODES.stoped}) if opciones[seleccion] == op[5]: - xbmc.executebuiltin('PlayMedia(' + filetools.join(DOWNLOAD_PATH, item.downloadFilename) + ')') + xbmc.executebuiltin('PlayMedia(' + filetools.join(DOWNLOAD_PATH, item.downloadFilename) + ',resume)') if opciones[seleccion] != op[5]: - platformtools.itemlist_update(item, True) + platformtools.itemlist_refresh() def move_to_libray(item): @@ -584,6 +585,12 @@ def download_from_url(url, item): part_size=2 ** (20 + int(config.get_setting("part_size", "downloads"))), max_buffer=2 * int(config.get_setting("max_buffer", "downloads")), json_path=item.path) + dir = filetools.dirname(item.downloadFilename) + file = filetools.join(dir, d.filename) + + update_json(item.path, {"downloadUrl": d.download_url, "downloadStatus": STATUS_CODES.downloading, "downloadSize": d.size[0], + "downloadProgress": d.progress, "downloadCompleted": d.downloaded[0], "downloadFilename": file}) + d.start_dialog(config.get_localized_string(60332)) # Descarga detenida. Obtenemos el estado: @@ -607,9 +614,6 @@ def download_from_url(url, item): save_server_statistics(item.server, d.speed[0], d.state != d.states.error) - dir = filetools.dirname(item.downloadFilename) - file = filetools.join(dir, d.filename) - if status == STATUS_CODES.completed: move_to_libray(item.clone(downloadFilename=file)) @@ -622,30 +626,32 @@ def download_from_server(item): unsupported_servers = ["torrent"] progreso = platformtools.dialog_progress_bg(config.get_localized_string(30101), config.get_localized_string(70178) % item.server) - if item.contentChannel == 'community': - channel = __import__('specials.%s' % item.contentChannel, None, None, ['specials.%s' % item.contentChannel]) - else: - channel = __import__('channels.%s' % item.contentChannel, None, None, ['channels.%s' % item.contentChannel]) - if hasattr(channel, "play") and not item.play_menu: - - progreso.update(50, config.get_localized_string(70178) % item.server, config.get_localized_string(60003) % item.contentChannel) - try: - itemlist = getattr(channel, "play")(item.clone(channel=item.contentChannel, action=item.contentAction)) - except: - logger.error("Error in the channel %s" % item.contentChannel) + try: + if item.contentChannel == 'community': + channel = __import__('specials.%s' % item.contentChannel, None, None, ['specials.%s' % item.contentChannel]) else: - if len(itemlist) and isinstance(itemlist[0], Item): - download_item = item.clone(**itemlist[0].__dict__) - download_item.contentAction = download_item.action - download_item.infoLabels = item.infoLabels - item = download_item - elif len(itemlist) and isinstance(itemlist[0], list): - item.video_urls = itemlist - if not item.server: item.server = "directo" + channel = __import__('channels.%s' % item.contentChannel, None, None, ['channels.%s' % item.contentChannel]) + if hasattr(channel, "play") and not item.play_menu: + + progreso.update(50, config.get_localized_string(70178) % item.server, config.get_localized_string(70180) % item.contentChannel) + try: + itemlist = getattr(channel, "play")(item.clone(channel=item.contentChannel, action=item.contentAction)) + except: + logger.error("Error in the channel %s" % item.contentChannel) else: - logger.info("There is nothing to reproduce") - return {"downloadStatus": STATUS_CODES.error} - progreso.close() + if len(itemlist) and isinstance(itemlist[0], Item): + download_item = item.clone(**itemlist[0].__dict__) + download_item.contentAction = download_item.action + download_item.infoLabels = item.infoLabels + item = download_item + elif len(itemlist) and isinstance(itemlist[0], list): + item.video_urls = itemlist + if not item.server: item.server = "directo" + else: + logger.info("There is nothing to reproduce") + return {"downloadStatus": STATUS_CODES.error} + finally: + progreso.close() logger.info("contentAction: %s | contentChannel: %s | server: %s | url: %s" % ( item.contentAction, item.contentChannel, item.server, item.url)) @@ -691,9 +697,9 @@ def download_from_best_server(item): result = {"downloadStatus": STATUS_CODES.error} progreso = platformtools.dialog_progress_bg(config.get_localized_string(30101), config.get_localized_string(70179)) try: - if item.serverItemlist: + if item.downloadItemlist: logger.info('using cached servers') - play_items = [Item().fromurl(i) for i in item.serverItemlist] + play_items = [Item().fromurl(i) for i in item.downloadItemlist] else: if item.contentChannel == 'community': channel = __import__('specials.%s' % item.contentChannel, None, None, ['specials.%s' % item.contentChannel]) @@ -739,42 +745,46 @@ def download_from_best_server(item): def select_server(item): + if item.server: + return "Auto" logger.info( "contentAction: %s | contentChannel: %s | url: %s" % (item.contentAction, item.contentChannel, item.url)) - - progreso = platformtools.dialog_progress(config.get_localized_string(30101), config.get_localized_string(70179)) - if item.serverItemlist: - logger.info('using cached servers') - play_items = [Item().fromurl(i) for i in item.serverItemlist] - else: - if item.contentChannel == 'community': - channel = __import__('specials.%s' % item.contentChannel, None, None, ['specials.%s' % item.contentChannel]) + progreso = platformtools.dialog_progress_bg(config.get_localized_string(30101), config.get_localized_string(70179)) + try: + if item.downloadItemlist: + logger.info('using cached servers') + play_items = [Item().fromurl(i) for i in item.downloadItemlist] else: - channel = __import__('channels.%s' % item.contentChannel, None, None, ['channels.%s' % item.contentChannel]) - progreso.update(50, config.get_localized_string(70184), config.get_localized_string(70180) % item.contentChannel) + if item.contentChannel == 'community': + channel = __import__('specials.%s' % item.contentChannel, None, None, ['specials.%s' % item.contentChannel]) + else: + channel = __import__('channels.%s' % item.contentChannel, None, None, ['channels.%s' % item.contentChannel]) + progreso.update(50, config.get_localized_string(70184), config.get_localized_string(70180) % item.contentChannel) - if hasattr(channel, item.contentAction): - play_items = getattr(channel, item.contentAction)( - item.clone(action=item.contentAction, channel=item.contentChannel)) - else: - play_items = servertools.find_video_items(item.clone(action=item.contentAction, channel=item.contentChannel)) + if hasattr(channel, item.contentAction): + play_items = getattr(channel, item.contentAction)( + item.clone(action=item.contentAction, channel=item.contentChannel)) + else: + play_items = servertools.find_video_items(item.clone(action=item.contentAction, channel=item.contentChannel)) - play_items = [x for x in play_items if x.action == "play" and not "trailer" in x.title.lower()] - progreso.update(100, config.get_localized_string(70183), config.get_localized_string(70181) % len(play_items)) + play_items = [x for x in play_items if x.action == "play" and not "trailer" in x.title.lower()] + progreso.update(100, config.get_localized_string(70183), config.get_localized_string(70181) % len(play_items)) + finally: + progreso.close() for x, i in enumerate(play_items): 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 seleccion > 1: + if seleccion >= 1: update_json(item.path, { "downloadServer": {"url": play_items[seleccion - 1].url, "server": play_items[seleccion - 1].server}}) + return play_items[seleccion - 1] elif seleccion == 0: update_json(item.path, {"downloadServer": {}}) - - # platformtools.itemlist_update(item, True) - return play_items[seleccion - 1] + return play_items[0] + # platformtools.itemlist_refresh() def start_download(item): @@ -809,13 +819,16 @@ def get_episodes(item): # El item es uma serie o temporada elif item.contentType in ["tvshow", "season"]: - # importamos el canal - if item.contentChannel == 'community': - channel = __import__('specials.%s' % item.contentChannel, None, None, ["specials.%s" % item.contentChannel]) + if item.downloadItemlist: + episodes = [Item().fromurl(i) for i in item.downloadItemlist] else: - channel = __import__('channels.%s' % item.contentChannel, None, None, ["channels.%s" % item.contentChannel]) - # Obtenemos el listado de episodios - episodes = getattr(channel, item.contentAction)(item) + # importamos el canal + if item.contentChannel == 'community': + channel = __import__('specials.%s' % item.contentChannel, None, None, ["specials.%s" % item.contentChannel]) + else: + channel = __import__('channels.%s' % item.contentChannel, None, None, ["channels.%s" % item.contentChannel]) + # Obtenemos el listado de episodios + episodes = getattr(channel, item.contentAction)(item) itemlist = [] @@ -896,6 +909,12 @@ def write_json(item): def save_download(item): logger.info() + show_disclaimer() + if item.channel != 'downloads': + item.from_channel = item.channel + item.from_action = item.action + + item.channel = "downloads" item.action = "save_download_background" xbmc.executebuiltin("RunPlugin(plugin://plugin.video.kod/?" + item.tourl() + ")") @@ -969,10 +988,13 @@ def save_download_movie(item): config.get_localized_string(30109)) else: play_item = select_server(item) - play_item = item.clone(**play_item.__dict__) - play_item.contentAction = play_item.action - play_item.infoLabels = item.infoLabels - start_download(play_item) + if play_item == 'Auto': + start_download(item) + else: + play_item = item.clone(**play_item.__dict__) + play_item.contentAction = play_item.action + play_item.infoLabels = item.infoLabels + start_download(play_item) def save_download_tvshow(item): @@ -980,25 +1002,26 @@ def save_download_tvshow(item): item.contentAction, item.contentChannel, item.contentType, item.contentSerieName)) progreso = platformtools.dialog_progress_bg(config.get_localized_string(30101), config.get_localized_string(70188)) + try: + item.show = item.fulltitle + scraper.find_and_set_infoLabels(item) + if not item.contentSerieName: item.contentSerieName = item.fulltitle - 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 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) - 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(70187) % item.contentChannel) + episodes = get_episodes(item) - episodes = get_episodes(item) + progreso.update(0, config.get_localized_string(70190), " ") - 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)) - write_json(i) - progreso.close() + for x, i in enumerate(episodes): + progreso.update(old_div(x * 100, len(episodes)), + "%dx%0.2d: %s" % (i.contentSeason, i.contentEpisodeNumber, i.contentTitle)) + write_json(i) + finally: + progreso.close() if not platformtools.dialog_yesno(config.get_localized_string(30101), config.get_localized_string(70189)): platformtools.dialog_ok(config.get_localized_string(30101), @@ -1007,12 +1030,13 @@ def save_download_tvshow(item): else: if len(episodes) == 1: play_item = select_server(item) - play_item = item.clone(**play_item.__dict__) - play_item.contentAction = play_item.action - play_item.infoLabels = item.infoLabels - from core import support - support.dbg() - start_download(play_item) + if play_item == 'Auto': + start_download(item) + else: + play_item = item.clone(**play_item.__dict__) + play_item.contentAction = play_item.action + play_item.infoLabels = item.infoLabels + start_download(play_item) else: for i in episodes: i.contentChannel = item.contentChannel @@ -1027,3 +1051,10 @@ def set_movie_title(item): if not item.contentTitle: item.contentTitle = re.sub("\[[^\]]+\]|\([^\)]+\)", "", item.title).strip() + + +def show_disclaimer(): + line1 = config.get_localized_string(70690) + line2 = config.get_localized_string(70691) + line3 = config.get_localized_string(70692) + platformtools.dialog_ok(config.get_localized_string(20000), line1, line2, line3) diff --git a/specials/setting.py b/specials/setting.py index 12ee2e3f..628bf4c7 100644 --- a/specials/setting.py +++ b/specials/setting.py @@ -798,7 +798,7 @@ def channel_status(item, dict_values): def restore_tools(item): - import videolibrary_service + import service from core import videolibrarytools import os @@ -832,7 +832,7 @@ def restore_tools(item): # filetools.rmdirtree(path) # ... y la volvemos a añadir - videolibrary_service.update(path, p_dialog, i, t, serie, 3) + service.update(path, p_dialog, i, t, serie, 3) p_dialog.close() # movies diff --git a/specials/videolibrary.py b/specials/videolibrary.py index 3098b07d..700e6797 100644 --- a/specials/videolibrary.py +++ b/specials/videolibrary.py @@ -667,8 +667,8 @@ def update_videolibrary(item): logger.info() # Actualizar las series activas sobreescribiendo - import videolibrary_service - videolibrary_service.check_for_update(overwrite=True) + import service + service.check_for_update(overwrite=True) # Eliminar las carpetas de peliculas que no contengan archivo strm for raiz, subcarpetas, ficheros in filetools.walk(videolibrarytools.MOVIES_PATH): @@ -692,8 +692,8 @@ def update_tvshow(item): p_dialog = platformtools.dialog_progress_bg(config.get_localized_string(20000), heading) p_dialog.update(0, heading, item.contentSerieName) - import videolibrary_service - if videolibrary_service.update(item.path, p_dialog, 1, 1, item, False) and config.is_xbmc() and config.get_setting("videolibrary_kodi"): + import service + if service.update(item.path, p_dialog, 1, 1, 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))