From 31038643089721e2faaafb1fb5cbbe3a795732ee Mon Sep 17 00:00:00 2001 From: Alhaziel01 Date: Mon, 5 Jul 2021 19:51:47 +0200 Subject: [PATCH] Fix --- channels/altadefinizioneclick.py | 67 ++++++++++++++++++++++++++++---- channels/seriehd.json | 2 +- core/tmdb.py | 9 +++-- core/videolibrarytools.py | 8 ++++ platformcode/launcher.py | 5 +++ platformcode/platformtools.py | 2 + 6 files changed, 81 insertions(+), 12 deletions(-) diff --git a/channels/altadefinizioneclick.py b/channels/altadefinizioneclick.py index 6956348c..83958e7d 100644 --- a/channels/altadefinizioneclick.py +++ b/channels/altadefinizioneclick.py @@ -17,6 +17,7 @@ """ +from platformcode.logger import debug from core import support from core.item import Item from platformcode import config @@ -42,28 +43,29 @@ def mainlist(item): ('Mi sento Fortunato',[ '', 'genres', 'lucky']), ('Sub-ITA', ['/sub-ita/', 'peliculas', 'sub']) ] + + tvshow = ['/serie-tv/'] + + search = '' return locals() @support.scrape def peliculas(item): - # debug=True + action = 'check' + patron = r'
\s*(?:(?P[^<]+)[^>]+>)?(?:(?P[^<>]+))?.+?href="(?P[^"]+)".+?src="(?P[^"]+)".+?

[^>]+>(?P.+?)[ ]?(?:|\[(?P<lang>[^\]]+)\])?</a>.*?(?:IMDB\:</strong>[ ](?P<rating>.+?)<|</div>)' - # patronBlock = r'h1>(?P<block>.*?)</section' if item.args == 'az': patron = r'<img style="[^"]+" src="(?P<thumb>[^"]+)"[^>]+>[^>]+>[^>]+>[^>]+>[^>]+><a href="(?P<url>[^"]+)" [^>]+>(?P<title>[^<\[]+)(?:\[(?P<lang>[^\]]+)\]\s*)?<'\ r'[^>]+>[^>]+>[^>]+>[^>]+>\s*(?P<year>\d{4})[^>]+>[^>]+>\s*(?P<quality>[^<]+).*?<span class="label">(?P<ratting>[^<]+)<' patronBlock ='' - # elif item.args == 'genres': - # patron = r'<div class="wrapperImage">[ ]?(?:<span class="hd">(?P<quality>[^<>]+))?.+?href="(?P<url>[^"]+)".+?src="(?P<thumb>[^"]+)"'\ - # r'.+?<h2 class="titleFilm(?:Mobile)?">[^>]+>(?P<title>.+?)[ ]?(?:|\[(?P<lang>[^\]]+)\])?(?:\((?P<year>\d{4})\))?</a>.*?(IMDB\:[ ](?P<rating>.+?))<' elif item.args == 'search': patronBlock = r'<section id="lastUpdate">(?P<block>.*?)(?:<div class="row ismobile">|<section)' - patron = r'<a href="(?P<url>[^"]+)">\s*<div class="wrapperImage">(?:\s*<span class="year">(?P<year>[^<]+)<\/span>)?(?:\s*<span class="hd">(?P<quality>[^<]+)<\/span>)?[^>]+>\s*<img[^s]+src="(?P<thumb>[^"]+)"[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>\s*(?P<rating>[^<]+)[^>]+>[^>]+>[^>]+>[^>]+>(?P<title>[^<]+)' + patron = r'<a href="(?P<url>[^"]+)">\s*<div class="wrapperImage">(?:\s*<span class="year">(?P<year>[^<]+)<\/span>)?(?:\s*<span class="hd">(?P<quality>[^<]+)<\/span>)?[^>]+>\s*<img[^s]+src="(?P<thumb>[^"]+)"(?:(?:[^>]+>){5}\s*(?P<rating>[^<]+))?(?:[^>]+>){4}(?P<title>[^<]+)' if not item.args: - patronBlock = r'ULTIMI INSERITI(?P<block>.*?)</section' + patronBlock = r'(?:ULTIMI INSERITI|Serie TV)(?P<block>.*?)</section' # nella pagina "CERCA", la voce "SUCCESSIVO" apre la maschera di inserimento dati patronNext = r'<a class="next page-numbers" href="([^"]+)">' @@ -72,7 +74,6 @@ def peliculas(item): @support.scrape def genres(item): - # debugBlock=True action = 'peliculas' patronMenu = r'<li><a href="(?P<url>[^"]+)">(?P<title>[^<]+)<' @@ -134,6 +135,56 @@ def newest(categoria): return itemlist + +def check(item): + def get_season(pageData, seas_url, season): + data = '' + episodes = support.match(pageData if pageData else seas_url, patronBlock=patron_episode, patron=patron_option).matches + for episode_url, episode in episodes: + # episode_url = support.urlparse.urljoin(item.url, episode_url) + # if '-' in episode: episode = episode.split('-')[0].zfill(2) + 'x' + episode.split('-')[1].zfill(2) + title = season + "x" + episode.zfill(2) + ' - ' + item.fulltitle + data += title + '|' + episode_url + '\n' + return data + + patron_season = '<div class="[^"]+" id="seasonsModal"[^>]+>(.*?)</ul>' + patron_episode = '<div class="[^"]+" id="episodesModal"[^>]+>(.*?)</ul>' + patron_option = r'<a href="([^"]+?)".*?>(?:Stagione |Episodio )([^<]+?)</a>' + + url = support.match(item, patron=r'<iframe id="iframeVid" width="[^"]+" height="[^"]+" src="([^"]+)" allowfullscreen').match + seasons = support.match(url, patronBlock=patron_season, patron=patron_option) + if not seasons.match: + item.contentType = 'tvshow' + return findvideos(item) + + data = '' + + import sys + if sys.version_info[0] >= 3: from concurrent import futures + else: from concurrent_py2 import futures + with futures.ThreadPoolExecutor() as executor: + thL = [] + for i, season in enumerate(seasons.matches): + thL.append(executor.submit(get_season, seasons.data if i == 0 else '', season[0], season[1])) + for res in futures.as_completed(thL): + if res.result(): + data += res.result() + item.data = data + return episodios(item) + +@support.scrape +def episodios(item): + data = item.data + + patron = r'(?P<season>\d+)x(?P<episode>\d+)\s*-\s*(?P<title>[^\|]+)\|(?P<url>[^ ]+)' + action = 'findvideos' + + def itemlistHook(itemlist): + itemlist.sort(key=lambda item: (item.infoLabels['season'], item.infoLabels['episode'])) + return itemlist + + return locals() + def findvideos(item): support.info('findvideos', item) return support.hdpass_get_servers(item) diff --git a/channels/seriehd.json b/channels/seriehd.json index eda29eb2..9c7ade33 100644 --- a/channels/seriehd.json +++ b/channels/seriehd.json @@ -1,7 +1,7 @@ { "id": "seriehd", "name": "SerieHD", - "active": true, + "active": false, "language": ["ita"], "thumbnail": "seriehd.png", "banner": "seriehd.png", diff --git a/core/tmdb.py b/core/tmdb.py index 0dacde84..577a6f85 100644 --- a/core/tmdb.py +++ b/core/tmdb.py @@ -391,15 +391,18 @@ def set_infoLabels_item(item, seekTmdb=True, search_language=def_lang): # do it by title if search_type == 'tv': # Serial search by title and filtering your results if necessary - otmdb = Tmdb(searched_text=scrapertools.unescape(item.infoLabels['tvshowtitle']), search_type=search_type, + searched_title = scrapertools.unescape(item.infoLabels['tvshowtitle']) + searched_title = searched_title.split('-')[0].strip() + otmdb = Tmdb(searched_text=searched_title, search_type=search_type, search_language=search_language, filtro=item.infoLabels.get('filtro', {}), year=item.infoLabels['year']) else: # Movie search by title ... # if item.infoLabels['year'] or item.infoLabels['filtro']: # ...and year or filter - searched_title = item.contentTitle if item.contentTitle else item.fulltitle - otmdb = Tmdb(searched_text=scrapertools.unescape(searched_title), search_type=search_type, search_language=search_language, + searched_title = scrapertools.unescape(item.contentTitle if item.contentTitle else item.fulltitle) + searched_title = searched_title.split('-')[0].strip() + otmdb = Tmdb(searched_text=searched_title, search_type=search_type, search_language=search_language, filtro=item.infoLabels.get('filtro', {}), year=item.infoLabels['year']) if otmdb is not None: if otmdb.get_id() and config.get_setting("tmdb_plus_info", default=False): diff --git a/core/videolibrarytools.py b/core/videolibrarytools.py index bbe46396..aa6724df 100644 --- a/core/videolibrarytools.py +++ b/core/videolibrarytools.py @@ -679,6 +679,14 @@ def save_episodes(item, episodelist, extra_info, host, local_files, silent=False return inserted, overwritten, failed +def add_to_videolibrary(item, channel): + itemlist = getattr(channel, item.from_action)(item) + if itemlist and itemlist[0].contentType == 'episode': + return add_tvshow(item, channel) + else: + return add_movie(item) + + def add_movie(item): """ Keep a movie at the movie library. The movie can be a link within a channel or a previously downloaded video. diff --git a/platformcode/launcher.py b/platformcode/launcher.py index 3a12529f..a581b74c 100644 --- a/platformcode/launcher.py +++ b/platformcode/launcher.py @@ -245,6 +245,11 @@ def run(item=None): elif item.action == "add_serie_to_library": from core import videolibrarytools videolibrarytools.add_tvshow(item, channel) + + # Special action for adding a serie to the library + elif item.action == "add_to_library": + from core import videolibrarytools + videolibrarytools.add_to_videolibrary(item, channel) # Special action for downloading all episodes from a serie elif item.action == "download_all_episodes": diff --git a/platformcode/platformtools.py b/platformcode/platformtools.py index 213eb192..21c2b260 100644 --- a/platformcode/platformtools.py +++ b/platformcode/platformtools.py @@ -686,6 +686,8 @@ def set_context_commands(item, item_url, parent_item, **kwargs): # Add Movie to Video Library elif item.action in ["detail", "findvideos"] and item.contentType == 'movie' and item.contentTitle: context_commands.append((config.get_localized_string(60353), "RunPlugin(%s?%s&%s)" % (sys.argv[0], item_url, 'action=add_movie_to_library&from_action=' + item.action))) + elif item.action in ['check'] and item.contentTitle: + context_commands.append((config.get_localized_string(30161), "RunPlugin(%s?%s&%s)" % (sys.argv[0], item_url, 'action=add_to_library&from_action=' + item.action))) if not item.local and item.channel not in ["downloads", "filmontv", "search"] and item.server != 'torrent' and parent_item.action != 'mainlist' and config.get_setting('downloadenabled'): # Download movie