diff --git a/resources/language/English/strings.po b/resources/language/English/strings.po index 7d880c6b..6c4b4e4f 100644 --- a/resources/language/English/strings.po +++ b/resources/language/English/strings.po @@ -631,7 +631,7 @@ msgid "No links available that meets the requirements of the Black list. Try aga msgstr "" msgctxt "#60003" -msgid "" +msgid "Download unseen episodes" msgstr "" msgctxt "#60004" diff --git a/resources/language/Italian/strings.po b/resources/language/Italian/strings.po index 30a7d47a..46819fb4 100644 --- a/resources/language/Italian/strings.po +++ b/resources/language/Italian/strings.po @@ -630,8 +630,8 @@ 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 "" -msgstr "" +msgid "Download unseen episodes" +msgstr "Scarica episodi non visti" msgctxt "#60004" msgid "No connector for the server %s" diff --git a/specials/downloads.py b/specials/downloads.py index d9775c3d..3569e4bc 100644 --- a/specials/downloads.py +++ b/specials/downloads.py @@ -627,7 +627,7 @@ def download_from_server(item): progreso = platformtools.dialog_progress_bg(config.get_localized_string(30101), config.get_localized_string(70178) % item.server) try: - if item.contentChannel == 'community': + if item.contentChannel in ['community', 'videolibrary']: 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]) @@ -696,12 +696,13 @@ 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.downloadItemlist: logger.info('using cached servers') play_items = [Item().fromurl(i) for i in item.downloadItemlist] else: - if item.contentChannel == 'community': + if item.contentChannel in ['community', 'videolibrary']: 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]) @@ -755,7 +756,7 @@ def select_server(item): logger.info('using cached servers') play_items = [Item().fromurl(i) for i in item.downloadItemlist] else: - if item.contentChannel == 'community': + if item.contentChannel in ['community', 'videolibrary']: 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]) @@ -823,7 +824,7 @@ def get_episodes(item): episodes = [Item().fromurl(i) for i in item.downloadItemlist] else: # importamos el canal - if item.contentChannel == 'community': + if item.contentChannel in ['community', 'videolibrary']: 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]) @@ -868,7 +869,7 @@ def get_episodes(item): episode.downloadFilename = filetools.validate_path(filetools.join(item.downloadFilename, "%dx%0.2d - %s" % (episode.contentSeason, episode.contentEpisodeNumber, episode.contentTitle.strip()))) if season: - if scrapertools.find_single_match(episode.title, r'(\d+)x') == season_number: + if int(scrapertools.find_single_match(episode.title, r'(\d+)x')) == int(season_number): itemlist.append(episode) else: itemlist.append(episode) @@ -920,6 +921,8 @@ def save_download(item): def save_download_background(item): + logger.info() + # Menu contextual if item.from_action and item.from_channel: item.channel = item.from_channel @@ -930,19 +933,47 @@ def save_download_background(item): item.contentChannel = item.from_channel if item.from_channel else item.channel item.contentAction = item.from_action if item.from_action else item.action - if item.contentType in ["tvshow", "episode", "season"]: - if ('download' in item and item.channel != 'community') or (item.channel == 'community' and config.get_setting('show_seasons',item.channel) == False): - heading = config.get_localized_string(70594) # <- Enter the season number - item.dlseason = platformtools.dialog_numeric(0, heading, '') - if item.dlseason: - save_download_tvshow(item) - else: - save_download_tvshow(item) + if item.channel == 'videolibrary': + from specials import videolibrary - elif item.contentType == "movie": - save_download_movie(item) + parent = Item().fromurl(item.parent) + parent.contentChannel = 'videolibrary' + if item.downloadItemlist: # episode + parent.downloadItemlist = item.downloadItemlist + elif item.unseen: # unseen episodes + parent.downloadItemlist = [i.tourl() for i in videolibrary.get_episodes(parent) if parent.library_playcounts[scrapertools.get_season_and_episode(i.title)] == 0] + else: # tvshow or season + parent.downloadItemlist = [i.tourl() for i in videolibrary.get_episodes(parent)] + + if parent.contentType in ["tvshow", "episode", "season"]: + if not item.unseen and parent.contentSeason: # if no season, this is episode view, let's download entire serie + parent.dlseason = parent.contentSeason # this is season view, let's download season + save_download_tvshow(parent) + elif parent.contentType == "movie": + save_download_movie(parent) else: - save_download_video(item) + if item.contentType in ["tvshow", "episode", "season"]: + if ('download' in item and item.channel != 'community') or (item.channel == 'community' and config.get_setting('show_seasons',item.channel) == False): + heading = config.get_localized_string(70594) # <- Enter the season number + item.dlseason = platformtools.dialog_numeric(0, heading, '') + if item.dlseason: + save_download_tvshow(item) + else: + save_download_tvshow(item) + + elif item.contentType == "movie": + save_download_movie(item) + else: + save_download_video(item) + + +def save_download_videolibrary(item): + logger.info() + show_disclaimer() + item.contentChannel = 'videolibrary' + item.channel = "downloads" + item.action = "save_download_background" + xbmc.executebuiltin("RunPlugin(plugin://plugin.video.kod/?" + item.tourl() + ")") def save_download_video(item): diff --git a/specials/videolibrary.py b/specials/videolibrary.py index 4fa2ec4f..476ea7fc 100644 --- a/specials/videolibrary.py +++ b/specials/videolibrary.py @@ -10,7 +10,7 @@ if sys.version_info[0] >= 3: PY3 = True; unicode = str; unichr = chr; long = int import xbmc, os, traceback -from channelselector import get_thumb +from channelselector import get_thumb, thumb from core import filetools from core import scrapertools from core import videolibrarytools @@ -380,6 +380,7 @@ def get_seasons(item): new_item.infoLabels["playcount"] = 0 itemlist.insert(0, new_item) + add_download_items(item, itemlist) return itemlist @@ -441,7 +442,9 @@ def get_episodes(item): # logger.debug("epi:\n" + epi.tostring('\n')) itemlist.append(epi) - return sorted(itemlist, key=lambda it: (int(it.contentSeason), int(it.contentEpisodeNumber))) + itemlist = sorted(itemlist, key=lambda it: (int(it.contentSeason), int(it.contentEpisodeNumber))) + add_download_items(item, itemlist) + return itemlist def findvideos(item): @@ -449,7 +452,6 @@ def findvideos(item): logger.info() # logger.debug("item:\n" + item.tostring('\n')) videolibrarytools.check_renumber_options(item) - itemlist = [] list_canales = {} item_local = None @@ -462,8 +464,8 @@ def findvideos(item): return [] #content_title = [c for c in item.contentTitle.strip().lower() if c not in ":*?<>|\/"] - content_title = "".join(c for c in item.contentTitle.strip().lower() if c not in ":*?<>|\/") - + content_title = str(item.contentSeason) + 'x' + (str(item.contentEpisodeNumber) if item.contentEpisodeNumber > 9 \ + else '0' + str(item.contentEpisodeNumber)) if item.contentType == 'movie': item.strm_path = filetools.join(videolibrarytools.MOVIES_PATH, item.strm_path) path_dir = filetools.dirname(item.strm_path) @@ -621,6 +623,7 @@ def findvideos(item): from specials import nextep if nextep.check(item) and stack()[1][3] == 'run': nextep.videolibrary(item) + add_download_items(item, itemlist) return itemlist @@ -1080,3 +1083,34 @@ def check_tvshow_playcount(item, season): item.library_playcounts.update({item.title: playcount}) return item + + +def add_download_items(item, itemlist): + downloadItem = Item(channel='downloads', + from_channel=item.channel, + title=typo(config.get_localized_string(60355), "color kod bold"), + fulltitle=item.fulltitle, + show=item.fulltitle, + contentType=item.contentType, + contentSerieName=item.contentSerieName, + url=item.url, + action='save_download', + from_action="findvideos", + contentTitle=item.contentTitle, + path=item.path, + thumbnail=thumb(thumb='downloads.png'), + parent=item.tourl()) + if item.action == 'findvideos': + if item.contentType == 'episode': + downloadItem.title = typo(config.get_localized_string(60356), "color kod bold") + else: # film + downloadItem.title = typo(config.get_localized_string(60354), "color kod bold") + downloadItem.downloadItemlist = [i.tourl() for i in itemlist] + itemlist.append(downloadItem) + else: + if item.contentSeason: # season + downloadItem.title = typo(config.get_localized_string(60357), "color kod bold") + itemlist.append(downloadItem) + else: # tvshow + not seen + itemlist.append(downloadItem) + itemlist.append(downloadItem.clone(title=typo(config.get_localized_string(60003), "color kod bold"), unseen=True)) \ No newline at end of file