Migliorie varie download e videolibrary_service rinominato in service

This commit is contained in:
marco
2020-03-29 17:13:14 +02:00
parent 1c3dc9e22e
commit 6a3dde4ba0
14 changed files with 164 additions and 136 deletions
+1 -1
View File
@@ -34,6 +34,6 @@
<forum>https://t.me/kodiondemand</forum> <forum>https://t.me/kodiondemand</forum>
<source>https://github.com/kodiondemand/addon</source> <source>https://github.com/kodiondemand/addon</source>
</extension> </extension>
<extension point="xbmc.service" library="videolibrary_service.py" start="login|startup"> <extension point="xbmc.service" library="service.py" start="login|startup">
</extension> </extension>
</addon> </addon>
+3 -3
View File
@@ -910,7 +910,7 @@ def download(itemlist, item, typography='', function_level=1, function=''):
contentSerieName=item.contentSerieName if item.contentSerieName else '' contentSerieName=item.contentSerieName if item.contentSerieName else ''
contentTitle=item.contentTitle if item.contentTitle 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': if itemlist and item.contentChannel != 'videolibrary':
itemlist.append( itemlist.append(
@@ -927,7 +927,7 @@ def download(itemlist, item, typography='', function_level=1, function=''):
contentTitle=contentTitle, contentTitle=contentTitle,
path=item.path, path=item.path,
thumbnail=thumb(thumb='downloads.png'), thumbnail=thumb(thumb='downloads.png'),
serverItemlist=serverItemlist downloadItemlist=downloadItemlist
)) ))
if from_action == 'episodios': if from_action == 'episodios':
itemlist.append( itemlist.append(
@@ -944,7 +944,7 @@ def download(itemlist, item, typography='', function_level=1, function=''):
contentTitle=contentTitle, contentTitle=contentTitle,
download='season', download='season',
thumbnail=thumb(thumb='downloads.png'), thumbnail=thumb(thumb='downloads.png'),
serverItemlist=serverItemlist downloadItemlist=downloadItemlist
)) ))
return itemlist return itemlist
+2 -2
View File
@@ -537,7 +537,7 @@ def save_tvshow(item, episodelist):
item_tvshow.library_filter_show = {item.channel: item.show} item_tvshow.library_filter_show = {item.channel: item.show}
if item.channel != "downloads": 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()) 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.append(season_episode)
nostrm_episodelist = sorted(set(nostrm_episodelist)) 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: if not silent:
# progress dialog # progress dialog
p_dialog = platformtools.dialog_progress(config.get_localized_string(20000), config.get_localized_string(60064)) p_dialog = platformtools.dialog_progress(config.get_localized_string(20000), config.get_localized_string(60064))
+6 -6
View File
@@ -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) # - patron5: expresión Regex aplicable a la url (opcional)
# - content_inc: contenido al que aplica esta entrada, o * (item.contentType o item.extra) # - 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' # - 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: # - 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 videolibrary_service la reescriba # - force: indica al canal que analize toda la serie y que service la reescriba
# - auto: indica a videolibrary_service que la reescriba # - auto: indica a service que la reescriba
# - no: no acción para videolibrary_service, solo redirige en visionado de videolibrary # - no: no acción para 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 # - 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 # - 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: # 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'), # ('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', 'newpct1', '', '', '', '', '', '', '', '', '*', '', 'del'),
# ('1', 'torrentrapid', 'torrentrapid', '', '', '', '', '', '', '', '*', '1 ó 2', 'emerg'), # ('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) # #logger.debug(item)
+1 -1
View File
@@ -37,7 +37,7 @@ def init():
Los pasos que sigue esta función, son los siguientes: 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 # Copia Custom code a las carpetas de Alfa desde la zona de Userdata
from platformcode import custom_code from platformcode import custom_code
custom_code.init() custom_code.init()
+1 -8
View File
@@ -1077,14 +1077,7 @@ def set_opcion(item, seleccion, opciones, video_urls):
# "Descargar" # "Descargar"
elif opciones[seleccion] == config.get_localized_string(30153): elif opciones[seleccion] == config.get_localized_string(30153):
from specials import downloads from specials import downloads
import xbmcaddon downloads.show_disclaimer()
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)
if item.contentType == "list" or item.contentType == "tvshow": if item.contentType == "list" or item.contentType == "tvshow":
item.contentType = "video" item.contentType = "video"
+2 -2
View File
@@ -49,7 +49,7 @@ def loadCommits(page=1):
return ret return ret
# ret -> aggiornato, necessita reload videolibrary_service # ret -> aggiornato, necessita reload service
def check(background=False): def check(background=False):
if not addon.getSetting('addon_update_enabled'): if not addon.getSetting('addon_update_enabled'):
return False, False return False, False
@@ -109,7 +109,7 @@ def check(background=False):
logger.info(file["filename"]) logger.info(file["filename"])
if 'resources/language' in file["filename"]: if 'resources/language' in file["filename"]:
poFilesChanged = True poFilesChanged = True
if 'videolibrary_service.py' in file["filename"]: if 'service.py' in file["filename"]:
serviceChanged = True serviceChanged = True
if file['status'] == 'modified' or file['status'] == 'added': if file['status'] == 'modified' or file['status'] == 'added':
if 'patch' in file: if 'patch' in file:
+3 -3
View File
@@ -623,7 +623,7 @@ msgid "No links available that meets the requirements of the Black list. Try aga
msgstr "" msgstr ""
msgctxt "#60003" msgctxt "#60003"
msgid "Connessione con %s" msgid ""
msgstr "" msgstr ""
msgctxt "#60004" msgctxt "#60004"
@@ -631,7 +631,7 @@ msgid "No connector for the server %s"
msgstr "" msgstr ""
msgctxt "#60005" msgctxt "#60005"
msgid "Connecting with %s" msgid ""
msgstr "" msgstr ""
msgctxt "#60006" msgctxt "#60006"
@@ -3527,7 +3527,7 @@ msgid "Getting episodes..."
msgstr "" msgstr ""
msgctxt "#70187" msgctxt "#70187"
msgid "connecting with %s..." msgid ""
msgstr "" msgstr ""
msgctxt "#70188" msgctxt "#70188"
+6 -6
View File
@@ -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" msgstr "Nessun collegamento disponibile che soddisfi i requisiti della Black list. Riprova modificando il filtro in 'Configurazione Server"
msgctxt "#60003" msgctxt "#60003"
msgid "Connessione con %s" msgid ""
msgstr "Connessione con %s" msgstr ""
msgctxt "#60004" msgctxt "#60004"
msgid "No connector for the server %s" msgid "No connector for the server %s"
msgstr "Non c'è nessun connettore per il server %s" msgstr "Non c'è nessun connettore per il server %s"
msgctxt "#60005" msgctxt "#60005"
msgid "Connecting with %s" msgid ""
msgstr "Connessione con %s" msgstr ""
msgctxt "#60006" msgctxt "#60006"
msgid "An error has occurred in %s" msgid "An error has occurred in %s"
@@ -3526,8 +3526,8 @@ msgid "Getting episodes..."
msgstr "Ottenimento episodi..." msgstr "Ottenimento episodi..."
msgctxt "#70187" msgctxt "#70187"
msgid "connecting with %s..." msgid ""
msgstr "connessione con %s..." msgstr ""
msgctxt "#70188" msgctxt "#70188"
msgid "Obtaining data for the TV show" msgid "Obtaining data for the TV show"
+4
View File
@@ -382,6 +382,10 @@ if __name__ == "__main__":
import xbmc import xbmc
import time 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: # modo adulto:
# sistema actual 0: Nunca, 1:Siempre, 2:Solo hasta que se reinicie Kodi # sistema actual 0: Nunca, 1:Siempre, 2:Solo hasta que se reinicie Kodi
# si es == 2 lo desactivamos. # si es == 2 lo desactivamos.
+2 -2
View File
@@ -90,8 +90,8 @@ def import_videolibrary(item):
platformtools.dialog_ok(config.get_localized_string(20000), config.get_localized_string(80008)) 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)): if platformtools.dialog_yesno(config.get_localized_string(20000), config.get_localized_string(80009)):
import videolibrary_service import service
videolibrary_service.check_for_update(overwrite=True) service.check_for_update(overwrite=True)
if config.is_xbmc() and config.get_setting("videolibrary_kodi"): if config.is_xbmc() and config.get_setting("videolibrary_kodi"):
xbmc_videolibrary.update() xbmc_videolibrary.update()
+127 -96
View File
@@ -96,13 +96,6 @@ def mainlist(item):
estados = [i.downloadStatus for i in itemlist] 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 # Si hay alguno completado
if 2 in estados: if 2 in estados:
itemlist.insert(0, Item(channel=item.channel, action="clean_ready", title=config.get_localized_string(70218), 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'), contentType=item.contentType, contentChannel=item.contentChannel, thumbnail=get_thumb('delete.png'),
contentSerieName=item.contentSerieName)) 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: 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)) 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): def clean_all(item):
logger.info() logger.info()
stop_all(item) stop_all()
for fichero in sorted(filetools.listdir(DOWNLOAD_LIST_PATH)): for fichero in sorted(filetools.listdir(DOWNLOAD_LIST_PATH)):
if fichero.endswith(".json"): if fichero.endswith(".json"):
@@ -188,14 +188,14 @@ def clean_all(item):
item.contentSerieName == download_item.contentSerieName and item.contentChannel == download_item.contentChannel): item.contentSerieName == download_item.contentSerieName and item.contentChannel == download_item.contentChannel):
filetools.remove(filetools.join(DOWNLOAD_LIST_PATH, fichero)) filetools.remove(filetools.join(DOWNLOAD_LIST_PATH, fichero))
xbmc.sleep(100) xbmc.sleep(100)
platformtools.itemlist_update(item, True) platformtools.itemlist_refresh()
def reload(item): def reload(item):
platformtools.itemlist_update(item, True) platformtools.itemlist_refresh()
def stop_all(item): def stop_all(item=None):
logger.info() logger.info()
for fichero in sorted(filetools.listdir(DOWNLOAD_LIST_PATH)): for fichero in sorted(filetools.listdir(DOWNLOAD_LIST_PATH)):
@@ -204,7 +204,8 @@ def stop_all(item):
if download_item.downloadStatus == 4: if download_item.downloadStatus == 4:
update_json(filetools.join(DOWNLOAD_LIST_PATH, fichero), {"downloadStatus": STATUS_CODES.stoped}) update_json(filetools.join(DOWNLOAD_LIST_PATH, fichero), {"downloadStatus": STATUS_CODES.stoped})
xbmc.sleep(100) xbmc.sleep(100)
platformtools.itemlist_update(item, True) if item:
platformtools.itemlist_refresh()
def clean_ready(item): def clean_ready(item):
@@ -217,7 +218,7 @@ def clean_ready(item):
if download_item.downloadStatus == STATUS_CODES.completed: if download_item.downloadStatus == STATUS_CODES.completed:
filetools.remove(filetools.join(DOWNLOAD_LIST_PATH, fichero)) filetools.remove(filetools.join(DOWNLOAD_LIST_PATH, fichero))
platformtools.itemlist_update(item, True) platformtools.itemlist_refresh()
def restart_error(item): def restart_error(item):
@@ -237,14 +238,14 @@ def restart_error(item):
update_json(item.path, update_json(item.path,
{"downloadStatus": STATUS_CODES.stoped, "downloadComplete": 0, "downloadProgress": 0}) {"downloadStatus": STATUS_CODES.stoped, "downloadComplete": 0, "downloadProgress": 0})
platformtools.itemlist_update(item, True) platformtools.itemlist_refresh()
def download_all(item): def download_all(item):
time.sleep(0.5) time.sleep(0.5)
item.action = "download_all_background" item.action = "download_all_background"
xbmc.executebuiltin("RunPlugin(plugin://plugin.video.kod/?" + item.tourl() + ")") xbmc.executebuiltin("RunPlugin(plugin://plugin.video.kod/?" + item.tourl() + ")")
platformtools.itemlist_update(item, True) platformtools.itemlist_refresh()
def download_all_background(item): def download_all_background(item):
@@ -333,10 +334,10 @@ def menu(item):
update_json(item.path, {"downloadStatus": STATUS_CODES.stoped}) update_json(item.path, {"downloadStatus": STATUS_CODES.stoped})
if opciones[seleccion] == op[5]: 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]: if opciones[seleccion] != op[5]:
platformtools.itemlist_update(item, True) platformtools.itemlist_refresh()
def move_to_libray(item): 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"))), part_size=2 ** (20 + int(config.get_setting("part_size", "downloads"))),
max_buffer=2 * int(config.get_setting("max_buffer", "downloads")), max_buffer=2 * int(config.get_setting("max_buffer", "downloads")),
json_path=item.path) 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)) d.start_dialog(config.get_localized_string(60332))
# Descarga detenida. Obtenemos el estado: # 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) 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: if status == STATUS_CODES.completed:
move_to_libray(item.clone(downloadFilename=file)) move_to_libray(item.clone(downloadFilename=file))
@@ -622,30 +626,32 @@ def download_from_server(item):
unsupported_servers = ["torrent"] unsupported_servers = ["torrent"]
progreso = platformtools.dialog_progress_bg(config.get_localized_string(30101), config.get_localized_string(70178) % item.server) progreso = platformtools.dialog_progress_bg(config.get_localized_string(30101), config.get_localized_string(70178) % item.server)
if item.contentChannel == 'community': try:
channel = __import__('specials.%s' % item.contentChannel, None, None, ['specials.%s' % item.contentChannel]) if item.contentChannel == 'community':
else: channel = __import__('specials.%s' % item.contentChannel, None, None, ['specials.%s' % item.contentChannel])
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)
else: else:
if len(itemlist) and isinstance(itemlist[0], Item): channel = __import__('channels.%s' % item.contentChannel, None, None, ['channels.%s' % item.contentChannel])
download_item = item.clone(**itemlist[0].__dict__) if hasattr(channel, "play") and not item.play_menu:
download_item.contentAction = download_item.action
download_item.infoLabels = item.infoLabels progreso.update(50, config.get_localized_string(70178) % item.server, config.get_localized_string(70180) % item.contentChannel)
item = download_item try:
elif len(itemlist) and isinstance(itemlist[0], list): itemlist = getattr(channel, "play")(item.clone(channel=item.contentChannel, action=item.contentAction))
item.video_urls = itemlist except:
if not item.server: item.server = "directo" logger.error("Error in the channel %s" % item.contentChannel)
else: else:
logger.info("There is nothing to reproduce") if len(itemlist) and isinstance(itemlist[0], Item):
return {"downloadStatus": STATUS_CODES.error} download_item = item.clone(**itemlist[0].__dict__)
progreso.close() 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" % ( logger.info("contentAction: %s | contentChannel: %s | server: %s | url: %s" % (
item.contentAction, item.contentChannel, item.server, item.url)) item.contentAction, item.contentChannel, item.server, item.url))
@@ -691,9 +697,9 @@ def download_from_best_server(item):
result = {"downloadStatus": STATUS_CODES.error} result = {"downloadStatus": STATUS_CODES.error}
progreso = platformtools.dialog_progress_bg(config.get_localized_string(30101), config.get_localized_string(70179)) progreso = platformtools.dialog_progress_bg(config.get_localized_string(30101), config.get_localized_string(70179))
try: try:
if item.serverItemlist: if item.downloadItemlist:
logger.info('using cached servers') 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: else:
if item.contentChannel == 'community': if item.contentChannel == 'community':
channel = __import__('specials.%s' % item.contentChannel, None, None, ['specials.%s' % item.contentChannel]) 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): def select_server(item):
if item.server:
return "Auto"
logger.info( logger.info(
"contentAction: %s | contentChannel: %s | url: %s" % (item.contentAction, item.contentChannel, item.url)) "contentAction: %s | contentChannel: %s | url: %s" % (item.contentAction, item.contentChannel, item.url))
progreso = platformtools.dialog_progress_bg(config.get_localized_string(30101), config.get_localized_string(70179))
progreso = platformtools.dialog_progress(config.get_localized_string(30101), config.get_localized_string(70179)) try:
if item.serverItemlist: if item.downloadItemlist:
logger.info('using cached servers') 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])
else: else:
channel = __import__('channels.%s' % item.contentChannel, None, None, ['channels.%s' % item.contentChannel]) if item.contentChannel == 'community':
progreso.update(50, config.get_localized_string(70184), config.get_localized_string(70180) % item.contentChannel) 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): if hasattr(channel, item.contentAction):
play_items = getattr(channel, item.contentAction)( play_items = getattr(channel, item.contentAction)(
item.clone(action=item.contentAction, channel=item.contentChannel)) item.clone(action=item.contentAction, channel=item.contentChannel))
else: else:
play_items = servertools.find_video_items(item.clone(action=item.contentAction, channel=item.contentChannel)) 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()] 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)) 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): for x, i in enumerate(play_items):
if not i.server and hasattr(channel, "play"): if not i.server and hasattr(channel, "play"):
play_items[x] = getattr(channel, "play")(i) play_items[x] = getattr(channel, "play")(i)
seleccion = platformtools.dialog_select(config.get_localized_string(70192), ["Auto"] + [s.title for s in play_items]) 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, { update_json(item.path, {
"downloadServer": {"url": play_items[seleccion - 1].url, "server": play_items[seleccion - 1].server}}) "downloadServer": {"url": play_items[seleccion - 1].url, "server": play_items[seleccion - 1].server}})
return play_items[seleccion - 1]
elif seleccion == 0: elif seleccion == 0:
update_json(item.path, {"downloadServer": {}}) update_json(item.path, {"downloadServer": {}})
return play_items[0]
# platformtools.itemlist_update(item, True) # platformtools.itemlist_refresh()
return play_items[seleccion - 1]
def start_download(item): def start_download(item):
@@ -809,13 +819,16 @@ def get_episodes(item):
# El item es uma serie o temporada # El item es uma serie o temporada
elif item.contentType in ["tvshow", "season"]: elif item.contentType in ["tvshow", "season"]:
# importamos el canal if item.downloadItemlist:
if item.contentChannel == 'community': episodes = [Item().fromurl(i) for i in item.downloadItemlist]
channel = __import__('specials.%s' % item.contentChannel, None, None, ["specials.%s" % item.contentChannel])
else: else:
channel = __import__('channels.%s' % item.contentChannel, None, None, ["channels.%s" % item.contentChannel]) # importamos el canal
# Obtenemos el listado de episodios if item.contentChannel == 'community':
episodes = getattr(channel, item.contentAction)(item) 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 = [] itemlist = []
@@ -896,6 +909,12 @@ def write_json(item):
def save_download(item): def save_download(item):
logger.info() 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" item.action = "save_download_background"
xbmc.executebuiltin("RunPlugin(plugin://plugin.video.kod/?" + item.tourl() + ")") xbmc.executebuiltin("RunPlugin(plugin://plugin.video.kod/?" + item.tourl() + ")")
@@ -969,10 +988,13 @@ def save_download_movie(item):
config.get_localized_string(30109)) config.get_localized_string(30109))
else: else:
play_item = select_server(item) play_item = select_server(item)
play_item = item.clone(**play_item.__dict__) if play_item == 'Auto':
play_item.contentAction = play_item.action start_download(item)
play_item.infoLabels = item.infoLabels else:
start_download(play_item) 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): def save_download_tvshow(item):
@@ -980,25 +1002,26 @@ def save_download_tvshow(item):
item.contentAction, item.contentChannel, item.contentType, item.contentSerieName)) item.contentAction, item.contentChannel, item.contentType, item.contentSerieName))
progreso = platformtools.dialog_progress_bg(config.get_localized_string(30101), config.get_localized_string(70188)) 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 item.downloadFilename = filetools.validate_path("%s [%s]" % (item.contentSerieName, item.infoLabels['IMDBNumber']))
scraper.find_and_set_infoLabels(item) if config.get_setting("lowerize_title", "videolibrary"):
if not item.contentSerieName: item.contentSerieName = item.fulltitle 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'])) episodes = get_episodes(item)
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) 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)),
for x, i in enumerate(episodes): "%dx%0.2d: %s" % (i.contentSeason, i.contentEpisodeNumber, i.contentTitle))
progreso.update(old_div(x * 100, len(episodes)), write_json(i)
"%dx%0.2d: %s" % (i.contentSeason, i.contentEpisodeNumber, i.contentTitle)) finally:
write_json(i) progreso.close()
progreso.close()
if not platformtools.dialog_yesno(config.get_localized_string(30101), config.get_localized_string(70189)): if not platformtools.dialog_yesno(config.get_localized_string(30101), config.get_localized_string(70189)):
platformtools.dialog_ok(config.get_localized_string(30101), platformtools.dialog_ok(config.get_localized_string(30101),
@@ -1007,12 +1030,13 @@ def save_download_tvshow(item):
else: else:
if len(episodes) == 1: if len(episodes) == 1:
play_item = select_server(item) play_item = select_server(item)
play_item = item.clone(**play_item.__dict__) if play_item == 'Auto':
play_item.contentAction = play_item.action start_download(item)
play_item.infoLabels = item.infoLabels else:
from core import support play_item = item.clone(**play_item.__dict__)
support.dbg() play_item.contentAction = play_item.action
start_download(play_item) play_item.infoLabels = item.infoLabels
start_download(play_item)
else: else:
for i in episodes: for i in episodes:
i.contentChannel = item.contentChannel i.contentChannel = item.contentChannel
@@ -1027,3 +1051,10 @@ def set_movie_title(item):
if not item.contentTitle: if not item.contentTitle:
item.contentTitle = re.sub("\[[^\]]+\]|\([^\)]+\)", "", item.title).strip() 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)
+2 -2
View File
@@ -798,7 +798,7 @@ def channel_status(item, dict_values):
def restore_tools(item): def restore_tools(item):
import videolibrary_service import service
from core import videolibrarytools from core import videolibrarytools
import os import os
@@ -832,7 +832,7 @@ def restore_tools(item):
# filetools.rmdirtree(path) # filetools.rmdirtree(path)
# ... y la volvemos a añadir # ... 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() p_dialog.close()
# movies # movies
+4 -4
View File
@@ -667,8 +667,8 @@ def update_videolibrary(item):
logger.info() logger.info()
# Actualizar las series activas sobreescribiendo # Actualizar las series activas sobreescribiendo
import videolibrary_service import service
videolibrary_service.check_for_update(overwrite=True) service.check_for_update(overwrite=True)
# Eliminar las carpetas de peliculas que no contengan archivo strm # Eliminar las carpetas de peliculas que no contengan archivo strm
for raiz, subcarpetas, ficheros in filetools.walk(videolibrarytools.MOVIES_PATH): 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 = platformtools.dialog_progress_bg(config.get_localized_string(20000), heading)
p_dialog.update(0, heading, item.contentSerieName) p_dialog.update(0, heading, item.contentSerieName)
import videolibrary_service import service
if videolibrary_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, 1, 1, item, False) and config.is_xbmc() and config.get_setting("videolibrary_kodi"):
from platformcode import xbmc_videolibrary from platformcode import xbmc_videolibrary
xbmc_videolibrary.update(folder=filetools.basename(item.path)) xbmc_videolibrary.update(folder=filetools.basename(item.path))