From 1c6eaf2c296b7fc9b20160372594593390c29c0f Mon Sep 17 00:00:00 2001 From: Alhaziel Date: Thu, 22 Aug 2019 20:37:59 +0200 Subject: [PATCH] Aggiunto Download come voce in lista --- core/support.py | 36 ++++++++++++++++++++++++++++++++++++ specials/autorenumber.py | 2 ++ specials/downloads.py | 4 ++-- 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/core/support.py b/core/support.py index 9d01bf85..8096ad0b 100644 --- a/core/support.py +++ b/core/support.py @@ -390,6 +390,8 @@ def scrape(func): if addVideolibrary and (item.infoLabels["title"] or item.fulltitle): # item.fulltitle = item.infoLabels["title"] videolibrary(itemlist, item, function=function) + if config.get_setting('downloadenabled') and (function == 'episodios' or function == 'finvideos'): + download(itemlist, item, function=function) if 'patronMenu' in args: itemlist = thumb(itemlist, genre=True) @@ -728,6 +730,39 @@ def match(item, patron='', patronBlock='', headers='', url='', post=''): return matches, block +def download(itemlist, item, typography='', function_level=1, function=''): + if item.contentType == 'movie': + fromaction = 'findvideos' + title = config.get_localized_string(60354) + else: + fromaction = 'episodios' + title = config.get_localized_string(60355) + + function = function if function else inspect.stack()[function_level][3] + + if not typography: typography = 'color kod bold' + + title = typo(title, typography) + contentSerieName=item.contentSerieName if item.contentSerieName else '' + contentTitle=item.contentTitle if item.contentTitle else '' + if item.contentType != 'episode': + itemlist.append( + Item(channel='downloads', + fromchannel=item.channel, + title=title, + fulltitle=item.fulltitle, + show=item.fulltitle, + contentType=item.contentType, + contentSerieName=contentSerieName, + url=item.url, + action='save_download', + fromaction=fromaction, + contentTitle=contentTitle + )) + + return itemlist + + def videolibrary(itemlist, item, typography='', function_level=1, function=''): # Simply add this function to add video library support # Function_level is useful if the function is called by another function. @@ -856,6 +891,7 @@ def controls(itemlist, item, AutoPlay=True, CheckLinks=True): autoplay.start(itemlist, item) if item.contentChannel != 'videolibrary': videolibrary(itemlist, item, function_level=3) + if get_setting('downloadenabled'): download(itemlist, item, function_level=3) return itemlist diff --git a/specials/autorenumber.py b/specials/autorenumber.py index b3ec8f3e..36f233c9 100644 --- a/specials/autorenumber.py +++ b/specials/autorenumber.py @@ -192,6 +192,8 @@ def config_item(item, itemlist=[], typography='', active=False): def renumber(itemlist, item='', typography=''): log() + if 'fromchannel' in item: + item.channel = item.fromchannel if item.fromchannel else item.channel # Seleziona la funzione Adatta, Menu Contestuale o Rinumerazione if item: settings_node = jsontools.get_node_from_file(item.channel, 'settings') diff --git a/specials/downloads.py b/specials/downloads.py index 3d379362..754cbe9b 100644 --- a/specials/downloads.py +++ b/specials/downloads.py @@ -803,8 +803,8 @@ def save_download(item): del item.from_action del item.from_channel - item.contentChannel = item.channel - item.contentAction = item.action + item.contentChannel = item.fromchannel if item.fromchannel else item.channel + item.contentAction = item.fromaction if item.fromaction else item.action if item.contentType in ["tvshow", "episode", "season"]: save_download_tvshow(item)