From 3004199d0dd2c6a4a2b7e863a35f65f7b9ca8c78 Mon Sep 17 00:00:00 2001 From: Alhaziel01 Date: Fri, 4 Sep 2020 17:41:44 +0200 Subject: [PATCH] Fix Ricerca Alternativa e altri micro fix --- core/support.py | 41 +- .../resource.language.en_gb/strings.po | 14 +- .../resource.language.it_it/strings.po | 26 +- specials/search.py | 4 +- specials/setting.py | 3 +- specials/tvmoviedb.py | 3227 ++++++++--------- 6 files changed, 1490 insertions(+), 1825 deletions(-) diff --git a/core/support.py b/core/support.py index f9e4baed..70696ef9 100755 --- a/core/support.py +++ b/core/support.py @@ -442,6 +442,7 @@ def scrape(func): data = re.sub("='([^']+)'", '="\\1"', page.data) data = data.replace('\n', ' ') data = data.replace('\t', ' ') + data = data.replace(' ', ' ') data = re.sub(r'>\s+<', '> <', data) # replace all ' with " and eliminate newline, so we don't need to worry about scrapingTime = time() @@ -928,6 +929,7 @@ def match(item_url_string, **args): data = re.sub("='([^']+)'", '="\\1"', data) data = data.replace('\n', ' ') data = data.replace('\t', ' ') + data = data.replace(' ', ' ') data = re.sub(r'>\s+<', '><', data) data = re.sub(r'([a-zA-Z])"([a-zA-Z])', "\1'\2", data) @@ -1358,42 +1360,48 @@ def thumb(item_itemlist_string=None, genre=False, live=False): 'tvshow':['serie','tv','episodi','episodio','fiction', 'show'], 'documentary':['documentari','documentario', 'documentary', 'documentaristico'], 'teenager':['ragazzi','teenager', 'teen'], - 'learning':['learning'], + 'learning':['learning', 'school', 'scuola'], 'all':['tutti', 'all'], - 'news':['novità', "novita'", 'aggiornamenti', 'nuovi', 'nuove', 'new', 'newest', 'news', 'ultimi'], + 'news':['novità', "novita'", 'aggiornamenti', 'nuovi', 'nuove', 'new', 'newest', 'news', 'ultimi', 'notizie'], 'now_playing':['cinema', 'in sala'], 'anime':['anime'], 'genres':['genere', 'generi', 'categorie', 'categoria', 'category'], 'animation': ['animazione', 'cartoni', 'cartoon', 'animation'], - 'action':['azione', 'arti marziali', 'action'], + 'action':['azione', 'marziali', 'action', 'martial'], 'adventure': ['avventura', 'adventure'], - 'biographical':['biografico', 'biographical'], - 'comedy':['comico', 'commedia', 'demenziale', 'comedy', 'brillante'], + 'biographical':['biografico', 'biographical', 'biografia'], + 'comedy':['comico', 'commedia', 'demenziale', 'comedy', 'brillante', 'demential', 'parody'], 'adult':['erotico', 'hentai', 'harem', 'ecchi', 'adult'], 'drama':['drammatico', 'drama', 'dramma'], - 'syfy':['fantascienza', 'science fiction', 'syfy', 'sci'], + 'syfy':['fantascienza', 'science fiction', 'syfy', 'sci-fi'], 'fantasy':['fantasy', 'magia', 'magic', 'fantastico'], - 'crime':['gangster','poliziesco', 'crime', 'crimine'], + 'crime':['gangster','poliziesco', 'crime', 'crimine', 'police'], 'grotesque':['grottesco', 'grotesque'], - 'war':['guerra', 'war'], + 'war':['guerra', 'war', 'military'], 'children':['bambini', 'kids'], - 'horror':['horror'], + 'horror':['horror', 'orrore'], 'music':['musical', 'musica', 'music', 'musicale'], 'mistery':['mistero', 'giallo', 'mystery'], 'noir':['noir'], - 'popular' : ['popolari','popolare', 'più visti'], + 'popular':['popolari','popolare', 'più visti', 'raccomandati', 'raccomandazioni' 'recommendations'], 'thriller':['thriller'], 'top_rated' : ['fortunato', 'votati', 'lucky', 'top'], 'on_the_air' : ['corso', 'onda', 'diretta', 'dirette'], 'western':['western'], 'vos':['sub','sub-ita'], 'romance':['romantico','sentimentale', 'romance', 'soap'], - 'family':['famiglia','famiglie', 'family', 'historical'], - 'historical':['storico', 'history', 'storia'], + 'family':['famiglia','famiglie', 'family'], + 'historical':['storico', 'history', 'storia', 'historical'], 'az':['lettera','lista','alfabetico','a-z', 'alphabetical'], 'year':['anno', 'anni', 'year'], 'update':['replay', 'update'], 'videolibrary':['teche'], + 'info':['info','information','informazioni'], + 'star':['star', 'personaggi', 'interpreti', 'stars', 'characters', 'performers', 'staff', 'actors', 'attori'], + 'winter':['inverno', 'winter'], + 'spring':['primavera', 'spring'], + 'summer':['estate', 'summer'], + 'autumn':['autunno', 'autumn'], 'autoplay':[config.get_localized_string(60071)] } @@ -1409,18 +1417,19 @@ def thumb(item_itemlist_string=None, genre=False, live=False): '_tvshow':['serie','tv', 'fiction']} def autoselect_thumb(item, genre): + log('SPLIT',re.split(r'\.|\{|\}|\[|\]|\(|\)|/| ',item.title.lower())) if genre == False: for thumb, titles in icon_dict.items(): - if any(word in re.split(r'\.|\{|\}|\[|\]|\(|\)| ',item.title.lower()) for word in search): + if any(word in re.split(r'\.|\{|\}|\[|\]|\(|\)|/| ',item.title.lower()) for word in search): thumb = 'search' for suffix, titles in search_suffix.items(): - if any(word in re.split(r'\.|\{|\}|\[|\]|\(|\)| ',item.title.lower()) for word in titles ): + if any(word in re.split(r'\.|\{|\}|\[|\]|\(|\)|/| ',item.title.lower()) for word in titles ): thumb = thumb + suffix item.thumbnail = get_thumb(thumb + '.png') elif any(word in re.split(r'\.|\{|\}|\[|\]|\(|\)| ',item.title.lower()) for word in titles ): if thumb == 'movie' or thumb == 'tvshow': for suffix, titles in suffix_dict.items(): - if any(word in re.split(r'\.|\{|\}|\[|\]|\(|\)| ',item.title.lower()) for word in titles ): + if any(word in re.split(r'\.|\{|\}|\[|\]|\(|\)|/| ',item.title.lower()) for word in titles ): thumb = thumb + suffix item.thumbnail = get_thumb(thumb + '.png') else: item.thumbnail = get_thumb(thumb + '.png') @@ -1429,7 +1438,7 @@ def thumb(item_itemlist_string=None, genre=False, live=False): else: for thumb, titles in icon_dict.items(): - if any(word in re.split(r'\.|\{|\}|\[|\]|\(|\)| ',item.title.lower()) for word in titles ): + if any(word in re.split(r'\.|\{|\}|\[|\]|\(|\)|/| ',item.title.lower()) for word in titles ): item.thumbnail = get_thumb(thumb + '.png') else: thumb = item.thumbnail diff --git a/resources/language/resource.language.en_gb/strings.po b/resources/language/resource.language.en_gb/strings.po index fdd34306..39393442 100644 --- a/resources/language/resource.language.en_gb/strings.po +++ b/resources/language/resource.language.en_gb/strings.po @@ -2921,7 +2921,7 @@ msgid "Search similar" msgstr "" msgctxt "#70021" -msgid "Search in TMDB" +msgid "Search %s in %s" msgstr "" msgctxt "#70022" @@ -4209,11 +4209,11 @@ msgid "Search in KoD: %s" msgstr "" msgctxt "#70351" -msgid " Search alternative title: %s" +msgid "Search alternative title: %s" msgstr "" msgctxt "#70352" -msgid " Search title in english: %s" +msgid "Search title in english: %s" msgstr "" msgctxt "#70353" @@ -4332,10 +4332,6 @@ msgctxt "#70381" msgid "Dropped" msgstr "" -msgctxt "#70381" -msgid "Myanimelist username and/or password blank" -msgstr "" - msgctxt "#70382" msgid "Currently watching" msgstr "" @@ -4380,6 +4376,10 @@ msgctxt "#70392" msgid "Rate with a %s" msgstr "" +msgctxt "#70393" +msgid "Myanimelist username and/or password blank" +msgstr "" + msgctxt "#70394" msgid "Action" msgstr "" diff --git a/resources/language/resource.language.it_it/strings.po b/resources/language/resource.language.it_it/strings.po index bf53e8c4..d0f15ec4 100644 --- a/resources/language/resource.language.it_it/strings.po +++ b/resources/language/resource.language.it_it/strings.po @@ -2920,8 +2920,8 @@ msgid "Search similar" msgstr "Cerca simili" msgctxt "#70021" -msgid "Search in TMDB" -msgstr "Cerca in TMDB" +msgid "Search %s in %s" +msgstr "Cerca %s in %s" msgctxt "#70022" msgid " - Movies" @@ -4048,7 +4048,7 @@ msgid "TV shows by Genre" msgstr "Serie TV per Genere" msgctxt "#70311" -msgid "TV Shows most popular" +msgid "TV shows most popular" msgstr "Serie TV più popolari" msgctxt "#70312" @@ -4208,12 +4208,12 @@ msgid "Search in KoD: %s" msgstr "Cerca in KoD: %s" msgctxt "#70351" -msgid " Search alternative title: %s" -msgstr " Cerca titolo alternativo: %s" +msgid "Search alternative title: %s" +msgstr "Cerca titolo alternativo: %s" msgctxt "#70352" -msgid " Search title in english: %s" -msgstr " Cerca titolo in inglese: %s" +msgid "Search title in english: %s" +msgstr "Cerca titolo in inglese: %s" msgctxt "#70353" msgid "Vídeos (Episodes, Trailers...)" @@ -4301,11 +4301,11 @@ msgstr "Anime dove appare:" msgctxt "#70374" msgid "Give voice to/in:" -msgstr "Dai voce a/in:" +msgstr "Da voce a/in:" msgctxt "#70375" msgid "Staff in animes:" -msgstr "Staff in anime:" +msgstr "Staff negli anime:" msgctxt "#70376" msgid "Info in AniDB %s" @@ -4331,10 +4331,6 @@ msgctxt "#70381" msgid "Dropped" msgstr "Abbandonata" -msgctxt "#70381" -msgid "Myanimelist username and/or password blank" -msgstr "Username e/o password di Myanimelist vuoti" - msgctxt "#70382" msgid "Currently watching" msgstr "In visione attualmente" @@ -4379,6 +4375,10 @@ msgctxt "#70392" msgid "Rate with a %s" msgstr "Dai un punteggio con un %s" +msgctxt "#70393" +msgid "Myanimelist username and/or password blank" +msgstr "Username e/o password di Myanimelist vuoti" + msgctxt "#70394" msgid "Action" msgstr "Azione" diff --git a/specials/search.py b/specials/search.py index e4d03852..a19f41c9 100644 --- a/specials/search.py +++ b/specials/search.py @@ -39,6 +39,7 @@ def mainlist(item): Item(channel=item.channel, title=config.get_localized_string(70741) % config.get_localized_string(70314), action='new_search', page=1, mode='person', thumbnail=get_thumb("search_star.png")), Item(channel=item.channel, title=config.get_localized_string(59995), action='saved_search', thumbnail=get_thumb('search.png')), Item(channel=item.channel, title=config.get_localized_string(60420), action='sub_menu', thumbnail=get_thumb('search.png')), + Item(channel="tvmoviedb", title=config.get_localized_string(70274), action="mainlist", thumbnail=get_thumb("search.png")), Item(channel=item.channel, title=typo(config.get_localized_string(59994), 'color kod bold'), action='setting_channel_new', thumbnail=get_thumb('setting_0.png')), Item(channel='shortcuts', title=typo(config.get_localized_string(70286), 'color kod bold'), action='SettingOnPosition', category=5, setting=1, thumbnail=get_thumb('setting_0.png'))] @@ -58,8 +59,7 @@ def sub_menu(item): Item(channel=item.channel, action='years_menu', title=config.get_localized_string(70743), mode='tvshow', thumbnail=get_thumb("tvshow_year.png")), Item(channel=item.channel, action='discover_list', title=config.get_localized_string(70311), search_type='list', list_type='tv/popular', mode='tvshow', thumbnail=get_thumb("popular.png")), Item(channel=item.channel, action='discover_list', title=config.get_localized_string(70312), search_type='list', list_type='tv/on_the_air', mode='tvshow', thumbnail=get_thumb("tvshow_on_the_air.png")), - Item(channel=item.channel, action='discover_list', title=config.get_localized_string(70313), search_type='list', list_type='tv/top_rated', mode='tvshow', thumbnail=get_thumb("tvshow_top.png")), - Item(channel="tvmoviedb", action="mainlist", title=config.get_localized_string(70274), thumbnail=get_thumb("search.png"))] + Item(channel=item.channel, action='discover_list', title=config.get_localized_string(70313), search_type='list', list_type='tv/top_rated', mode='tvshow', thumbnail=get_thumb("tvshow_top.png")),] itemlist = set_context(itemlist) return itemlist diff --git a/specials/setting.py b/specials/setting.py index 9efc839a..8926e254 100644 --- a/specials/setting.py +++ b/specials/setting.py @@ -405,7 +405,8 @@ def cb_servers_favorites(server_names, dict_values): progreso.update(old_div((i * 100), n), config.get_localized_string(60559) % server_parameters['name']) i += 1 - c = 2 + c = 1 + logger.log(dict_favorites) favorites_servers_list = [] while c in dict_favorites: favorites_servers_list.append(dict_favorites[c]) diff --git a/specials/tvmoviedb.py b/specials/tvmoviedb.py index 78ccda67..02e1b14c 100644 --- a/specials/tvmoviedb.py +++ b/specials/tvmoviedb.py @@ -1,68 +1,51 @@ # -*- coding: utf-8 -*- - -import re, urllib, xbmcaddon -from base64 import b64decode as bdec - -from channelselector import get_thumb -from core import filetools, httptools, jsontools, scrapertools, trakt_tools -from core.item import Item -from core.support import typo +import re +from core import support, filetools, jsontools, trakt_tools from core.tmdb import Tmdb -from platformcode import config, logger, platformtools +from core.scrapertools import htmlclean, decodeHtmlentities +from core.support import thumb, typo, match, Item, dbg +from platformcode import config, platformtools +from platformcode.logger import log, error info_language = ["de", "en", "es", "fr", "it", "pt"] # from videolibrary.json def_lang = info_language[config.get_setting("info_language", "videolibrary")] langs = ['auto', 'de', 'fr', 'pt', 'it', 'es-MX', 'ca', 'en', 'es'] langt = langs[config.get_setting('tmdb', "tvmoviedb")] -if langt == 'auto': - langt = def_lang +if langt == 'auto': langt = def_lang langt_alt = langs[config.get_setting('tmdb_alternativo', "tvmoviedb")] langs = ['auto', 'co', 'cl', 'ar', 'mx', 'en', 'es'] langf = langs[config.get_setting('filmaff', "tvmoviedb")] -if langf == 'auto': - langf = def_lang +if langf == 'auto': langf = 'en' langs = ['auto', 'de-de', 'fr-fr', 'pt-pt', 'it-it', 'es-MX', 'ca-es', 'en', 'es'] langi = langs[config.get_setting('imdb', "tvmoviedb")] -if langi == 'auto': - langi = def_lang +if langi == 'auto': langi = def_lang adult_mal = config.get_setting('adult_mal', "tvmoviedb") mal_ck = "MzE1MDQ2cGQ5N2llYTY4Z2xwbGVzZjFzbTY=" images_predef = "https://raw.githubusercontent.com/master-1970/resources/master/images/genres/" default_fan = filetools.join(config.get_runtime_path(), "fanart.jpg") -logger.log('FANART= '+default_fan) def mainlist(item): - logger.log() - itemlist = [] - # TMDB - itemlist.append(item.clone(title=typo(config.get_localized_string(70021), 'bold'), action="")) - itemlist.append(item.clone(title=config.get_localized_string(70022), action="tmdb", extra="movie", - thumbnail=get_thumb('search_movie.png'))) - itemlist.append(item.clone(title=config.get_localized_string(70023), action="tmdb", extra="tv", - thumbnail=get_thumb('search_tvshow.png'))) - # Filmaffinity - itemlist.append(item.clone(title=typo(config.get_localized_string(70024), 'bold'), action="")) - itemlist.append(item.clone(title=config.get_localized_string(70022), action="filmaf", extra="movie", - thumbnail=get_thumb('search_movie.png'))) - itemlist.append(item.clone(title=config.get_localized_string(70023), action="filmaf", extra="tv", - thumbnail=get_thumb('search_tvshow.png'))) - # IMDB - itemlist.append(item.clone(title=typo(config.get_localized_string(70025), 'bold'), action="")) - itemlist.append(item.clone(title=config.get_localized_string(70022), action="imdb", extra="movie", - url='&title_type=feature,tv_movie', - thumbnail=get_thumb('search_movie.png'))) - itemlist.append(item.clone(title=config.get_localized_string(70023), action="imdb", extra="tv", - url='&title_type=tv_series,tv_special,mini_series', - thumbnail=get_thumb('search_tvshow.png'))) - itemlist.append( - item.clone(title=typo(config.get_localized_string(70415), 'bold'), action="trakt", thumbnail="http://i.imgur.com/5sQjjuk.png")) - itemlist.append( - item.clone(title=typo(config.get_localized_string(70026), 'bold'), action="mal", thumbnail="http://i.imgur.com/RhsYWmd.png",)) - itemlist.append( - item.clone(title=typo(config.get_localized_string(70027), 'color kod'), action="configuracion", folder=False)) + log() + itemlist = [ + # TMDB + # item.clone(title=typo(config.get_localized_string(70021), 'bold'), action=""), + item.clone(title=typo(config.get_localized_string(70021) % (config.get_localized_string(30122), 'TMDB'), 'bold'), action="tmdb", args="movie", thumbnail=thumb('search_movie')), + item.clone(title=typo(config.get_localized_string(70021) % (config.get_localized_string(30123), 'TMDB'), 'bold'), action="tmdb", args="tv", thumbnail=thumb('search_tvshow')), + # Filmaffinity + # itemlist.append(item.clone(title=typo(config.get_localized_string(70024), 'bold'), action="")) + # itemlist.append(item.clone(title=config.get_localized_string(70022), action="filmaf", args="movie", thumbnail=thumb('search_movie'))) + # itemlist.append(item.clone(title=config.get_localized_string(70023), action="filmaf", args="tv", thumbnail=thumb('search_tvshow'))) + # IMDB + # item.clone(title=typo(config.get_localized_string(70025), 'bold'), action=""), + item.clone(title=typo(config.get_localized_string(70021) % (config.get_localized_string(30122), 'IMDB'), 'bold'), action="imdb", args="movie", url='&title_type=feature,tv_movie', thumbnail=thumb('search_movie')), + item.clone(title=typo(config.get_localized_string(70021) % (config.get_localized_string(30123), 'IMDB'), 'bold'), action="imdb", args="tv", url='&title_type=tv_series,tv_special,mini_series', thumbnail=thumb('search_tvshow')), + item.clone(title=typo(config.get_localized_string(70415), 'bold'), action="trakt", thumbnail="http://i.imgur.com/5sQjjuk.png"), + item.clone(title=typo(config.get_localized_string(70026), 'bold'), action="mal", thumbnail="http://i.imgur.com/RhsYWmd.png"), + item.clone(title=typo(config.get_localized_string(70027), 'color kod'), action="configuracion", folder=False) + ] return itemlist @@ -72,7 +55,7 @@ def configuracion(item): return ret def search_star(item): - logger.log() + log() itemlist = [] item.type='movie' @@ -82,24 +65,24 @@ def search_star(item): return itemlist def search_(item): - texto = platformtools.dialog_input(heading=item.title) - if texto: + text = platformtools.dialog_input(heading=item.title) + if text: if "imdb" in item.url: - item.url += texto.replace(" ", "+") - item.action = "listado_imdb" - return listado_imdb(item) - if "filmaffinity" in item.url: - item.url += texto.replace(" ", "+") - item.action = "listado_fa" - return listado_fa(item) + item.url = item.url.format(text.replace(" ", "+")) + item.action = "list_imdb" + return list_imdb(item) + # if "filmaffinity" in item.url: + # item.url += text.replace(" ", "+") + # item.action = "list_fa" + # return list_fa(item) if "myanimelist" in item.url: - item.url += texto.replace(" ", "%20") + item.url += text.replace(" ", "%20") item.url += "&type=0&score=0&status=0&p=0&r=0&sm=0&sd=0&sy=0&em=0&ed=0&ey=0&c[0]=a&c[1]=b&c[2]=c&c[3]=d&c[4]=f&gx=0" - item.action = "busqueda_mal" - return busqueda_mal(item) + item.action = "searching_mal" + return searching_mal(item) - item.search['query'] = texto - item.action = "listado_tmdb" + item.search['query'] = text + item.action = "list_tmdb" if item.star == True: types = ['movie','tv'] @@ -107,14 +90,14 @@ def search_(item): for type in types: item.contentType = type item.search['type']=type - itemlist.extend(listado_tmdb(item)) + itemlist.extend(list_tmdb(item)) return itemlist else: - return listado_tmdb(item) + return list_tmdb(item) -def busqueda(item): - logger.log() +def searcing(item): + log() new_item = Item(title=item.contentTitle, text=item.contentTitle.replace("+", " "), mode=item.contentType, infoLabels=item.infoLabels) @@ -123,173 +106,130 @@ def busqueda(item): def tmdb(item): - item.contentType = item.extra.replace("tv", "tvshow") + item.contentType = item.args.replace("tv", "tvshow") itemlist = [] - itemlist.append(item.clone(title=config.get_localized_string(70028), action="listado_tmdb", - search={'url': item.extra + "/popular", 'language': langt, 'page': 1})) - itemlist.append(item.clone(title=config.get_localized_string(70029), action="listado_tmdb", - search={'url': item.extra + "/top_rated", 'language': langt, 'page': 1})) - if item.extra == "movie": - itemlist.append(item.clone(title=config.get_localized_string(70030), action="listado_tmdb", - search={'url': item.extra + "/now_playing", 'language': langt, 'page': 1})) - else: - itemlist.append(item.clone(title=config.get_localized_string(70031), action="listado_tmdb", - search={'url': item.extra + "/on_the_air", 'language': langt, 'page': 1})) + + itemlist.append(item.clone(title=config.get_localized_string(70028), action="list_tmdb", search={'url': item.args + "/popular", 'language': langt, 'page': 1})) + itemlist.append(item.clone(title=config.get_localized_string(70029), action="list_tmdb", search={'url': item.args + "/top_rated", 'language': langt, 'page': 1})) + + if item.args == "movie": itemlist.append(item.clone(title=config.get_localized_string(70030), action="list_tmdb", search={'url': item.args + "/now_playing", 'language': langt, 'page': 1})) + else: itemlist.append(item.clone(title=config.get_localized_string(70031), action="list_tmdb", search={'url': item.args + "/on_the_air", 'language': langt, 'page': 1})) + itemlist.append(item.clone(title=config.get_localized_string(70032), action="indices_tmdb")) itemlist.append(item.clone(title=config.get_localized_string(70042), action="indices_tmdb")) - if item.extra == "movie": - itemlist.append(item.clone(title=config.get_localized_string(70033), action="listado_tmdb", - search={'url': 'person/popular', 'language': langt, 'page': 1})) - itemlist.append(item.clone(title=config.get_localized_string(70034), action="listado_tmdb", - search={'url': item.extra + "/upcoming", 'language': langt, 'page': 1})) + if item.args == "movie": + itemlist.append(item.clone(title=config.get_localized_string(70033), action="list_tmdb", search={'url': 'person/popular', 'language': langt, 'page': 1})) + itemlist.append(item.clone(title=config.get_localized_string(70034), action="list_tmdb", search={'url': item.args + "/upcoming", 'language': langt, 'page': 1})) if config.get_platform() != "plex": title = item.contentType.replace("movie", config.get_localized_string(70283)).replace("tvshow", "serie") - itemlist.append(item.clone(title=config.get_localized_string(70035) % title, action="search_", - search={'url': 'search/%s' % item.extra, 'language': langt, 'page': 1})) + itemlist.append(item.clone(title=config.get_localized_string(70035) % title, action="search_", search={'url': 'search/%s' % item.args, 'language': langt, 'page': 1})) - itemlist.append(item.clone(title=config.get_localized_string(70036), action="search_", - search={'url': 'search/person', 'language': langt, 'page': 1})) - if item.extra == "movie": - itemlist.append(item.clone(title=config.get_localized_string(70037), action="search_", - search={'url': "search/person", 'language': langt, 'page': 1}, crew=True)) + itemlist.append(item.clone(title=config.get_localized_string(70036), action="search_", search={'url': 'search/person', 'language': langt, 'page': 1})) + if item.args == "movie": itemlist.append(item.clone(title=config.get_localized_string(70037), action="search_", search={'url': "search/person", 'language': langt, 'page': 1}, crew=True)) - itemlist.append(item.clone(title=config.get_localized_string(70038), action="filtro", )) - itemlist.append(item.clone(title=config.get_localized_string(70039), action="filtro", )) + itemlist.append(item.clone(title=config.get_localized_string(70038), action="filter", )) + itemlist.append(item.clone(title=config.get_localized_string(70039), action="filter", )) - return itemlist + return thumb(itemlist) def imdb(item): - item.contentType = item.extra.replace("tv", "tvshow") + item.contentType = item.args.replace("tv", "tvshow") itemlist = [] - itemlist.append(item.clone(title=config.get_localized_string(70028), action="listado_imdb")) - itemlist.append(item.clone(title=config.get_localized_string(70029), action="listado_imdb", - url=item.url + "&num_votes=25000,&sort=user_rating,desc")) - if item.extra == "movie": - itemlist.append(item.clone(title=config.get_localized_string(70030), action="listado_imdb", - url="http://www.imdb.com/showtimes/location?ref_=inth_ov_sh_sm")) + itemlist.append(item.clone(title=config.get_localized_string(70028), action="list_imdb")) + itemlist.append(item.clone(title=config.get_localized_string(70029), action="list_imdb", url=item.url + "&num_votes=25000,&sort=user_rating,desc")) + if item.args == "movie": + itemlist.append(item.clone(title=config.get_localized_string(70030), action="list_imdb", url="http://www.imdb.com/showtimes/location?ref_=inth_ov_sh_sm")) itemlist.append(item.clone(title=config.get_localized_string(70032), action="indices_imdb")) itemlist.append(item.clone(title=config.get_localized_string(70042), action="indices_imdb")) - if item.extra == "movie": - itemlist.append(item.clone(title=config.get_localized_string(70033), action="listado_imdb", - url="http://www.imdb.com/search/name?gender=male,female&ref_=nv_cel_m_3")) - - itemlist.append(item.clone(title=config.get_localized_string(70034), action="listado_imdb", - url="http://www.imdb.com/movies-coming-soon/?ref_=shlc_cs")) + if item.args == "movie": + itemlist.append(item.clone(title=config.get_localized_string(70033), action="list_imdb", url="http://www.imdb.com/search/name?gender=male,female&ref_=nv_cel_m_3")) + itemlist.append(item.clone(title=config.get_localized_string(70034), action="list_imdb", url="http://www.imdb.com/movies-coming-soon/?ref_=shlc_cs")) if config.get_platform() != "plex": - title = item.contentType.replace("movie", config.get_localized_string(70283)).replace("tvshow", "serie") - itemlist.append(item.clone(title=config.get_localized_string(70035) % title, action="search_", - url="http://www.imdb.com/search/title?title=" + item.url)) + itemlist.append(item.clone(title=config.get_localized_string(30980), action="search_", url="http://www.imdb.com/search/title?title={}" + item.url)) + itemlist.append(item.clone(title=config.get_localized_string(70036), action="search_", url="http://www.imdb.com/search/name?name={}")) - itemlist.append(item.clone(title=config.get_localized_string(70036), action="search_", - url="http://www.imdb.com/search/name?name=")) + itemlist.append(item.clone(title=config.get_localized_string(70038), action="filter_imdb", )) - itemlist.append(item.clone(title=config.get_localized_string(70038), action="filtro_imdb", )) - - return itemlist + return thumb(itemlist) -def filmaf(item): - item.contentType = item.extra.replace("tv", "tvshow") - login, message = login_fa() +# def filmaf(item): +# item.contentType = item.args.replace("tv", "tvshow") +# login, message = login_fa() +# if def_lang == 'it': langf = 'us' - itemlist = [] - if item.extra == "movie": - itemlist.append(item.clone(title=config.get_localized_string(70040), action="listado_fa", extra="top", - url="http://m.filmaffinity.com/%s/topgen.php?genre=&country=&" - "fromyear=&toyear=¬vse=1&nodoc=1" % langf)) - itemlist.append(item.clone(title=config.get_localized_string(70030), action="listado_fa", - url="http://m.filmaffinity.com/%s/rdcat.php?id=new_th_%s" % (langf, langf))) - itemlist.append(item.clone(title=config.get_localized_string(70032), action="indices_fa", url="http://m.filmaffinity.com/%s/topgen.php" - % langf, - thumbnail="%s0/Genres.png" % images_predef)) - else: - itemlist.append(item.clone(title=config.get_localized_string(70040), action="listado_fa", extra="top", - url="http://m.filmaffinity.com/%s/topgen.php?genre=TV_SE&country=&" - "fromyear=&toyear=&nodoc" % langf)) - itemlist.append(item.clone(title="Series de actualidad", action="listado_fa", - url="http://m.filmaffinity.com/%s/category.php?id=current_tv" % langf)) +# itemlist = [] +# if item.args == "movie": +# itemlist.append(item.clone(title=config.get_localized_string(70040), action="list_fa", args="top", url="http://m.filmaffinity.com/%s/topgen.php?genre=&country=&fromyear=&toyear=¬vse=1&nodoc=1" % langf)) +# itemlist.append(item.clone(title=config.get_localized_string(70030), action="list_fa", url="http://m.filmaffinity.com/%s/rdcat.php?id=new_th_%s" % (langf, langf))) +# itemlist.append(item.clone(title=config.get_localized_string(70032), action="indices_fa", url="http://m.filmaffinity.com/%s/topgen.php" % langf)) +# else: +# itemlist.append(item.clone(title=config.get_localized_string(70040), action="list_fa", args="top", url="http://m.filmaffinity.com/%s/topgen.php?genre=TV_SE&country=&fromyear=&toyear=&nodoc" % langf)) +# itemlist.append(item.clone(title="Series de actualidad", action="list_fa", url="http://m.filmaffinity.com/%s/category.php?id=current_tv" % langf)) - itemlist.append(item.clone(title=config.get_localized_string(70042), action="indices_fa", thumbnail="%s0/Year.png" % images_predef)) - if item.extra == "movie": - itemlist.append(item.clone(title=config.get_localized_string(70043), action="listado_fa", extra="estrenos", - url="http://m.filmaffinity.com/%s/rdcat.php?id=upc_th_%s" % (langf, langf))) - itemlist.append(item.clone(title=config.get_localized_string(70044), action="indices_fa", extra="sagas", - url="http://www.filmaffinity.com/%s/movie-groups-all.php" % langf)) - itemlist.append(item.clone(title=config.get_localized_string(70045), action="indices_fa", - url='http://m.filmaffinity.com/%s/topics.php' % langf, )) - if config.get_platform() != "plex": - itemlist.append(item.clone(title=config.get_localized_string(70046), action="search_", - url="http://m.filmaffinity.com/%s/search.php?stype=title&stext=" % langf)) +# itemlist.append(item.clone(title=config.get_localized_string(70042), action="indices_fa")) - itemlist.append(item.clone(title=config.get_localized_string(70036), action="search_", - url="http://m.filmaffinity.com/%s/search.php?stype=cast&stext=" % langf)) - itemlist.append(item.clone(title=config.get_localized_string(70047), action="search_", - url="http://m.filmaffinity.com/%s/search.php?stype=director&stext=" % langf)) +# if item.args == "movie": +# itemlist.append(item.clone(title=config.get_localized_string(70043), action="list_fa", args="estrenos", url="http://m.filmaffinity.com/%s/rdcat.php?id=upc_th_%s" % (langf, langf))) +# itemlist.append(item.clone(title=config.get_localized_string(70044), action="indices_fa", args="sagas", url="http://www.filmaffinity.com/%s/movie-groups-all.php" % langf)) - itemlist.append(item.clone(title=config.get_localized_string(70038), action="filtro_fa", extra="top")) - itemlist.append(item.clone(title=config.get_localized_string(70048), action="cuenta_fa", )) +# itemlist.append(item.clone(title=config.get_localized_string(70045), action="indices_fa", url='http://m.filmaffinity.com/%s/topics.php' % langf, )) - return itemlist +# if config.get_platform() != "plex": +# itemlist.append(item.clone(title=config.get_localized_string(70046), action="search_", url="http://m.filmaffinity.com/%s/search.php?stype=title&stext=" % langf)) +# itemlist.append(item.clone(title=config.get_localized_string(70036), action="search_", url="http://m.filmaffinity.com/%s/search.php?stype=cast&stext=" % langf)) +# itemlist.append(item.clone(title=config.get_localized_string(70047), action="search_", url="http://m.filmaffinity.com/%s/search.php?stype=director&stext=" % langf)) + +# itemlist.append(item.clone(title=config.get_localized_string(70038), action="filter_fa", args="top")) +# itemlist.append(item.clone(title=config.get_localized_string(70048), action="cuenta_fa", )) + +# return thumb(itemlist) def trakt(item): itemlist = [] token_auth = config.get_setting("token_trakt", "trakt") page = "?page=1&limit=20&extended=full" - if not item.extra: - item.extra = "movie" + if not item.args: + item.args = "movie" itemlist.append(item.clone(title=typo(config.get_localized_string(70416), 'bold'), action="")) itemlist.append(item.clone(title=config.get_localized_string(70049), action="acciones_trakt", url="movies/popular%s" % page)) - itemlist.append( - item.clone(title=config.get_localized_string(70050), action="acciones_trakt", url="movies/trending%s" % page)) + itemlist.append(item.clone(title=config.get_localized_string(70050), action="acciones_trakt", url="movies/trending%s" % page)) itemlist.append(item.clone(title=config.get_localized_string(70053), action="acciones_trakt", url="movies/watched/all%s" % page)) - itemlist.append( - item.clone(title=config.get_localized_string(70051), action="acciones_trakt", url="movies/anticipated%s" % page)) - if token_auth: - itemlist.append(item.clone(title=config.get_localized_string(70052), action="acciones_trakt", - url="recommendations/movies?limit=100&extended=full", pagina=0)) + itemlist.append(item.clone(title=config.get_localized_string(70051), action="acciones_trakt", url="movies/anticipated%s" % page)) + if token_auth: itemlist.append(item.clone(title=config.get_localized_string(70052), action="acciones_trakt",url="recommendations/movies?limit=100&extended=full", pagina=0)) itemlist.append(item.clone(title=typo(config.get_localized_string(70417), 'bold'), action="",)) - item.extra = "show" + item.args = "show" itemlist.append(item.clone(title=config.get_localized_string(70049), action="acciones_trakt", url="shows/popular%s" % page)) itemlist.append(item.clone(title=config.get_localized_string(70050), action="acciones_trakt", url="shows/trending%s" % page)) itemlist.append(item.clone(title=config.get_localized_string(70053), action="acciones_trakt", url="shows/watched/all%s" % page)) - itemlist.append( - item.clone(title=config.get_localized_string(70051), action="acciones_trakt", url="shows/anticipated%s" % page)) - if token_auth: - itemlist.append(item.clone(title=config.get_localized_string(70052), action="acciones_trakt", - url="recommendations/shows?limit=100&extended=full", pagina=0)) - itemlist.append(item.clone(title=typo(config.get_localized_string(70048), 'color kod bold'), extra="cuenta")) + itemlist.append(item.clone(title=config.get_localized_string(70051), action="acciones_trakt", url="shows/anticipated%s" % page)) + if token_auth: itemlist.append(item.clone(title=config.get_localized_string(70052), action="acciones_trakt", url="recommendations/shows?limit=100&extended=full", pagina=0)) + itemlist.append(item.clone(title=typo(config.get_localized_string(70048), 'color kod bold'), args="cuenta")) else: - item.extra = "movie" + item.args = "movie" # A saved token is checked and the authentication process is executed if not token_auth: folder = (config.get_platform() == "plex") itemlist.append(item.clone(title=config.get_localized_string(70054), action="auth_trakt", folder=folder)) else: itemlist.append(item.clone(title=config.get_localized_string(70055), action="", )) - itemlist.append( - item.clone(title=config.get_localized_string(60651), action="acciones_trakt", url="users/me/watchlist/movies%s" % page, order="added", how="desc")) - itemlist.append( - item.clone(title=config.get_localized_string(60652), action="acciones_trakt", url="users/me/watchlist/shows%s" % page, extra="show", order="added", how="desc")) + itemlist.append(item.clone(title=config.get_localized_string(60651), action="acciones_trakt", url="users/me/watchlist/movies%s" % page, order="added", how="desc")) + itemlist.append(item.clone(title=config.get_localized_string(60652), action="acciones_trakt", url="users/me/watchlist/shows%s" % page, args="show", order="added", how="desc")) itemlist.append(item.clone(title=config.get_localized_string(70056), action="", )) - itemlist.append( - item.clone(title=config.get_localized_string(60651), action="acciones_trakt", url="users/me/watched/movies%s" % page, order="added", how="desc")) - itemlist.append( - item.clone(title=config.get_localized_string(60652), action="acciones_trakt", url="users/me/watched/shows%s" % page, extra="show", order="added", how="desc")) + itemlist.append(item.clone(title=config.get_localized_string(60651), action="acciones_trakt", url="users/me/watched/movies%s" % page, order="added", how="desc")) + itemlist.append(item.clone(title=config.get_localized_string(60652), action="acciones_trakt", url="users/me/watched/shows%s" % page, args="show", order="added", how="desc")) itemlist.append(item.clone(title=config.get_localized_string(70068), action="", )) - itemlist.append( - item.clone(title=config.get_localized_string(60651), action="acciones_trakt", url="users/me/collection/movies%s" % page, order="added", how="desc")) - itemlist.append( - item.clone(title=config.get_localized_string(60652), action="acciones_trakt", url="users/me/collection/shows%s" % page, extra="show", order="added", how="desc")) - itemlist.append( - item.clone(title=config.get_localized_string(70057), action="acciones_trakt", url="users/me/lists", )) + itemlist.append(item.clone(title=config.get_localized_string(60651), action="acciones_trakt", url="users/me/collection/movies%s" % page, order="added", how="desc")) + itemlist.append(item.clone(title=config.get_localized_string(60652), action="acciones_trakt", url="users/me/collection/shows%s" % page, args="show", order="added", how="desc")) + itemlist.append(item.clone(title=config.get_localized_string(70057), action="acciones_trakt", url="users/me/lists", )) return itemlist @@ -300,19 +240,16 @@ def mal(item): if login: item.login = True - itemlist.append( - item.clone(title=config.get_localized_string(70058), url="https://myanimelist.net/topanime.php?type=tv&limit=0", action="top_mal", contentType="tvshow", extra="tv")) - itemlist.append(item.clone(title=config.get_localized_string(70059), url="https://myanimelist.net/topanime.php?type=movie&limit=0", action="top_mal", contentType="movie", extra="movie")) - itemlist.append( - item.clone(title=config.get_localized_string(70061), url="https://myanimelist.net/topanime.php?type=ova&limit=0", action="top_mal", contentType="tvshow", extra="tv", tipo="ova")) - itemlist.append( - item.clone(title=config.get_localized_string(70028), url="https://myanimelist.net/topanime.php?type=bypopularity&limit=0", action="top_mal")) + itemlist.append(item.clone(title=config.get_localized_string(70058), url="https://myanimelist.net/topanime.php?type=tv&limit=0", action="top_mal", contentType="tvshow", args="tv")) + itemlist.append(item.clone(title=config.get_localized_string(70059), url="https://myanimelist.net/topanime.php?type=movie&limit=0", action="top_mal", contentType="movie", args="movie")) + itemlist.append(item.clone(title=config.get_localized_string(70061), url="https://myanimelist.net/topanime.php?type=ova&limit=0", action="top_mal", contentType="tvshow", args="tv", tipo="ova")) + itemlist.append(item.clone(title=config.get_localized_string(70028), url="https://myanimelist.net/topanime.php?type=bypopularity&limit=0", action="top_mal")) itemlist.append(item.clone(title=config.get_localized_string(70060), url="https://myanimelist.net/topanime.php?type=upcoming&limit=0", action="top_mal")) itemlist.append(item.clone(title=config.get_localized_string(70062), url="", action="indices_mal")) itemlist.append(item.clone(title=config.get_localized_string(70063), url="", action="indices_mal")) if config.get_platform() != "plex": itemlist.append(item.clone(title=config.get_localized_string(70064), url="https://myanimelist.net/anime.php?q=", action="search_")) - itemlist.append(item.clone(title=typo(config.get_localized_string(70038), 'bold submenu'), action="filtro_mal")) + itemlist.append(item.clone(title=typo(config.get_localized_string(70038), 'bold submenu'), action="filter_mal")) itemlist.append(item.clone(title=typo(config.get_localized_string(70057), 'bold submenu'), action="cuenta_mal")) @@ -320,7 +257,7 @@ def mal(item): ##-------------------- SECTION TMDB ------------------------## -def listado_tmdb(item): +def list_tmdb(item): # Main listings of the Tmdb category (Most popular, Most viewed, etc ...) itemlist = [] item.fanart = default_fan @@ -330,45 +267,35 @@ def listado_tmdb(item): # List of actors if 'nm' in item.infoLabels['imdb_id']: try: - - ob_tmdb = Tmdb(discover=item.search, tipo=item.extra, idioma_busqueda=langt) + ob_tmdb = Tmdb(discover=item.search, tipo=item.args, idioma_searching=langt) id_cast = ob_tmdb.result["person_results"][0]["id"] - if item.contentType == "movie": - item.search = {'url': 'discover/movie', 'with_cast': id_cast, 'page': item.pagina, - 'sort_by': 'primary_release_date.desc', 'language': langt} - else: - item.search = {'url': 'person/%s/tv_credits' % id_cast, 'language': langt} - ob_tmdb = Tmdb(discover=item.search, tipo=item.extra, idioma_busqueda=langt) + if item.contentType == "movie": item.search = {'url': 'discover/movie', 'with_cast': id_cast, 'page': item.pagina, 'sort_by': 'primary_release_date.desc', 'language': langt} + else:item.search = {'url': 'person/%s/tv_credits' % id_cast, 'language': langt} + ob_tmdb = Tmdb(discover=item.search, tipo=item.args, idioma_searching=langt) except: pass else: - ob_tmdb = Tmdb(discover=item.search, tipo=item.extra, idioma_busqueda=langt) + ob_tmdb = Tmdb(discover=item.search, tipo=item.args, idioma_searching=langt) # Sagas and collections if "collection" in item.search["url"]: try: - new_item = item.clone(action="", url='') - new_item.infoLabels["plot"] = ob_tmdb.result["overview"] - itemlist.append(new_item) for parte in ob_tmdb.result["parts"]: - new_item = item.clone(action="detalles") + new_item = item.clone(action="details") new_item.infoLabels = ob_tmdb.get_infoLabels(new_item.infoLabels, origen=parte) - if new_item.infoLabels['thumbnail']: - new_item.thumbnail = new_item.infoLabels['thumbnail'] - if new_item.infoLabels['fanart']: - new_item.fanart = new_item.infoLabels['fanart'] + if new_item.infoLabels['thumbnail']: new_item.thumbnail = new_item.infoLabels['thumbnail'] + if new_item.infoLabels['fanart']: new_item.fanart = new_item.infoLabels['fanart'] - if new_item.infoLabels['year']: - new_item.title = typo(new_item.contentTitle, 'bold') + ' (%s)' % new_item.infoLabels['year'] + typo(str(new_item.infoLabels['rating']).replace("0.0", ""), '_ color kod') - else: - new_item.title = typo(new_item.contentTitle, 'bold') + ' (%s)' % new_item.infoLabels['year'] + typo(str(new_item.infoLabels['rating']).replace("0.0", ""), '_ color kod') + if new_item.infoLabels['year']: new_item.title = typo(new_item.contentTitle, 'bold') + ' (%s)' % new_item.infoLabels['year'] + typo(str(new_item.infoLabels['rating']).replace("0.0", ""), '_ color kod') + else: new_item.title = typo(new_item.contentTitle, 'bold') + ' (%s)' % new_item.infoLabels['year'] + typo(str(new_item.infoLabels['rating']).replace("0.0", ""), '_ color kod') itemlist.append(new_item) + itemlist.sort(key=lambda item: item.infoLabels["year"]) except: pass else: try: orden = False - # If you do a search for actors or directors, those results are extracted + # If you do a search for actors or directors, those results are argscted if "cast" in ob_tmdb.result and not item.crew: ob_tmdb.results = ob_tmdb.result["cast"] orden = True @@ -376,11 +303,11 @@ def listado_tmdb(item): ob_tmdb.results = ob_tmdb.result["crew"] orden = True for i in range(0, len(ob_tmdb.results)): - new_item = item.clone(action="detalles", url='', infoLabels={'mediatype': item.contentType}) + new_item = item.clone(action="details", url='', infoLabels={'mediatype': item.contentType}) new_item.infoLabels = ob_tmdb.get_infoLabels(new_item.infoLabels, origen=ob_tmdb.results[i]) # If there is no synopsis in the chosen language, search in the alternative if not new_item.infoLabels["plot"] and not 'person' in item.search["url"]: - ob_tmdb2 = Tmdb(id_Tmdb=new_item.infoLabels["tmdb_id"], tipo=item.extra, idioma_busqueda=langt_alt) + ob_tmdb2 = Tmdb(id_Tmdb=new_item.infoLabels["tmdb_id"], tipo=item.args, idioma_searching=langt_alt) new_item.infoLabels["plot"] = ob_tmdb2.get_sinopsis() if new_item.infoLabels['thumbnail']: new_item.thumbnail = new_item.infoLabels['thumbnail'] @@ -390,36 +317,28 @@ def listado_tmdb(item): new_item.plot = new_item.infoLabels["biography"] if not item.search.get('with_cast', '') and not item.search.get('with_crew', ''): if item.contentType == "movie": - new_item.action = "listado_tmdb" + new_item.action = "list_tmdb" cast = 'with_cast' if item.crew: cast = 'with_crew' - new_item.search = {'url': 'discover/movie', cast: new_item.infoLabels['tmdb_id'], - 'sort_by': 'primary_release_date.desc', 'language': langt, - 'page': item.pagina} + new_item.search = {'url': 'discover/movie', cast: new_item.infoLabels['tmdb_id'], 'sort_by': 'primary_release_date.desc', 'language': langt, 'page': item.pagina} else: - new_item.action = "listado_tmdb" - new_item.search = {'url': 'person/%s/tv_credits' % new_item.infoLabels['tmdb_id'], - 'language': langt} + new_item.action = "list_tmdb" + new_item.search = {'url': 'person/%s/tv_credits' % new_item.infoLabels['tmdb_id'], 'language': langt} elif not new_item.infoLabels['thumbnail'] and not new_item.infoLabels['profile_path']: new_item.thumbnail = '' - if new_item.infoLabels['fanart']: - new_item.fanart = new_item.infoLabels['fanart'] + + if new_item.infoLabels['fanart']: new_item.fanart = new_item.infoLabels['fanart'] if not 'person' in item.search["url"] or 'tv_credits' in item.search["url"]: - if new_item.infoLabels['year']: - new_item.title = "%s %s %s" \ - % (typo(new_item.contentTitle,'bold'), typo(new_item.infoLabels['year'],'() bold'), - typo(str(new_item.infoLabels['rating']).replace("0.0", ""),'color kod bold')) - else: - new_item.title = "%s %s" \ - % (typo(new_item.contentTitle,'bold'), - typo(new_item.infoLabels['rating'].replace("0.0", ""),'color kod bold')) + new_item.title = typo(new_item.contentTitle,'bold') + if new_item.infoLabels['year']: new_item.title += typo(new_item.infoLabels['year'],'_ () bold') + if new_item.infoLabels['rating'] != '0.0': new_item.title += typo(new_item.infoLabels['rating'],'_ [] color kod bold') else: # If it is a search for people, a film for which it is known is included in the title and fanart known_for = ob_tmdb.results[i].get("known_for") - type=item.type + # type=item.type if known_for: from random import randint random = randint(0, len(known_for) - 1) @@ -432,46 +351,39 @@ def listado_tmdb(item): itemlist.append(new_item) except: import traceback - logger.error(traceback.format_exc()) + error(traceback.format_exc()) if orden: itemlist.sort(key=lambda item: item.infoLabels["year"], reverse=True) if "page" in item.search and ob_tmdb.total_pages > item.search["page"]: item.search["page"] += 1 - itemlist.append(Item(channel=item.channel, action=item.action, title=config.get_localized_string(70065), - search=item.search, extra=item.extra, pagina=item.pagina + 1, - contentType=item.contentType)) + itemlist.append(item.clone(title=typo(config.get_localized_string(30992), 'color kod bold'), pagina=item.pagina + 1, thumbnail=thumb())) return itemlist -def detalles(item): +def details(item): itemlist = [] images = {} data = "" # If it comes from imdb section if not item.infoLabels["tmdb_id"]: headers = [['Accept-Language', langi]] - #data = httptools.downloadpage("http://www.imdb.com/title/" + item.infoLabels['imdb_id'], headers=headers, - # replace_headers=True).data - data = httptools.downloadpage("http://www.imdb.com/title/" + item.infoLabels['imdb_id'], headers=headers).data + data = match("http://www.imdb.com/title/" + item.infoLabels['imdb_id'], headers=headers).data - pics = scrapertools.find_single_match(data, 'showAllVidsAndPics.*?href=".*?(tt\d+)') # Imdb images - if pics: - images["imdb"] = {'url': 'http://www.imdb.com/_json/title/%s/mediaviewer' % pics} + pics = match(data, patron=r'showAllVidsAndPics.*?href=".*?(tt\d+)').match + if pics: images["imdb"] = {'url': 'http://www.imdb.com/_json/title/%s/mediaviewer' % pics} - ob_tmdb = Tmdb(external_id=item.infoLabels["imdb_id"], external_source="imdb_id", tipo=item.extra, - idioma_busqueda=langt) + ob_tmdb = Tmdb(external_id=item.infoLabels["imdb_id"], external_source="imdb_id", tipo=item.args, idioma_searching=langt) item.infoLabels["tmdb_id"] = ob_tmdb.get_id() - ob_tmdb = Tmdb(id_Tmdb=item.infoLabels["tmdb_id"], tipo=item.extra, idioma_busqueda=langt) + ob_tmdb = Tmdb(id_Tmdb=item.infoLabels["tmdb_id"], tipo=item.args, idioma_searching=langt) try: item.infoLabels = ob_tmdb.get_infoLabels(item.infoLabels) # If there is no synopsis in the chosen language, search in the alternative - if not item.infoLabels["plot"]: - item.infoLabels["plot"] = ob_tmdb.get_sinopsis(idioma_alternativo=langt_alt) + if not item.infoLabels["plot"]: item.infoLabels["plot"] = ob_tmdb.get_sinopsis(idioma_alternativo=langt_alt) except: pass if not item.fanart and item.infoLabels['fanart']: @@ -481,51 +393,45 @@ def detalles(item): # Synopsis, votes from imdb if data: - plot = scrapertools.find_single_match(data, 'class="inline canwrap" itemprop="description">(.*?)') - plot = scrapertools.htmlclean(plot) - plot = re.sub(r'(?i)]+>|\n|\s{2}', ' ', plot).strip() - if plot and (item.infoLabels['plot'] and item.infoLabels['plot'] != plot): - item.infoLabels['plot'] += " (TMDB)\n" + plot + " (IMDB)" - elif plot and not item.infoLabels['plot']: - item.infoLabels['plot'] = plot - rating = scrapertools.find_single_match(data, 'itemprop="ratingValue">([^<]+)<') - if rating: - item.infoLabels['rating'] = float(rating.replace(",", ".")) - votos = scrapertools.find_single_match(data, 'itemprop="ratingCount">([^<]+)<') - if votos: - item.infoLabels['votes'] = votos + plot = match(data, patron='class="inline canwrap" itemprop="description">(.*?)').match + plot = re.sub(r'(?i)]+>|\n|\s{2}', ' ', htmlclean(plot)).strip() + if plot and (item.infoLabels['plot'] and item.infoLabels['plot'] != plot): item.infoLabels['plot'] += " (TMDB)\n" + plot + " (IMDB)" + elif plot and not item.infoLabels['plot']: item.infoLabels['plot'] = plot - if item.infoLabels['tagline']: - itemlist.append(item.clone(title="--- %s ---" % item.infoLabels['tagline'], action="")) + rating = match(data, patron=r'itemprop="ratingValue">([^<]+)<').match + if rating: item.infoLabels['rating'] = float(rating.replace(",", ".")) + + votos = match(data, patron=r'itemprop="ratingCount">([^<]+)<').match + if votos: item.infoLabels['votes'] = votos + + if item.infoLabels['tagline']: item.plot= typo(item.infoLabels['tagline'],'bold') + '\n' + item.plot title = item.contentType.replace("movie", config.get_localized_string(70283)).replace("tvshow", "serie") # Search by titles chosen language and / or original version and Spanish - itemlist.append(item.clone(action="busqueda", title=config.get_localized_string(70069) % (title, item.contentTitle))) + itemlist.append(item.clone(channel='search', action="new_search", title=config.get_localized_string(70069) % (title, item.contentTitle), search_text=item.contentTitle, mode=item.contentType)) if item.infoLabels['originaltitle'] and item.contentTitle != item.infoLabels['originaltitle']: - itemlist.append(item.clone(action="busqueda", contentTitle=item.infoLabels['originaltitle'], title=config.get_localized_string(70070) % item.infoLabels['originaltitle'])) + itemlist.append(item.clone(channel='search', action="search", search_text=item.infoLabels['originaltitle'], title=config.get_localized_string(70070) % item.infoLabels['originaltitle'], mode=item.contentType)) - if langt != "es" and langt != "en" and item.infoLabels["tmdb_id"]: - tmdb_lang = Tmdb(id_Tmdb=item.infoLabels["tmdb_id"], tipo=item.extra, idioma_busqueda=def_lang) - if tmdb_lang.result.get("title") and tmdb_lang.result["title"] != item.contentTitle \ - and tmdb_lang.result["title"] != item.infoLabels['originaltitle']: - tmdb_lang = tmdb_lang.result["title"] - itemlist.append(item.clone(action="busqueda", title=config.get_localized_string(70066) % tmdb_lang, contentTitle=tmdb_lang)) + # if langt != "es" and langt != "en" and item.infoLabels["tmdb_id"]: + # tmdb_lang = Tmdb(id_Tmdb=item.infoLabels["tmdb_id"], tipo=item.args, idioma_searching=def_lang) + # if tmdb_lang.result.get("title") and tmdb_lang.result["title"] != item.contentTitle and tmdb_lang.result["title"] != item.infoLabels['originaltitle']: + # tmdb_lang = tmdb_lang.result["title"] + # itemlist.append(item.clone(channel='search', action="search", title=config.get_localized_string(70066) % tmdb_lang, contentTitle=tmdb_lang, mode=item.contentType)) - # In case of series, option of info by seasons + # In case of series, option of info by seasons if item.contentType == "tvshow" and item.infoLabels['tmdb_id']: itemlist.append(item.clone(action="info_seasons", title=config.get_localized_string(70067) % item.infoLabels["number_of_seasons"])) # Option to watch the cast and browse their movies / series if item.infoLabels['tmdb_id']: - itemlist.append(item.clone(action="reparto", title=config.get_localized_string(70071), infoLabels={'tmdb_id': item.infoLabels['tmdb_id'], 'mediatype': item.contentType})) + itemlist.append(item.clone(action="distribution", title=config.get_localized_string(70071), infoLabels={'tmdb_id': item.infoLabels['tmdb_id'], 'mediatype': item.contentType})) if config.is_xbmc(): item.contextual = True - itemlist.append(item.clone(channel="trailertools", action="buscartrailer", title=config.get_localized_string(60359), - )) + itemlist.append(item.clone(channel="trailertools", action="buscartrailer", title=config.get_localized_string(60359))) try: images['tmdb'] = ob_tmdb.result["images"] - itemlist.append(item.clone(action="imagenes", title=config.get_localized_string(70316), images=images, extra="menu")) + itemlist.append(item.clone(action="imagenes", title=config.get_localized_string(70316), images=images, args="menu")) except: pass @@ -556,7 +462,7 @@ def detalles(item): if token_auth: itemlist.append(item.clone(title=config.get_localized_string(70318), action="menu_trakt")) - itemlist.append(item.clone(title="", action="")) + # itemlist.append(item.clone(title="", action="")) # It is part of a collection try: if ob_tmdb.result.get("belongs_to_collection"): @@ -568,39 +474,33 @@ def detalles(item): if saga["backdrop_path"]: new_item.fanart = 'http://image.tmdb.org/t/p/original' + saga["backdrop_path"] new_item.search = {'url': 'collection/%s' % saga['id'], 'language': langt} - itemlist.append(new_item.clone(title=config.get_localized_string(70327) % saga["name"], action="listado_tmdb")) + itemlist.append(new_item.clone(title=config.get_localized_string(70327) % saga["name"], action="list_tmdb")) except: pass # Similar Movies / Series and Recommendations if item.infoLabels['tmdb_id']: - item.extra = item.contentType.replace('tvshow', 'tv') + item.args = item.contentType.replace('tvshow', 'tv') title = title.replace("película", config.get_localized_string(70137)).replace("serie", config.get_localized_string(30123)) - itemlist.append(item.clone(title=config.get_localized_string(70328) % title, action="listado_tmdb", - search={'url': '%s/%s/similar' % (item.extra, item.infoLabels['tmdb_id']), - 'language': langt, 'page': 1}, infoLabels={'mediatype': item.contentType}, - )) - itemlist.append( - item.clone(title=config.get_localized_string(70315), action="listado_tmdb", infoLabels={'mediatype': item.contentType}, - search={'url': '%s/%s/recommendations' % (item.extra, item.infoLabels['tmdb_id']), - 'language': langt, 'page': 1}, )) + itemlist.append(item.clone(title=config.get_localized_string(70328) % title, action="list_tmdb", search={'url': '%s/%s/similar' % (item.args, item.infoLabels['tmdb_id']), 'language': langt, 'page': 1}, infoLabels={'mediatype': item.contentType})) + itemlist.append(item.clone(title=config.get_localized_string(70315), action="list_tmdb", search={'url': '%s/%s/recommendations' % (item.args, item.infoLabels['tmdb_id']), 'language': langt, 'page': 1})) return itemlist -def reparto(item): +def distribution(item): # Actors and film crew for a movie / series itemlist = [] - item.extra=item.contentType.replace('tvshow','tv') - item.search = {'url': '%s/%s/credits' % (item.extra, item.infoLabels['tmdb_id'])} - ob_tmdb = Tmdb(discover=item.search, tipo=item.extra, idioma_busqueda=langt) + item.args=item.contentType.replace('tvshow','tv') + item.search = {'url': '%s/%s/credits' % (item.args, item.infoLabels['tmdb_id'])} + ob_tmdb = Tmdb(discover=item.search, tipo=item.args, idioma_searching=langt) try: cast = ob_tmdb.result["cast"] if cast: itemlist.append(item.clone(title=config.get_localized_string(70314), action="", )) for actor in cast: - new_item = item.clone(action="listado_tmdb", fanart=default_fan) + new_item = item.clone(action="list_tmdb", fanart=default_fan) new_item.title = " " + actor["name"] + " as " + actor["character"] if actor["profile_path"]: new_item.thumbnail = 'http://image.tmdb.org/t/p/original' + actor["profile_path"] @@ -619,13 +519,12 @@ def reparto(item): if crew: itemlist.append(item.clone(title=config.get_localized_string(70319), action="", )) for c in crew: - new_item = item.clone(action="listado_tmdb", fanart=default_fan) + new_item = item.clone(action="list_tmdb", fanart=default_fan) new_item.title = " " + c["job"] + ": " + c["name"] if c["profile_path"]: new_item.thumbnail = 'http://image.tmdb.org/t/p/original' + c["profile_path"] if item.contentType == "movie": - new_item.search = {'url': 'discover/movie', 'with_crew': c['id'], 'page': 1, - 'sort_by': 'primary_release_date.desc'} + new_item.search = {'url': 'discover/movie', 'with_crew': c['id'], 'page': 1,'sort_by': 'primary_release_date.desc'} else: new_item.search = {'url': 'person/%s/tv_credits' % c['id'], 'language': langt} new_item.crew = True @@ -639,7 +538,7 @@ def reparto(item): def info_seasons(item): # Season and episode info itemlist = [] - ob_tmdb = Tmdb(id_Tmdb=item.infoLabels["tmdb_id"], tipo="tv", idioma_busqueda=langt) + ob_tmdb = Tmdb(id_Tmdb=item.infoLabels["tmdb_id"], tipo="tv", idioma_searching=langt) for temp in range(item.infoLabels["number_of_seasons"], 0, -1): temporada = ob_tmdb.get_temporada(temp) @@ -689,20 +588,13 @@ def indices_tmdb(item): from datetime import datetime if config.get_localized_string(70032) in item.title: thumbnail = {} - url = ('http://api.themoviedb.org/3/genre/%s/list?api_key=a1ab8b8669da03637a4b98fa39c39228&language=%s' - % (item.extra, langt)) - lista_generos = {} + url = ('http://api.themoviedb.org/3/genre/%s/list?api_key=a1ab8b8669da03637a4b98fa39c39228&language=%s' % (item.args, langt)) + genres_list = {} try: - lista = jsontools.load(httptools.downloadpage(url, cookies=False).data)["genres"] - for l in lista: - lista_generos[str(l["id"])] = l["name"] - if "es" in langt: - thumbnail[str(l["id"])] = "%s1/%s.jpg" % (images_predef, l["name"].lower() \ - .replace("ó", "o").replace("í", "i") \ - .replace(" ", "%20").replace("Aventuras", "Aventura") - .replace("ú", "u")) - else: - thumbnail[str(l["id"])] = "%s2/%s.jpg" % (images_predef, l["name"]) + for l in jsontools.load(match(url, cookies=False).data)["genres"]: + genres_list[str(l["id"])] = l["name"] + if "es" in langt: thumbnail[str(l["id"])] = "%s1/%s.jpg" % (images_predef, l["name"].lower().replace("ó", "o").replace("í", "i").replace(" ", "%20").replace("Aventuras", "Aventura").replace("ú", "u")) + else: thumbnail[str(l["id"])] = "%s2/%s.jpg" % (images_predef, l["name"]) except: pass @@ -712,14 +604,13 @@ def indices_tmdb(item): if item.contentType == 'tvshow': sort_by = 'first_air_date.desc' param_year = 'air_date.lte' - for key, value in lista_generos.items(): - search = {'url': 'discover/%s' % item.extra, 'with_genres': key, 'sort_by': sort_by, - param_year: fecha, - 'language': langt, 'page': 1} - new_item = item.clone(title=value, thumbnail=thumbnail[key], action="listado_tmdb", search=search) + for key, value in genres_list.items(): + search = {'url': 'discover/%s' % item.args, 'with_genres': key, 'sort_by': sort_by, param_year: fecha,'language': langt, 'page': 1} + new_item = item.clone(title=value, thumbnail=thumbnail[key], action="list_tmdb", search=search) itemlist.append(new_item) itemlist.sort(key=lambda item: item.title) + thumb(itemlist) else: year = datetime.now().year + 3 for i in range(year, 1899, -1): @@ -727,14 +618,14 @@ def indices_tmdb(item): param_year = 'first_air_date_year' else: param_year = 'primary_release_year' - search = {'url': 'discover/%s' % item.extra, param_year: i, 'language': langt, 'page': 1} - itemlist.append(item.clone(title=str(i), action='listado_tmdb', search=search)) + search = {'url': 'discover/%s' % item.args, param_year: i, 'language': langt, 'page': 1} + itemlist.append(item.clone(title=str(i), action='list_tmdb', search=search)) return itemlist -def filtro(item): - logger.log() +def filter(item): + log() from datetime import datetime list_controls = [] @@ -742,8 +633,7 @@ def filtro(item): dict_values = None - list_controls.append({'id': 'years', 'label': config.get_localized_string(60232), 'enabled': True, 'color': '0xFFCC2EFA', - 'type': 'list', 'default': -1, 'visible': True}) + list_controls.append({'id': 'years', 'label': config.get_localized_string(60232), 'enabled': True, 'type': 'list', 'default': -1, 'visible': True}) list_controls[0]['lvalues'] = [] valores['years'] = [] year = datetime.now().year + 1 @@ -753,124 +643,103 @@ def filtro(item): list_controls[0]['lvalues'].append(config.get_localized_string(70450)) valores['years'].append('') - if "Personalizado" in item.title: + if config.get_localized_string(70038) in item.title: # Se utilizan los valores por defecto/guardados - valores_guardados = config.get_setting("filtro_defecto_" + item.extra, item.channel) - if valores_guardados: - dict_values = valores_guardados - url = ('http://api.themoviedb.org/3/genre/%s/list?api_key=f7f51775877e0bb6703520952b3c7840&language=%s' - % (item.extra, langt)) + saved_values = config.get_setting("default_filter_" + item.args, item.channel) + if saved_values: + dict_values = saved_values + url = ('http://api.themoviedb.org/3/genre/%s/list?api_key=f7f51775877e0bb6703520952b3c7840&language=%s' % (item.args, langt)) try: lista = jsontools.load(httptools.downloadpage(url, cookies=False).data)["genres"] if lista: - list_controls.append({'id': 'labelgenre', 'enabled': True, 'type': 'label', 'default': None, - 'label': config.get_localized_string(70451), - 'visible': True, 'color': '0xFFC52020'}) + list_controls.append({'id': 'labelgenre', 'enabled': True, 'type': 'label', 'default': None, 'label': config.get_localized_string(70451), 'visible': True}) for l in lista: - list_controls.append({'id': 'genre' + str(l["id"]), 'label': l["name"], 'enabled': True, - 'type': 'bool', 'default': False, 'visible': True}) + list_controls.append({'id': 'genre' + str(l["id"]), 'label': l["name"], 'enabled': True, 'type': 'bool', 'default': False, 'visible': True}) except: pass - list_controls.append({'id': 'orden', 'label': config.get_localized_string(70455), 'enabled': True, 'color': '0xFF25AA48', - 'type': 'list', 'default': -1, 'visible': True}) + list_controls.append({'id': 'orden', 'label': config.get_localized_string(70455), 'enabled': True, 'type': 'list', 'default': -1, 'visible': True}) orden = [config.get_localized_string(70456), config.get_localized_string(70457), config.get_localized_string(70458), config.get_localized_string(70459), config.get_localized_string(70460), config.get_localized_string(70461)] - if item.extra == "movie": + if item.args == "movie": orden.extend([config.get_localized_string(70462), config.get_localized_string(70463)]) - orden_tmdb = ['popularity.desc', 'popularity.asc', 'release_date.desc', 'release_date.asc', - 'vote_average.desc', 'vote_average.asc', 'original_title.asc', 'original_title.desc'] + orden_tmdb = ['popularity.desc', 'popularity.asc', 'release_date.desc', 'release_date.asc', 'vote_average.desc', 'vote_average.asc', 'original_title.asc', 'original_title.desc'] valores['orden'] = [] list_controls[-1]['lvalues'] = [] for i, tipo_orden in enumerate(orden): list_controls[-1]['lvalues'].insert(0, tipo_orden) valores['orden'].insert(0, orden_tmdb[i]) - list_controls.append({'id': 'espacio', 'label': '', 'enabled': False, - 'type': 'label', 'default': None, 'visible': True}) - list_controls.append({'id': 'save', 'label': config.get_localized_string(70464), 'enabled': True, - 'type': 'bool', 'default': False, 'visible': True}) + list_controls.append({'id': 'espacio', 'label': '', 'enabled': False, 'type': 'label', 'default': None, 'visible': True}) + list_controls.append({'id': 'save', 'label': config.get_localized_string(70464), 'enabled': True, 'type': 'bool', 'default': False, 'visible': True}) else: - list_controls.append({'id': 'keyword', 'label': config.get_localized_string(70465), 'enabled': True, - 'type': 'text', 'default': '', 'visible': True}) + list_controls.append({'id': 'keyword', 'label': config.get_localized_string(70465), 'enabled': True, 'type': 'text', 'default': '', 'visible': True}) item.valores = valores - return platformtools.show_channel_settings(list_controls=list_controls, dict_values=dict_values, - caption=config.get_localized_string(70320), item=item, callback='filtrado') + return platformtools.show_channel_settings(list_controls=list_controls, dict_values=dict_values, caption=config.get_localized_string(70320), item=item, callback='filtered') -def filtrado(item, values): +def filtered(item, values): values_copy = values.copy() # Save the filter to be the one loaded by default if "save" in values and values["save"]: values_copy.pop("save") - config.set_setting("filtro_defecto_" + item.extra, values_copy, item.channel) + config.set_setting("default_filter_" + item.args, values_copy, item.channel) year = item.valores["years"][values["years"]] - if "Personalizado" in item.title: + if config.get_localized_string(70038) in item.title: orden = item.valores["orden"][values["orden"]] - if item.extra == "tv": - orden = orden.replace('release_date', 'first_air_date') + if item.args == "tv": orden = orden.replace('release_date', 'first_air_date') - genero_ids = [] + genre_ids = [] for v in values: if "genre" in v: - if values[v]: - genero_ids.append(v.replace('genre', '')) - genero_ids = ",".join(genero_ids) + if values[v]: genre_ids.append(v.replace('genre', '')) + genre_ids = ",".join(genre_ids) - if "clave" in item.title: - item.search = {'url': 'search/%s' % item.extra, 'year': year, 'query': values["keyword"], - 'language': langt, 'page': 1} - elif item.extra == "movie": - item.search = {'url': 'discover/%s' % item.extra, 'sort_by': orden, 'primary_release_year': year, - 'with_genres': genero_ids, 'vote_count.gte': '10', 'language': langt, 'page': 1} - else: - item.search = {'url': 'discover/%s' % item.extra, 'sort_by': orden, 'first_air_date_year': year, - 'with_genres': genero_ids, 'vote_count.gte': '10', 'language': langt, 'page': 1} + if config.get_localized_string(70465).lower() in item.title.lower(): item.search = {'url': 'search/%s' % item.args, 'year': year, 'query': values["keyword"], 'language': langt, 'page': 1} + elif item.args == "movie": item.search = {'url': 'discover/%s' % item.args, 'sort_by': orden, 'primary_release_year': year, 'with_genres': genre_ids, 'vote_count.gte': '10', 'language': langt, 'page': 1} + else: item.search = {'url': 'discover/%s' % item.args, 'sort_by': orden, 'first_air_date_year': year, 'with_genres': genre_ids, 'vote_count.gte': '10', 'language': langt, 'page': 1} - item.action = "listado_tmdb" - return listado_tmdb(item) + item.action = "list_tmdb" + return list_tmdb(item) def musica_movie(item): - logger.log() + log() itemlist = [] - - data = httptools.downloadpage(item.url).data - patron = '([^<]+)
([^<]+).*?(\d+:\d+).*?

([^<]+)
([^<]+).*?(\d+:\d+).*?

(.*?)' - matches = scrapertools.find_multiple_matches(data, patron) - for thumbnail, imdb_id, title, movie, datos in matches: - new_item = item.clone(action='listado_tmdb') + patron = r'src="([^"]+)"[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>([^<]+)|"description">([^<]+)<)' - matches = scrapertools.find_multiple_matches(data, patron) - for thumbnail, thumb2, imdb_id, title, datos, plot, plot2 in matches: + patron = r'(?:

|
]+>\s*([^<]+)<' + matches = match(data, patron=patron).matches + for thumbnail, thumb2, imdb_id, title, info, plot in matches: - new_item = item.clone(action='detalles') - new_item.title = title.strip() - if not thumbnail: - thumbnail = thumb2 + new_item = item.clone(action='details') + new_item.title = typo(title.strip(),'bold') + if not thumbnail: thumbnail = thumb2 try: if "@" in thumbnail: thumbnail = thumbnail.rsplit('@', 1)[0] @@ -910,51 +776,43 @@ def listado_imdb(item): pass new_item.thumbnail = thumbnail - if not plot: - plot = plot2 - new_item.infoLabels['plot'] = scrapertools.htmlclean(plot.strip()) + new_item.infoLabels['plot'] = htmlclean(plot.strip()) - generos = scrapertools.find_multiple_matches(datos, 'genre">([^<]+)<') - if generos: - new_item.infoLabels["genre"] = ", ".join(generos) - duracion = scrapertools.find_single_match(datos, '(\d+) min') - if duracion: - new_item.infoLabels['duration'] = int(duracion) * 60 + genres = match(info, patron=r'genre">([^<]+)<').matches + if genres: new_item.infoLabels["genre"] = ", ".join(genres) + duration = match(info, patron=r'(\d+) min').match + if duration: new_item.infoLabels['duration'] = int(duration) * 60 - new_item.infoLabels['year'] = scrapertools.find_single_match(new_item.title, '\((\d{4})') + new_item.infoLabels['year'] = match(new_item.title, patron=r'\((\d{4})').match if not new_item.infoLabels['year']: - new_item.infoLabels['year'] = scrapertools.find_single_match(datos, 'year.*?\((\d{4})') - if new_item.infoLabels['year']: - new_item.title += ' (%s)' % new_item.infoLabels['year'] + new_item.infoLabels['year'] = match(info, patron=r'year.*?\((\d{4})').match + if new_item.infoLabels['year']: new_item.title += typo(new_item.infoLabels['year'], '_ () bold') - rating = scrapertools.find_single_match(datos, '(?:rating|Metascore).*?([^<]*)') - rating = rating.replace(",", ".") + rating = match(info, patron=r'(?:rating|Metascore).*?([^<]*)').match.replace(",", ".") if rating: if not "." in rating: - try: - rating = float(rating) / 10 - except: - rating = None + try: rating = float(rating) / 10 + except: rating = None if rating: - new_item.title += typo(str(rating), '_ color kod') + new_item.title += typo(str(rating), '_ [] color kod') new_item.infoLabels['rating'] = float(rating) new_item.infoLabels['imdb_id'] = imdb_id itemlist.append(new_item) - next_page = scrapertools.find_single_match(data, ']*>Next') + match_data = match(data, patron=r'
|' \ - '
([^<]+)
' \ - '\s*(.*?)\s*<|)' - matches = scrapertools.find_multiple_matches(bloque, patron) - for url, thumb, thumb2, title, year, rating, votos in matches: - title = title.strip() - new_item = item.clone(action="detalles_fa", contentType="movie", extra="movie", contentTitle=title) - if not url.startswith("http://m.filmaffinity"): - new_item.url = "http://m.filmaffinity.com" + url - else: - new_item.url = url - - if not thumb: - thumb = thumb2 - new_item.thumbnail = thumb.replace("msmall", "large") - if not new_item.thumbnail.startswith("http"): - new_item.thumbnail = "http://m.filmaffinity.com" + new_item.thumbnail - - new_item.title = " " + title + " (%s) %s" % (year, rating) - new_item.infoLabels['year'] = year - votaciones.append([rating, votos]) - if rating: - new_item.infoLabels['rating'] = float(rating.replace(",", ".")) - new_item.infoLabels['votes'] = votos - itemlist.append(new_item) - else: - patron = '(?:
|)' \ - '.*?(?:data-src="([^"]+)"|src="((?!/images/empty.gif)[^"]+)").*?' \ - '
' \ - '([^<]+)
\s*(.*?)\s*<|)' - matches = scrapertools.find_multiple_matches(data, patron) - for url, url2, thumb, thumb2, title, year, rating, votos in matches: - title = title.strip() - new_item = item.clone(action="detalles_fa", extra="movie") - if not url: - url = url2 - if not url.startswith("http://m.filmaffinity"): - new_item.url = "http://m.filmaffinity.com" + url - else: - new_item.url = url - - if not thumb: - thumb = thumb2 - new_item.thumbnail = thumb.replace("msmall", "large") - if not new_item.thumbnail.startswith("http"): - new_item.thumbnail = "http://m.filmaffinity.com" + new_item.thumbnail - - new_item.title = title.replace("(Serie de TV)", "").replace("(TV)", "") + " (%s) %s" \ - % (year, rating) - new_item.contentTitle = re.sub(r'(?i)\(serie de tv\)|\(tv\)|\(c\)', '', title) - if re.search(r'(?i)serie de tv|\(tv\)', title): - new_item.contentType = "tvshow" - new_item.extra = "tv" - new_item.infoLabels["tvshowtitle"] = new_item.contentTitle - - new_item.infoLabels['year'] = year - votaciones.append([rating, votos]) - if rating: - new_item.infoLabels['rating'] = float(rating.replace(",", ".")) - new_item.infoLabels['votes'] = votos - itemlist.append(new_item) - - if len(itemlist) < 31: - from core import tmdb - tmdb.set_infoLabels_itemlist(itemlist, True) - for i, it in enumerate(itemlist): - try: - it.infoLabels['votes'] = votaciones[i][1] - it.infoLabels['rating'] = float(votaciones[i][0].replace(",", ".")) - except: - pass - - next_page = scrapertools.find_single_match(data, 'aria-label="Next" href="([^"]+)"') - if next_page: - if not next_page.startswith("http://m.filmaffinity"): - next_page = "http://m.filmaffinity.com" + next_page - - itemlist.append(Item(channel=item.channel, action=item.action, title=config.get_localized_string(70065), url=next_page, - extra=item.extra)) - elif item.page_fa: - itemlist.append(item.clone(title=config.get_localized_string(70065), )) - return itemlist - - -def indices_fa(item): - # Indexes by gender, year, themes and sagas / collections - itemlist = [] - if item.url: - data = httptools.downloadpage(item.url).data - data = re.sub(r"\n|\r|\t| ", "", data) - data = re.sub(r"\s{2}", " ", data) - if "sagas" in item.extra: - patron = '
  • .*?href="([^"]+)".*?group-name">([^<]+)<.*?src="([^"]+)".*?' \ - '"count-movies">([^<]+)<' - matches = scrapertools.find_multiple_matches(data, patron) - for url, title, thumbnail, info in matches: - new_item = item.clone(action="listado_fa") - if not url.startswith("http://www.filmaffinity"): - new_item.url = "http://m.filmaffinity.com" + url - else: - new_item.url = url.replace("www.filmaffinity.com", "m.filmaffinity.com") - - new_item.thumbnail = thumbnail.replace("mmed", "large") - new_item.title = title.strip() + " (%s)" % (info) - itemlist.append(new_item) - - next_page = scrapertools.find_single_match(data, '>>') - if next_page: - if not next_page.startswith("http://www.filmaffinity.com"): - next_page = "http://www.filmaffinity.com" + next_page - itemlist.append(Item(channel=item.channel, action=item.action, title=config.get_localized_string(70065), url=next_page, - extra=item.extra)) - elif config.get_localized_string(70032) in item.title: - bloque = scrapertools.find_single_match(data, 'name="genre">.*?(.*?)') - matches = scrapertools.find_multiple_matches(bloque, '') - for valor, titulo in matches: - if valor == "TV_SE": - continue - new_item = item.clone(title=titulo, action="listado_fa", extra="top") - new_item.url = "http://m.filmaffinity.com/%s/topgen.php?genre=%s&country=&fromyear=&toyear=&nodoc=1" \ - % (langf, valor) - if item.contentType == "movie": - new_item.url += "¬vse=1" - generos = ['1/accion.jpg', '1/animacion.jpg', '1/aventura.jpg', '1/guerra.jpg', '1/ciencia%20ficcion.jpg', - '2/Film-Noir.jpg', '1/comedia.jpg', '0/Unknown.png', '1/documental.jpg', '1/drama.jpg', - '1/fantasia.jpg', '2/Kids.jpg', '2/Suspense.jpg', '1/musical.jpg', '1/romance.jpg', - '1/terror.jpg', '1/thriler.jpg', '1/western.jpg'] - if langf != "en": - try: - new_item.thumbnail = "%s/%s" % (images_predef, generos[len(itemlist)]) - except: - new_item.thumbnail = "%s1/%s.jpg" % (images_predef, titulo.lower()) - else: - new_item.thumbnail = "%s2/%s.jpg" % (images_predef, titulo) - itemlist.append(new_item) - elif "Temas" in item.title: - bloques = scrapertools.find_multiple_matches(data, '
    (.*?)
    ') - for letra, bloque in bloques: - patron = 'href="([^"]+)">([^<]+)<.*?"badge">(\d+)' - matches = scrapertools.find_multiple_matches(bloque, patron) - extra = len(matches) + 1 - action = "" - folder = True - if config.is_xbmc(): - action = "move" - folder = False - itemlist.append(item.clone(title=letra, action=action, extra=extra, folder=folder)) - for url, titulo, numero in matches: - new_item = item.clone(action="temas_fa") - topic_id = scrapertools.find_single_match(url, "topic=(\d+)") - new_item.url = "http://www.filmaffinity.com/%s/%s&attr=all" % ( - langf, url.replace("&nodoc", "").replace("¬vse", "")) - new_item.title = titulo + " (%s)" % numero - itemlist.append(new_item) - else: - from datetime import datetime - year = datetime.now().year - for i in range(year, 1899, -1): - new_item = item.clone(title=str(i), action="listado_fa", extra="top") - genre = '' - if item.contentType == "tvshow": - genre = 'TV_SE' - new_item.url = "http://m.filmaffinity.com/%s/topgen.php?genre=%s&country=&fromyear=%s&toyear=%s&nodoc=1" \ - % (langf, genre, i, i) - if item.contentType == "movie": - new_item.url += "¬vse=1" - itemlist.append(new_item) - - return itemlist - - -def temas_fa(item): - # Movies and series by themes - itemlist = [] - - data = httptools.downloadpage(item.url).data - data = re.sub(r"\n|\r|\t| ", "", data) - data = re.sub(r"\s{2}", " ", data) - item.infoLabels['plot'] = scrapertools.find_single_match(data, '

    ([^<]+)

    ') - - patron = '
    \s*([^<]+)\s*\((\d+)\)' - matches = scrapertools.find_multiple_matches(data, patron) - for url, thumb, title, year in matches: - title = title.strip() - new_item = item.clone(action="detalles_fa", contentType="movie", extra="movie", ) - new_item.url = "http://m.filmaffinity.com/%s/movie.php?id=%s" % (langf, url) - new_item.thumbnail = thumb.replace("msmall", "large") - if not new_item.thumbnail.startswith("http"): - new_item.thumbnail = "http://www.filmaffinity.com" + new_item.thumbnail - new_item.infoLabels["year"] = year - new_item.title = title + " (%s)" % year - if re.search(r'(?i)serie de tv|\(tv\)', title): - new_item.contentType = "tvshow" - new_item.extra = "tv" - new_item.contentTitle = re.sub(r'(?i)\(serie de tv\)|\(tv\)|\(c\)', '', title) - itemlist.append(new_item) - - next_page = scrapertools.find_single_match(data, '>>') - if next_page: - if not next_page.startswith("http://www.filmaffinity.com"): - next_page = "http://www.filmaffinity.com/%s/%s" % (langf, next_page) - itemlist.append(Item(channel=item.channel, action=item.action, title=config.get_localized_string(70065), url=next_page)) - - return itemlist - - -def detalles_fa(item): - itemlist = [] - item.plot = "" - rating = item.infoLabels['rating'] - votos = item.infoLabels['votes'] - - data = httptools.downloadpage(item.url).data - data = re.sub(r"\n|\r|\t| ", "", data) - data = re.sub(r"\s{2}", " ", data) - - # The original title is extracted for possible searches in later tmdb - orig_title = scrapertools.find_single_match(data, 'itemprop="datePublished">.*?
    ([^<]+)
    ').strip() - if item.contentType == "movie": - item.infoLabels['originaltitle'] = re.sub(r"(?i)\(TV Series\)|\(S\)|\(TV\)", "", orig_title) - else: - item.infoLabels['tvshowtitle'] = re.sub(r"(?i)\(TV Series\)|\(S\)|\(TV\)", "", orig_title) - item_tmdb = item.clone() - - if item.contentType == "movie": - ob_tmdb = Tmdb(texto_buscado=item_tmdb.contentTitle, year=item_tmdb.infoLabels['year'], tipo=item_tmdb.extra, - idioma_busqueda=langt) - if not ob_tmdb.result: - ob_tmdb = Tmdb(texto_buscado=item_tmdb.infoLabels['originaltitle'], year=item_tmdb.infoLabels['year'], - tipo=item_tmdb.extra, idioma_busqueda=langt) - else: - ob_tmdb = Tmdb(texto_buscado=item_tmdb.contentTitle, tipo=item_tmdb.extra, idioma_busqueda=langt) - if not ob_tmdb.result: - ob_tmdb = Tmdb(texto_buscado=item_tmdb.infoLabels['tvshowtitle'], tipo=item_tmdb.extra, - idioma_busqueda=langt) - - if ob_tmdb.result: - ob_tmdb = Tmdb(id_Tmdb=ob_tmdb.get_id(), tipo=item_tmdb.extra, idioma_busqueda=langt) - item.infoLabels = ob_tmdb.get_infoLabels(item.infoLabels) - - # If there is no synopsis in the chosen language, search in the alternative - if not item.infoLabels["plot"]: - item.infoLabels["plot"] = ob_tmdb.get_sinopsis(idioma_alternativo=langt_alt) - - # The filmaffinity plot is concatenated to the tmdb plot if any - plot = scrapertools.find_single_match(data, '
    (.*?)
    ') - plot = plot.replace("

    ", "\n") - plot = scrapertools.decodeHtmlentities(plot).replace(" (FILMAFFINITY)", "") - if plot and (item.infoLabels['plot'] and item.infoLabels['plot'] != plot): - item.infoLabels['plot'] += " (TMDB)\n" + plot + " (FILMAFFINITY)" - elif plot and not item.infoLabels['plot']: - item.infoLabels['plot'] = plot - - # It is searched and filled with the filmaffinity info to differentiate it from tmdb - if not item.infoLabels['duration']: - duration = scrapertools.find_single_match(data, '
    (\d+)') - if duration: - item.infoLabels['duration'] = int(duration) * 60 - - if not item.infoLabels['genre']: - generos = scrapertools.find_multiple_matches(data, 'class="g-t-item">(.*?)') - genres = [] - for g in generos: - genres.append(scrapertools.htmlclean(g.strip())) - item.infoLabels['genre'] = ", ".join(genres) - - if not rating: - rating = scrapertools.find_single_match(data, 'itemprop="ratingValue".*?>([^<]+)<') - if rating: - rating = float(rating.replace(",", ".")) - elif ob_tmdb.result: - rating = float(ob_tmdb.result.get('vote_average', 0)) - item.infoLabels['rating'] = rating - - if not votos: - votos = scrapertools.find_single_match(data, 'itemprop="ratingCount".*?>([^<]+)<') - if votos == "0" and ob_tmdb.result: - votos = ob_tmdb.result.get('vote_count', '') - item.infoLabels['votes'] = votos - - if item.infoLabels['fanart']: - item.fanart = item.infoLabels['fanart'] - else: - item.fanart = scrapertools.find_single_match(data, 'Imagen Principal.*?src: "([^"]+)"') - if item.infoLabels['thumbnail']: - item.thumbnail = item.infoLabels['thumbnail'] - - if item.infoLabels['tagline']: - itemlist.append(item.clone(title="--- %s ---" % item.infoLabels['tagline'], action="")) - - title = item.contentType.replace("movie", config.get_localized_string(70283)).replace("tvshow", "serie") - itemlist.append(item.clone(action="busqueda", title=config.get_localized_string(70069) % (title, item.contentTitle))) - if item.infoLabels['originaltitle'] and item.contentTitle != item.infoLabels['originaltitle']: - itemlist.append(item.clone(action="busqueda", contentTitle=item.infoLabels['originaltitle'], - title=config.get_localized_string(70070) % item.infoLabels['originaltitle'])) - - if langt != "es" and langt != "en" and item.infoLabels["tmdb_id"]: - tmdb_lang = Tmdb(id_Tmdb=item.infoLabels["tmdb_id"], tipo=item.extra, idioma_busqueda=def_lang) - if tmdb_lang.result.get("title") and tmdb_lang.result["title"] != item.contentTitle: - tmdb_lang = tmdb_lang.result["title"] - itemlist.append(item.clone(action="busqueda", title=config.get_localized_string(70066) % tmdb_lang, - contentTitle=tmdb_lang)) - - if item.contentType == "tvshow" and ob_tmdb.result: - itemlist.append(item.clone(action="info_seasons", - title=config.get_localized_string(70067) % item.infoLabels["number_of_seasons"])) - if ob_tmdb.result: - itemlist.append(item.clone(action="reparto", title=config.get_localized_string(70071), - infoLabels={'tmdb_id': item.infoLabels['tmdb_id'], - 'mediatype': item.contentType})) - - if config.is_xbmc(): - item.contextual = True - trailer_url = scrapertools.find_single_match(data, - '' % langf) - images = {} - if ob_tmdb.result and ob_tmdb.result.get("images"): - images['tmdb'] = ob_tmdb.result["images"] - if url_img: - images['filmaffinity'] = {} - if images: - itemlist.append(item.clone(action="imagenes", title=config.get_localized_string(70316), images=images, - url=url_img, extra="menu")) - try: - if item.contentType == "movie" and item.infoLabels["year"] < 2014: - post_url = "https://theost.com/search/custom/?key=%s&year=%s&country=0&genre=0" % ( - item.infoLabels['originaltitle'].replace(" ", "+"), item.infoLabels["year"]) - url = "https://nl.hideproxy.me/includes/process.php?action=update" - post = "u=%s&proxy_formdata_server=nl&allowCookies=1&encodeURL=1&encodePage=0&stripObjects=0&stripJS=0&go=" % urllib.quote( - post_url) - while True: - response = httptools.downloadpage(url, post=post, follow_redirects=False) - if response.headers.get("location"): - url = response.headers["location"] - post = "" - else: - data_music = response.data - break - - url_album = scrapertools.find_single_match(data_music, 'album(?:s|) on request.*?href="([^"]+)"') - if url_album: - url_album = "https://nl.hideproxy.me" + url_album - itemlist.append( - item.clone(action="musica_movie", title=config.get_localized_string(70317), url=url_album, - )) - except: - pass - - token_auth = config.get_setting("token_trakt", "trakt") - if token_auth and ob_tmdb.result: - itemlist.append(item.clone(title=config.get_localized_string(70323), action="menu_trakt")) - # Actions if account is configured in FA (Vote and add / remove in lists) - mivoto = scrapertools.find_single_match(data, 'bg-my-rating.*?>\s*(\d+)') - itk = scrapertools.find_single_match(data, 'data-itk="([^"]+)"') - folder = not config.is_xbmc() - if mivoto: - item.infoLabels["userrating"] = int(mivoto) - new_item = item.clone(action="votar_fa", title=config.get_localized_string(70324) % mivoto, - itk=itk, voto=int(mivoto), folder=folder) - new_item.infoLabels["duration"] = "" - itemlist.append(new_item) - else: - if itk: - new_item = item.clone(action="votar_fa", title=config.get_localized_string(70325) % title, itk=itk, accion="votar", - folder=folder) - new_item.infoLabels["duration"] = "" - itemlist.append(new_item) - - if itk: - itk = scrapertools.find_single_match(data, 'var itk="([^"]+)"') - new_item = item.clone(action="acciones_fa", accion="lista_movie", itk=itk, - title=config.get_localized_string(70326)) - new_item.infoLabels["duration"] = "" - itemlist.append(new_item) - - # If you belong to a saga / collection - if ob_tmdb.result: - itemlist.append(item.clone(title="", action="", infoLabels={})) - if ob_tmdb.result.get("belongs_to_collection"): - new_item = item.clone(infoLabels={'mediatype': item.contentType}, action="listado_tmdb", ) - saga = ob_tmdb.result["belongs_to_collection"] - new_item.infoLabels["tmdb_id"] = saga["id"] - if saga["poster_path"]: - new_item.thumbnail = 'http://image.tmdb.org/t/p/original' + saga["poster_path"] - if saga["backdrop_path"]: - new_item.fanart = 'http://image.tmdb.org/t/p/original' + saga["backdrop_path"] - new_item.search = {'url': 'collection/%s' % saga['id'], 'language': langt} - new_item.title = config.get_localized_string(70327) % saga["name"] - itemlist.append(new_item) - - itemlist.append(item.clone(title=config.get_localized_string(70328) % title.capitalize(), action="listado_tmdb", - search={'url': '%s/%s/similar' % (item.extra, item.infoLabels['tmdb_id']), - 'language': langt, 'page': 1}, infoLabels={'mediatype': item.contentType}, - )) - itemlist.append( - item.clone(title=config.get_localized_string(70315), action="listado_tmdb", infoLabels={'mediatype': item.contentType}, - search={'url': '%s/%s/recommendations' % (item.extra, item.infoLabels['tmdb_id']), - 'language': langt, 'page': 1}, )) - - return itemlist - - -def filtro_fa(item): - logger.log() - - from datetime import datetime - list_controls = [] - valores = {} - - dict_values = None - # Default / saved values ​​are used - valores_guardados = config.get_setting("filtro_defecto_filmaf_" + item.extra, item.channel) - if valores_guardados: - dict_values = valores_guardados - - list_controls.append({'id': 'yearsdesde', 'label': config.get_localized_string(70452), 'enabled': True, - 'type': 'list', 'default': -1, 'visible': True}) - list_controls.append({'id': 'yearshasta', 'label': config.get_localized_string(70453), 'enabled': True, - 'type': 'list', 'default': -1, 'visible': True}) - list_controls[0]['lvalues'] = [] - list_controls[1]['lvalues'] = [] - valores['years'] = [] - year = datetime.now().year - for i in range(1900, year + 1): - list_controls[0]['lvalues'].append(str(i)) - list_controls[1]['lvalues'].append(str(i)) - valores['years'].append(str(i)) - list_controls[0]['lvalues'].append(config.get_localized_string(70450)) - list_controls[1]['lvalues'].append(config.get_localized_string(70450)) - valores['years'].append('') - - data = httptools.downloadpage("http://m.filmaffinity.com/%s/topgen.php" % langf).data - data = re.sub(r"\n|\r|\t| ", "", data) - data = re.sub(r"\s{2}", " ", data) - if item.contentType == "movie": - try: - bloque = scrapertools.find_single_match(data, 'name="genre">.*?(.*?)') - matches = scrapertools.find_multiple_matches(bloque, '') - if matches: - list_controls.append({'id': 'genero', 'label': config.get_localized_string(70467), 'enabled': True, - 'type': 'list', 'default': -1, 'visible': True}) - list_controls[2]['lvalues'] = [] - list_controls[2]['lvalues'].append("Todos") - valores['genero'] = [] - valores['genero'].append('') - for valor, titulo in matches: - if valor == "TV_SE": - continue - list_controls[2]['lvalues'].insert(0, titulo) - valores['genero'].insert(0, valor) - - except: - pass - - try: - bloque = scrapertools.find_single_match(data, 'name="country">.*?(.*?)') - matches = scrapertools.find_multiple_matches(bloque, '') - if matches: - list_controls.append({'id': 'pais', 'label': config.get_localized_string(70466), 'enabled': True, - 'type': 'list', 'default': -1, 'visible': True}) - list_controls[-1]['lvalues'] = [] - list_controls[-1]['lvalues'].append('Todos') - valores['pais'] = [] - valores['pais'].append('') - for valor, titulo in matches: - list_controls[-1]['lvalues'].insert(0, titulo) - valores['pais'].insert(0, valor) - except: - pass - - list_controls.append({'id': 'espacio', 'label': '', 'enabled': False, - 'type': 'label', 'default': None, 'visible': True}) - list_controls.append({'id': 'save', 'label': config.get_localized_string(70464), 'enabled': True, - 'type': 'bool', 'default': False, 'visible': True}) - - item.valores = valores - return platformtools.show_channel_settings(list_controls=list_controls, dict_values=dict_values, - caption=config.get_localized_string(70320), item=item, callback='filtrado_fa') - - -def filtrado_fa(item, values): - values_copy = values.copy() - # Save the filter to be the one loaded by default - if "save" in values and values["save"]: - values_copy.pop("save") - config.set_setting("filtro_defecto_filmaf_" + item.extra, values_copy, item.channel) - - yeard = item.valores["years"][values["yearsdesde"]] - yearh = item.valores["years"][values["yearshasta"]] - pais = item.valores["pais"][values["pais"]] - if item.contentType == "movie": - genero = item.valores["genero"][values["genero"]] - else: - genero = "TV_SE" - - item.url = 'http://m.filmaffinity.com/%s/topgen.php?genre=%s&country=%s&fromyear=%s&toyear=%s&nodoc=1' \ - % (langf, genero, pais, yeard, yearh) - if item.contentType == "movie": - item.url += "¬vse=1" - item.action = "listado_fa" - - return listado_fa(item) - - -def login_fa(): - logger.log() - - try: - user = config.get_setting("usuariofa", "tvmoviedb") - password = config.get_setting("passfa", "tvmoviedb") - userid = config.get_setting("userid", "tvmoviedb") - if user == "" or password == "": - return False, config.get_localized_string(70329) - data = httptools.downloadpage("http://m.filmaffinity.com/%s" % langf).data - if "modal-menu-user" in data and userid: - return True, "" - - post = "postback=1&rp=&username=%s&password=%s&rememberme=on" % (user, password) - data = httptools.downloadpage("https://m.filmaffinity.com/%s/account.ajax.php?action=login" % langf, post=post).data - - if "Invalid username" in data: - logger.error("Error en el login") - return False, config.get_localized_string(70330) - else: - post = "name=user-menu&url=http://m.filmaffinity.com/%s/main.php" % langf - data = httptools.downloadpage("http://m.filmaffinity.com/%s/tpl.ajax.php?action=getTemplate" % langf, - post=post).data - userid = scrapertools.find_single_match(data, 'id-user=(\d+)') - if userid: - config.set_setting("userid", userid, "tvmoviedb") - logger.log("Login correcto") - return True, "" - except: - import traceback - logger.error(traceback.format_exc()) - return False, config.get_localized_string(70331) - - -def cuenta_fa(item): - # Filmaffinity account menu - itemlist = [] - login, message = login_fa() - if not login: - itemlist.append(item.clone(action="", title=message, )) - else: - userid = config.get_setting("userid", "tvmoviedb") - itemlist.append(item.clone(action="acciones_fa", title=config.get_localized_string(70332), accion="votos", - url="http://m.filmaffinity.com/%s/user_ratings.php?id-user=%s" % (langf, userid))) - itemlist.append(item.clone(action="acciones_fa", title=config.get_localized_string(70057), accion="listas", - url="http://m.filmaffinity.com/%s/mylists.php" % langf)) - - return itemlist - - -def acciones_fa(item): - # Actions account filmaffinity, vote, view lists or add / remove from list - itemlist = [] - - if item.accion == "votos" or item.accion == "lista": - data = httptools.downloadpage(item.url).data - data = re.sub(r"\n|\r|\t| ", "", data) - data = re.sub(r"\s{2}", " ", data) - bloques = scrapertools.find_multiple_matches(data, - 'list-group-item(?:[^>]+>\s*)\s*
    \s*\((\d+)\)
    .*?(?:
    ' \ - '([^<]+)
    \s*(.*?)\s*<|
  • ).*?' - matches = scrapertools.find_multiple_matches(bloque, patron) - mivoto = scrapertools.find_single_match(bloque, 'bg-my-rating[^>]+>(?:\s*|)([^<]+)<') - for url, thumb, title, year, rating, votos in matches: - new_item = item.clone(action="detalles_fa", ) - if not url.startswith("http://m.filmaffinity"): - new_item.url = "http://m.filmaffinity.com" + url - else: - new_item.url = url - - new_item.infoLabels["year"] = year - rating = rating.replace(",", ".") - new_item.infoLabels["rating"] = float(rating) - new_item.infoLabels["votes"] = votos.replace(".", "") - if mivoto.isdigit(): - new_item.infoLabels["userrating"] = int(mivoto) - new_item.thumbnail = thumb.replace("msmall", "large") - if not new_item.thumbnail.startswith("http"): - new_item.thumbnail = "http://m.filmaffinity.com" + new_item.thumbnail - - if re.search(r'(?i)serie de tv|\(tv\)', title): - new_item.contentType = "tvshow" - new_item.extra = "tv" - new_item.title = title.strip() + " (%s) %s/]%s" % ( - year, rating, mivoto) - new_item.contentTitle = title.strip() - itemlist.append(new_item) - elif item.accion == "listas": - orderby = config.get_setting("orderfa", "tvmoviedb") - data = httptools.downloadpage(item.url).data - data = re.sub(r"\n|\r|\t| ", "", data) - data = re.sub(r"\s{2}", " ", data) - patron = 'list-group-item rip.*?href="([^"]+)".*?([^<]+).*?([^<]+)' \ - '.*?(?:
    (.*?)|)' - matches = scrapertools.find_multiple_matches(data, patron) - for url, title, content, imgs in matches: - new_item = item.clone(accion="lista", ) - if not url.startswith("http://m.filmaffinity.com"): - new_item.url = "http://m.filmaffinity.com%s&orderby=%s" % (url, orderby) - else: - new_item.url = "%s&orderby=%s" % (url, orderby) - new_item.title = title + " (%s)" % (content) - if imgs: - imagenes = scrapertools.find_multiple_matches(imgs, 'data-src="([^"]+)"') - from random import randint - random = randint(0, len(imagenes) - 1) - new_item.thumbnail = imagenes[random].replace("msmall", "large") - itemlist.append(new_item) - elif item.accion == "lista_movie": - movieid = item.url.rsplit("=", 1)[1] - url = "http://m.filmaffinity.com/%s/edtmovielists.php?movie_id=%s" % (langf, movieid) - data = httptools.downloadpage(url).data - patron = 'data-list-id="([^"]+)"(.*?)
    ([^<]+)<' - matches = scrapertools.find_multiple_matches(data, patron) - for listid, chequeo, title in matches: - new_item = item.clone(folder=not config.is_xbmc()) - new_item.infoLabels["duration"] = "" - new_item.listid = listid - if "checked" in chequeo: - new_item.title = "[COLOR %s]%s[/COLOR] %s" % ("green", u"\u0474".encode('utf-8'), title) - new_item.accion = "removeMovieFromList" - else: - new_item.title = "%s %s" % ( u"\u04FE".encode('utf-8'), title) - new_item.accion = "addMovieToList" - itemlist.append(new_item) - new_item = item.clone(action="newlist", title=config.get_localized_string(70333), ) - new_item.infoLabels["duration"] = "" - itemlist.append(new_item) - else: - url = "http://filmaffinity.com/%s/movieslist.ajax.php" % langf - movieid = item.url.rsplit("=", 1)[1] - post = "action=%s&listId=%s&movieId=%s&itk=%s" % (item.accion, item.listid, movieid, item.itk) - data = jsontools.load(httptools.downloadpage(url, post=post).data) - if not item.folder: - import xbmc - return xbmc.executebuiltin("Container.Refresh") - else: - if data["result"] == 0: - title = config.get_localized_string(70334) - else: - title = config.get_localized_string(70335) - itemlist.append(item.clone(action="", title=title)) - - return itemlist - - -def votar_fa(item): - # Window to select the vote - logger.log() - - list_controls = [] - valores = {} - dict_values = None - if item.voto: - dict_values = {'voto': item.voto} - list_controls.append({'id': 'voto', 'label': config.get_localized_string(70468), 'enabled': True, - 'type': 'list', 'default': 0, 'visible': True}) - list_controls[0]['lvalues'] = ['No vista'] - valores['voto'] = ["-1"] - for i in range(1, 11): - list_controls[0]['lvalues'].append(str(i)) - valores['voto'].append(i) - - item.valores = valores - return platformtools.show_channel_settings(list_controls=list_controls, dict_values=dict_values, - caption=config.get_localized_string(70336) % item.contentTitle, item=item, - callback='callback_voto') - - -def callback_voto(item, values): - item.voto = item.valores["voto"][values["voto"]] - item.action = "acciones_fa" - movieid = item.url.rsplit("=", 1)[1] - post = "id=%s&rating=%s&itk=%s&action=rate" % (movieid, item.voto, item.itk) - data = jsontools.load(httptools.downloadpage("http://filmaffinity.com/%s/ratingajax.php" % langf, post=post).data) - - if not item.folder: - import xbmc - return xbmc.executebuiltin("Container.Refresh") - else: - if data["result"] == 0: - title = config.get_localized_string(70337) - else: - title = config.get_localized_string(70335) - itemlist.append(item.clone(action="", title=title)) - return itemlist - - -def newlist(item): - # Creation of new list in filmaffinity - itemlist = [] - if item.accion == "lista": - location = httptools.downloadpage(item.url, only_headers=True).headers["location"] - data = httptools.downloadpage("http://m.filmaffinity.com" + location).data - itemlist.append(item.clone(action="", title=config.get_localized_string(70338))) - else: - url = "http://m.filmaffinity.com/%s/addlist.php?rp=%s" % (langf, item.url) - data = httptools.downloadpage(url).data - data = re.sub(r"\n|\r|\t| |\s{2}", "", data) - - patron = 'data-list-id="[^"]+" href="([^"]+)"><[^>]+>
    ' \ - '([^<]+)
    ]+>
    ' - matches = scrapertools.find_multiple_matches(data, patron) - for scrapedurl, title in matches: - scrapedurl = "http://m.filmaffinity.com" + scrapedurl - itemlist.append(item.clone(title=title, url=scrapedurl, accion="lista")) - - return itemlist +# def list_fa(item): +# # Filmaffinity main listing method +# itemlist = [] + +# # Listings with pagination per post +# if item.args == "top": +# if item.page_fa: +# post = "from=%s" % item.page_fa +# data = httptools.downloadpage(item.url, post=post).data +# if item.total > item.page_fa: +# item.page_fa += 30 +# else: +# item.page_fa = "" +# else: +# item.page_fa = 30 +# data = httptools.downloadpage(item.url).data +# item.total = int(scrapertools.find_single_match(data, 'tmResCount\s*=\s*(\d+)')) +# if item.total <= item.page_fa: +# item.page_fa = "" + +# else: +# data = httptools.downloadpage(item.url).data +# data = re.sub(r"\n|\r|\t| ", "", data) +# data = re.sub(r"\s{2}", " ", data) + +# votaciones = [] +# # If it is the premiere section, change the structure of the scraper + +# if item.args == "estrenos": +# patron = r'fa-calendar-alt">[^>]+>([^<]+)<(.*?)(?:id="main-wrapper-rdcat|class="np-cat-wrapper")' +# bloks = scrapertools.find_multiple_matches(data, patron) +# for title, block in bloks: +# itemlist.append(item.clone(title=title, action='', )) + +# patron = r'href="([^"]+)" title="([^"]+)">]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>\s*(\d+)[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>([^<]+)[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>\s*(\d+)[^>]+>[^>]+>[^>]+>[^>]+>([^<]+)[^>]+>[^>]+>([^<]+)' +# matches = match(block, patron=patron).matches +# # matches = scrapertools.find_multiple_matches(bloque, patron) +# for url, title, thumb, duration, rating, year, genre, plot in matches: +# title = title.strip() +# new_item = item.clone(action="details_fa", contentType="movie", args="movie", contentTitle=title) +# if not url.startswith("http://m.filmaffinity"): new_item.url = "http://m.filmaffinity.com" + url +# else: new_item.url = url + +# new_item.thumbnail = thumb.replace("msmall", "large") +# if not new_item.thumbnail.startswith("http"): new_item.thumbnail = "http://m.filmaffinity.com" + new_item.thumbnail + +# new_item.title = typo(title,'bold') + typo(rating,'_ [] color kod bold') +# new_item.infoLabels['duration'] = int(duration) * 60 +# new_item.infoLabels['rating'] = float(rating.replace(",", ".")) +# new_item.infoLabels['year'] = year +# new_item.infoLabels['genres'] = [genre] +# itemlist.append(new_item) +# else: +# patron = '(?:|)' \ +# '.*?(?:data-src="([^"]+)"|src="((?!/images/empty.gif)[^"]+)").*?' \ +# '
    ' \ +# '([^<]+)
    \s*(.*?)\s*<|)' +# matches = scrapertools.find_multiple_matches(data, patron) +# for url, url2, thumb, thumb2, title, year, rating, votos in matches: +# title = title.strip() +# new_item = item.clone(action="details_fa", args="movie") +# if not url: +# url = url2 +# if not url.startswith("http://m.filmaffinity"): +# new_item.url = "http://m.filmaffinity.com" + url +# else: +# new_item.url = url + +# if not thumb: +# thumb = thumb2 +# new_item.thumbnail = thumb.replace("msmall", "large") +# if not new_item.thumbnail.startswith("http"): +# new_item.thumbnail = "http://m.filmaffinity.com" + new_item.thumbnail + +# new_item.title = title.replace("(Serie de TV)", "").replace("(TV)", "") + " (%s) %s" \ +# % (year, rating) +# new_item.contentTitle = re.sub(r'(?i)\(serie de tv\)|\(tv\)|\(c\)', '', title) +# if re.search(r'(?i)serie de tv|\(tv\)', title): +# new_item.contentType = "tvshow" +# new_item.args = "tv" +# new_item.infoLabels["tvshowtitle"] = new_item.contentTitle + +# new_item.infoLabels['year'] = year +# votaciones.append([rating, votos]) +# if rating: +# new_item.infoLabels['rating'] = float(rating.replace(",", ".")) +# new_item.infoLabels['votes'] = votos +# itemlist.append(new_item) + +# if len(itemlist) < 31: +# from core import tmdb +# tmdb.set_infoLabels_itemlist(itemlist, True) +# for i, it in enumerate(itemlist): +# try: +# it.infoLabels['votes'] = votaciones[i][1] +# it.infoLabels['rating'] = float(votaciones[i][0].replace(",", ".")) +# except: +# pass + +# next_page = scrapertools.find_single_match(data, 'aria-label="Next" href="([^"]+)"') +# if next_page: +# if not next_page.startswith("http://m.filmaffinity"): +# next_page = "http://m.filmaffinity.com" + next_page + +# itemlist.append(Item(channel=item.channel, action=item.action, title=config.get_localized_string(70065), url=next_page, +# args=item.args)) +# elif item.page_fa: +# itemlist.append(item.clone(title=config.get_localized_string(70065), )) +# return itemlist + + +# def indices_fa(item): +# # Indexes by gender, year, themes and sagas / collections +# itemlist = [] +# # dbg() +# if item.url: +# data = match(item).data +# # data = httptools.downloadpage(item.url).data +# # data = re.sub(r"\n|\r|\t| ", "", data) +# # data = re.sub(r"\s{2}", " ", data) +# if "sagas" in item.args: +# matches = match(data, patron=r'
  • [^>]+>([^<]+)<.*?src="([^"]+)".*?"count-movies">([^<]+)<').matches +# # patron = '
  • .*?href="([^"]+)".*?group-name">([^<]+)<.*?src="([^"]+)".*?"count-movies">([^<]+)<' +# # matches = scrapertools.find_multiple_matches(data, patron) +# for url, title, thumbnail, info in matches: +# new_item = item.clone(action="list_fa") +# if not url.startswith("http://www.filmaffinity"): new_item.url = "http://m.filmaffinity.com" + url +# else: new_item.url = url.replace("www.filmaffinity.com", "m.filmaffinity.com") + +# new_item.thumbnail = thumbnail.replace("mmed", "large") +# new_item.title = typo(title.strip(),'bold') + typo(info, '_ []') +# itemlist.append(new_item) + +# next_page = match(data, patron = r'>>').match# scrapertools.find_single_match(data, '>>') +# if next_page: +# if not next_page.startswith("http://www.filmaffinity.com"): next_page = "http://www.filmaffinity.com" + next_page +# itemlist.append(Item(channel=item.channel, action=item.action, title=typo(config.get_localized_string(30992), 'color kod bold'), url=next_page, args=item.args)) +# elif config.get_localized_string(70032) in item.title: +# bloque = scrapertools.find_single_match(data, '="genre">.*?(.*?)') +# matches = scrapertools.find_multiple_matches(bloque, '') +# for valor, titulo in matches: +# if valor == "TV_SE": +# continue +# new_item = item.clone(title=titulo, action="list_fa", args="top") +# new_item.url = "http://m.filmaffinity.com/%s/topgen.php?genre=%s&country=&fromyear=&toyear=&nodoc=1" % (langf, valor) +# if item.contentType == "movie": +# new_item.url += "¬vse=1" +# # generos = ['1/accion.jpg', '1/animacion.jpg', '1/aventura.jpg', '1/guerra.jpg', '1/ciencia%20ficcion.jpg', +# # '2/Film-Noir.jpg', '1/comedia.jpg', '0/Unknown.png', '1/documental.jpg', '1/drama.jpg', +# # '1/fantasia.jpg', '2/Kids.jpg', '2/Suspense.jpg', '1/musical.jpg', '1/romance.jpg', +# # '1/terror.jpg', '1/thriler.jpg', '1/western.jpg'] +# # if langf != "en": +# # try: +# # new_item.thumbnail = "%s/%s" % (images_predef, generos[len(itemlist)]) +# # except: +# # new_item.thumbnail = "%s1/%s.jpg" % (images_predef, titulo.lower()) +# # else: +# # new_item.thumbnail = "%s2/%s.jpg" % (images_predef, titulo) +# itemlist.append(new_item) +# elif "Temas" in item.title: +# bloques = scrapertools.find_multiple_matches(data, '
    (.*?)
    ') +# for letra, bloque in bloques: +# patron = 'href="([^"]+)">([^<]+)<.*?"badge">(\d+)' +# matches = scrapertools.find_multiple_matches(bloque, patron) +# args = len(matches) + 1 +# action = "" +# folder = True +# if config.is_xbmc(): +# action = "move" +# folder = False +# itemlist.append(item.clone(title=letra, action=action, args=args, folder=folder)) +# for url, titulo, numero in matches: +# new_item = item.clone(action="temas_fa") +# topic_id = scrapertools.find_single_match(url, r"topic=(\d+)") +# new_item.url = "http://www.filmaffinity.com/%s/%s&attr=all" % ( +# langf, url.replace("&nodoc", "").replace("¬vse", "")) +# new_item.title = titulo + " (%s)" % numero +# itemlist.append(new_item) +# itemlist = thumb(itemlist) +# else: +# from datetime import datetime +# year = datetime.now().year +# for i in range(year, 1899, -1): +# new_item = item.clone(title=str(i), action="list_fa", args="top") +# genre = '' +# if item.contentType == "tvshow": genre = 'TV_SE' +# new_item.url = "http://m.filmaffinity.com/%s/topgen.php?genre=%s&country=&fromyear=%s&toyear=%s&nodoc=1" % (langf, genre, i, i) +# if item.contentType == "movie": new_item.url += "¬vse=1" +# itemlist.append(new_item) + +# return itemlist + + +# def temas_fa(item): +# # Movies and series by themes +# itemlist = [] + +# data = httptools.downloadpage(item.url).data +# data = re.sub(r"\n|\r|\t| ", "", data) +# data = re.sub(r"\s{2}", " ", data) +# item.infoLabels['plot'] = scrapertools.find_single_match(data, '

    ([^<]+)

    ') + +# patron = '
    \s*([^<]+)\s*\((\d+)\)' +# matches = scrapertools.find_multiple_matches(data, patron) +# for url, thumb, title, year in matches: +# title = title.strip() +# new_item = item.clone(action="details_fa", contentType="movie", args="movie", ) +# new_item.url = "http://m.filmaffinity.com/%s/movie.php?id=%s" % (langf, url) +# new_item.thumbnail = thumb.replace("msmall", "large") +# if not new_item.thumbnail.startswith("http"): +# new_item.thumbnail = "http://www.filmaffinity.com" + new_item.thumbnail +# new_item.infoLabels["year"] = year +# new_item.title = title + " (%s)" % year +# if re.search(r'(?i)serie de tv|\(tv\)', title): +# new_item.contentType = "tvshow" +# new_item.args = "tv" +# new_item.contentTitle = re.sub(r'(?i)\(serie de tv\)|\(tv\)|\(c\)', '', title) +# itemlist.append(new_item) + +# next_page = scrapertools.find_single_match(data, '>>') +# if next_page: +# if not next_page.startswith("http://www.filmaffinity.com"): +# next_page = "http://www.filmaffinity.com/%s/%s" % (langf, next_page) +# itemlist.append(Item(channel=item.channel, action=item.action, title=config.get_localized_string(70065), url=next_page)) + +# return itemlist + + +# def details_fa(item): +# itemlist = [] +# item.plot = "" +# rating = item.infoLabels['rating'] +# votos = item.infoLabels['votes'] + +# data = httptools.downloadpage(item.url).data +# data = re.sub(r"\n|\r|\t| ", "", data) +# data = re.sub(r"\s{2}", " ", data) + +# # The original title is argscted for possible searches in later tmdb +# orig_title = scrapertools.find_single_match(data, 'itemprop="datePublished">.*?
    ([^<]+)
    ').strip() +# if item.contentType == "movie": +# item.infoLabels['originaltitle'] = re.sub(r"(?i)\(TV Series\)|\(S\)|\(TV\)", "", orig_title) +# else: +# item.infoLabels['tvshowtitle'] = re.sub(r"(?i)\(TV Series\)|\(S\)|\(TV\)", "", orig_title) +# item_tmdb = item.clone() + +# if item.contentType == "movie": +# ob_tmdb = Tmdb(text_buscado=item_tmdb.contentTitle, year=item_tmdb.infoLabels['year'], tipo=item_tmdb.args, +# idioma_searching=langt) +# if not ob_tmdb.result: +# ob_tmdb = Tmdb(text_buscado=item_tmdb.infoLabels['originaltitle'], year=item_tmdb.infoLabels['year'], +# tipo=item_tmdb.args, idioma_searching=langt) +# else: +# ob_tmdb = Tmdb(text_buscado=item_tmdb.contentTitle, tipo=item_tmdb.args, idioma_searching=langt) +# if not ob_tmdb.result: +# ob_tmdb = Tmdb(text_buscado=item_tmdb.infoLabels['tvshowtitle'], tipo=item_tmdb.args, +# idioma_searching=langt) + +# if ob_tmdb.result: +# ob_tmdb = Tmdb(id_Tmdb=ob_tmdb.get_id(), tipo=item_tmdb.args, idioma_searching=langt) +# item.infoLabels = ob_tmdb.get_infoLabels(item.infoLabels) + +# # If there is no synopsis in the chosen language, search in the alternative +# if not item.infoLabels["plot"]: +# item.infoLabels["plot"] = ob_tmdb.get_sinopsis(idioma_alternativo=langt_alt) + +# # The filmaffinity plot is concatenated to the tmdb plot if any +# plot = scrapertools.find_single_match(data, '
    (.*?)
    ') +# plot = plot.replace("

    ", "\n") +# plot = scrapertools.decodeHtmlentities(plot).replace(" (FILMAFFINITY)", "") +# if plot and (item.infoLabels['plot'] and item.infoLabels['plot'] != plot): +# item.infoLabels['plot'] += " (TMDB)\n" + plot + " (FILMAFFINITY)" +# elif plot and not item.infoLabels['plot']: +# item.infoLabels['plot'] = plot + +# # It is searched and filled with the filmaffinity info to differentiate it from tmdb +# if not item.infoLabels['duration']: +# duration = scrapertools.find_single_match(data, '
    (\d+)') +# if duration: +# item.infoLabels['duration'] = int(duration) * 60 + +# if not item.infoLabels['genre']: +# generos = scrapertools.find_multiple_matches(data, 'class="g-t-item">(.*?)') +# genres = [] +# for g in generos: +# genres.append(scrapertools.htmlclean(g.strip())) +# item.infoLabels['genre'] = ", ".join(genres) + +# if not rating: +# rating = scrapertools.find_single_match(data, 'itemprop="ratingValue".*?>([^<]+)<') +# if rating: +# rating = float(rating.replace(",", ".")) +# elif ob_tmdb.result: +# rating = float(ob_tmdb.result.get('vote_average', 0)) +# item.infoLabels['rating'] = rating + +# if not votos: +# votos = scrapertools.find_single_match(data, 'itemprop="ratingCount".*?>([^<]+)<') +# if votos == "0" and ob_tmdb.result: +# votos = ob_tmdb.result.get('vote_count', '') +# item.infoLabels['votes'] = votos + +# if item.infoLabels['fanart']: +# item.fanart = item.infoLabels['fanart'] +# else: +# item.fanart = scrapertools.find_single_match(data, 'Imagen Principal.*?src: "([^"]+)"') +# if item.infoLabels['thumbnail']: +# item.thumbnail = item.infoLabels['thumbnail'] + +# if item.infoLabels['tagline']: +# itemlist.append(item.clone(title="--- %s ---" % item.infoLabels['tagline'], action="")) + +# title = item.contentType.replace("movie", config.get_localized_string(70283)).replace("tvshow", "serie") +# itemlist.append(item.clone(action="searching", title=config.get_localized_string(70069) % (title, item.contentTitle))) +# if item.infoLabels['originaltitle'] and item.contentTitle != item.infoLabels['originaltitle']: +# itemlist.append(item.clone(action="searching", contentTitle=item.infoLabels['originaltitle'], +# title=config.get_localized_string(70070) % item.infoLabels['originaltitle'])) + +# if langt != "es" and langt != "en" and item.infoLabels["tmdb_id"]: +# tmdb_lang = Tmdb(id_Tmdb=item.infoLabels["tmdb_id"], tipo=item.args, idioma_searching=def_lang) +# if tmdb_lang.result.get("title") and tmdb_lang.result["title"] != item.contentTitle: +# tmdb_lang = tmdb_lang.result["title"] +# itemlist.append(item.clone(action="searching", title=config.get_localized_string(70066) % tmdb_lang, +# contentTitle=tmdb_lang)) + +# if item.contentType == "tvshow" and ob_tmdb.result: +# itemlist.append(item.clone(action="info_seasons", +# title=config.get_localized_string(70067) % item.infoLabels["number_of_seasons"])) +# if ob_tmdb.result: +# itemlist.append(item.clone(action="distribution", title=config.get_localized_string(70071), +# infoLabels={'tmdb_id': item.infoLabels['tmdb_id'], +# 'mediatype': item.contentType})) + +# if config.is_xbmc(): +# item.contextual = True +# trailer_url = scrapertools.find_single_match(data, +# '' % langf) +# images = {} +# if ob_tmdb.result and ob_tmdb.result.get("images"): +# images['tmdb'] = ob_tmdb.result["images"] +# if url_img: +# images['filmaffinity'] = {} +# if images: +# itemlist.append(item.clone(action="imagenes", title=config.get_localized_string(70316), images=images, +# url=url_img, args="menu")) +# try: +# if item.contentType == "movie" and item.infoLabels["year"] < 2014: +# post_url = "https://theost.com/search/custom/?key=%s&year=%s&country=0&genre=0" % ( +# item.infoLabels['originaltitle'].replace(" ", "+"), item.infoLabels["year"]) +# url = "https://nl.hideproxy.me/includes/process.php?action=update" +# post = "u=%s&proxy_formdata_server=nl&allowCookies=1&encodeURL=1&encodePage=0&stripObjects=0&stripJS=0&go=" % urllib.quote( +# post_url) +# while True: +# response = httptools.downloadpage(url, post=post, follow_redirects=False) +# if response.headers.get("location"): +# url = response.headers["location"] +# post = "" +# else: +# data_music = response.data +# break + +# url_album = scrapertools.find_single_match(data_music, 'album(?:s|) on request.*?href="([^"]+)"') +# if url_album: +# url_album = "https://nl.hideproxy.me" + url_album +# itemlist.append( +# item.clone(action="musica_movie", title=config.get_localized_string(70317), url=url_album, +# )) +# except: +# pass + +# token_auth = config.get_setting("token_trakt", "trakt") +# if token_auth and ob_tmdb.result: +# itemlist.append(item.clone(title=config.get_localized_string(70323), action="menu_trakt")) +# # Actions if account is configured in FA (Vote and add / remove in lists) +# mivoto = scrapertools.find_single_match(data, 'bg-my-rating.*?>\s*(\d+)') +# itk = scrapertools.find_single_match(data, 'data-itk="([^"]+)"') +# folder = not config.is_xbmc() +# if mivoto: +# item.infoLabels["userrating"] = int(mivoto) +# new_item = item.clone(action="votar_fa", title=config.get_localized_string(70324) % mivoto, +# itk=itk, voto=int(mivoto), folder=folder) +# new_item.infoLabels["duration"] = "" +# itemlist.append(new_item) +# else: +# if itk: +# new_item = item.clone(action="votar_fa", title=config.get_localized_string(70325) % title, itk=itk, accion="votar", +# folder=folder) +# new_item.infoLabels["duration"] = "" +# itemlist.append(new_item) + +# if itk: +# itk = scrapertools.find_single_match(data, 'var itk="([^"]+)"') +# new_item = item.clone(action="acciones_fa", accion="lista_movie", itk=itk, +# title=config.get_localized_string(70326)) +# new_item.infoLabels["duration"] = "" +# itemlist.append(new_item) + +# # If you belong to a saga / collection +# if ob_tmdb.result: +# itemlist.append(item.clone(title="", action="", infoLabels={})) +# if ob_tmdb.result.get("belongs_to_collection"): +# new_item = item.clone(action="list_tmdb", ) +# saga = ob_tmdb.result["belongs_to_collection"] +# new_item.infoLabels["tmdb_id"] = saga["id"] +# if saga["poster_path"]: +# new_item.thumbnail = 'http://image.tmdb.org/t/p/original' + saga["poster_path"] +# if saga["backdrop_path"]: +# new_item.fanart = 'http://image.tmdb.org/t/p/original' + saga["backdrop_path"] +# new_item.search = {'url': 'collection/%s' % saga['id'], 'language': langt} +# new_item.title = config.get_localized_string(70327) % saga["name"] +# itemlist.append(new_item) + +# itemlist.append(item.clone(title=config.get_localized_string(70328) % title.capitalize(), action="list_tmdb", +# search={'url': '%s/%s/similar' % (item.args, item.infoLabels['tmdb_id']), +# 'language': langt, 'page': 1}, +# )) +# itemlist.append( +# item.clone(title=config.get_localized_string(70315), action="list_tmdb", +# search={'url': '%s/%s/recommendations' % (item.args, item.infoLabels['tmdb_id']), +# 'language': langt, 'page': 1}, )) + +# return itemlist + + +# def filter_fa(item): +# log() + +# from datetime import datetime +# list_controls = [] +# valores = {} + +# dict_values = None +# # Default / saved values ​​are used +# saved_values = config.get_setting("default_filter_filmaf_" + item.args, item.channel) +# if saved_values: +# dict_values = saved_values + +# list_controls.append({'id': 'yearsdesde', 'label': config.get_localized_string(70452), 'enabled': True, +# 'type': 'list', 'default': -1, 'visible': True}) +# list_controls.append({'id': 'yearshasta', 'label': config.get_localized_string(70453), 'enabled': True, +# 'type': 'list', 'default': -1, 'visible': True}) +# list_controls[0]['lvalues'] = [] +# list_controls[1]['lvalues'] = [] +# valores['years'] = [] +# year = datetime.now().year +# for i in range(1900, year + 1): +# list_controls[0]['lvalues'].append(str(i)) +# list_controls[1]['lvalues'].append(str(i)) +# valores['years'].append(str(i)) +# list_controls[0]['lvalues'].append(config.get_localized_string(70450)) +# list_controls[1]['lvalues'].append(config.get_localized_string(70450)) +# valores['years'].append('') + +# data = httptools.downloadpage("http://m.filmaffinity.com/%s/topgen.php" % langf).data +# data = re.sub(r"\n|\r|\t| ", "", data) +# data = re.sub(r"\s{2}", " ", data) +# if item.contentType == "movie": +# try: +# bloque = scrapertools.find_single_match(data, 'name="genre">.*?(.*?)') +# matches = scrapertools.find_multiple_matches(bloque, '') +# if matches: +# list_controls.append({'id': 'genero', 'label': config.get_localized_string(70467), 'enabled': True, +# 'type': 'list', 'default': -1, 'visible': True}) +# list_controls[2]['lvalues'] = [] +# list_controls[2]['lvalues'].append("Todos") +# valores['genero'] = [] +# valores['genero'].append('') +# for valor, titulo in matches: +# if valor == "TV_SE": +# continue +# list_controls[2]['lvalues'].insert(0, titulo) +# valores['genero'].insert(0, valor) + +# except: +# pass + +# try: +# bloque = scrapertools.find_single_match(data, 'name="country">.*?(.*?)') +# matches = scrapertools.find_multiple_matches(bloque, '') +# if matches: +# list_controls.append({'id': 'pais', 'label': config.get_localized_string(70466), 'enabled': True, +# 'type': 'list', 'default': -1, 'visible': True}) +# list_controls[-1]['lvalues'] = [] +# list_controls[-1]['lvalues'].append('Todos') +# valores['pais'] = [] +# valores['pais'].append('') +# for valor, titulo in matches: +# list_controls[-1]['lvalues'].insert(0, titulo) +# valores['pais'].insert(0, valor) +# except: +# pass + +# list_controls.append({'id': 'espacio', 'label': '', 'enabled': False, +# 'type': 'label', 'default': None, 'visible': True}) +# list_controls.append({'id': 'save', 'label': config.get_localized_string(70464), 'enabled': True, +# 'type': 'bool', 'default': False, 'visible': True}) + +# item.valores = valores +# return platformtools.show_channel_settings(list_controls=list_controls, dict_values=dict_values, +# caption=config.get_localized_string(70320), item=item, callback='filtered_fa') + + +# def filtered_fa(item, values): +# values_copy = values.copy() +# # Save the filter to be the one loaded by default +# if "save" in values and values["save"]: +# values_copy.pop("save") +# config.set_setting("default_filter_filmaf_" + item.args, values_copy, item.channel) + +# yeard = item.valores["years"][values["yearsdesde"]] +# yearh = item.valores["years"][values["yearshasta"]] +# pais = item.valores["pais"][values["pais"]] +# if item.contentType == "movie": +# genero = item.valores["genero"][values["genero"]] +# else: +# genero = "TV_SE" + +# item.url = 'http://m.filmaffinity.com/%s/topgen.php?genre=%s&country=%s&fromyear=%s&toyear=%s&nodoc=1' \ +# % (langf, genero, pais, yeard, yearh) +# if item.contentType == "movie": +# item.url += "¬vse=1" +# item.action = "list_fa" + +# return list_fa(item) + + +# def login_fa(): +# log() + +# try: +# user = config.get_setting("usuariofa", "tvmoviedb") +# password = config.get_setting("passfa", "tvmoviedb") +# userid = config.get_setting("userid", "tvmoviedb") +# if user == "" or password == "": +# return False, config.get_localized_string(70329) +# data = httptools.downloadpage("http://m.filmaffinity.com/%s" % langf).data +# if "modal-menu-user" in data and userid: +# return True, "" + +# post = "postback=1&rp=&username=%s&password=%s&rememberme=on" % (user, password) +# data = httptools.downloadpage("https://m.filmaffinity.com/%s/account.ajax.php?action=login" % langf, post=post).data + +# if "Invalid username" in data: +# error("Error en el login") +# return False, config.get_localized_string(70330) +# else: +# post = "name=user-menu&url=http://m.filmaffinity.com/%s/main.php" % langf +# data = httptools.downloadpage("http://m.filmaffinity.com/%s/tpl.ajax.php?action=getTemplate" % langf, +# post=post).data +# userid = scrapertools.find_single_match(data, 'id-user=(\d+)') +# if userid: +# config.set_setting("userid", userid, "tvmoviedb") +# log("Login correcto") +# return True, "" +# except: +# import traceback +# error(traceback.format_exc()) +# return False, config.get_localized_string(70331) + + +# def cuenta_fa(item): +# # Filmaffinity account menu +# itemlist = [] +# login, message = login_fa() +# if not login: +# itemlist.append(item.clone(action="", title=message, )) +# else: +# userid = config.get_setting("userid", "tvmoviedb") +# itemlist.append(item.clone(action="acciones_fa", title=config.get_localized_string(70332), accion="votos", +# url="http://m.filmaffinity.com/%s/user_ratings.php?id-user=%s" % (langf, userid))) +# itemlist.append(item.clone(action="acciones_fa", title=config.get_localized_string(70057), accion="listas", +# url="http://m.filmaffinity.com/%s/mylists.php" % langf)) + +# return itemlist + + +# def acciones_fa(item): +# # Actions account filmaffinity, vote, view lists or add / remove from list +# itemlist = [] + +# if item.accion == "votos" or item.accion == "lista": +# data = httptools.downloadpage(item.url).data +# data = re.sub(r"\n|\r|\t| ", "", data) +# data = re.sub(r"\s{2}", " ", data) +# bloques = scrapertools.find_multiple_matches(data, +# 'list-group-item(?:[^>]+>\s*)\s*
    \s*\((\d+)\)
    .*?(?:
    ' \ +# '([^<]+)
    \s*(.*?)\s*<|
  • ).*?' +# matches = scrapertools.find_multiple_matches(bloque, patron) +# mivoto = scrapertools.find_single_match(bloque, 'bg-my-rating[^>]+>(?:\s*|)([^<]+)<') +# for url, thumb, title, year, rating, votos in matches: +# new_item = item.clone(action="details_fa", ) +# if not url.startswith("http://m.filmaffinity"): +# new_item.url = "http://m.filmaffinity.com" + url +# else: +# new_item.url = url + +# new_item.infoLabels["year"] = year +# rating = rating.replace(",", ".") +# new_item.infoLabels["rating"] = float(rating) +# new_item.infoLabels["votes"] = votos.replace(".", "") +# if mivoto.isdigit(): +# new_item.infoLabels["userrating"] = int(mivoto) +# new_item.thumbnail = thumb.replace("msmall", "large") +# if not new_item.thumbnail.startswith("http"): +# new_item.thumbnail = "http://m.filmaffinity.com" + new_item.thumbnail + +# if re.search(r'(?i)serie de tv|\(tv\)', title): +# new_item.contentType = "tvshow" +# new_item.args = "tv" +# new_item.title = title.strip() + " (%s) %s/]%s" % ( +# year, rating, mivoto) +# new_item.contentTitle = title.strip() +# itemlist.append(new_item) +# elif item.accion == "listas": +# orderby = config.get_setting("orderfa", "tvmoviedb") +# data = httptools.downloadpage(item.url).data +# data = re.sub(r"\n|\r|\t| ", "", data) +# data = re.sub(r"\s{2}", " ", data) +# patron = 'list-group-item rip.*?href="([^"]+)".*?([^<]+).*?([^<]+)' \ +# '.*?(?:
    (.*?)|)' +# matches = scrapertools.find_multiple_matches(data, patron) +# for url, title, content, imgs in matches: +# new_item = item.clone(accion="lista", ) +# if not url.startswith("http://m.filmaffinity.com"): +# new_item.url = "http://m.filmaffinity.com%s&orderby=%s" % (url, orderby) +# else: +# new_item.url = "%s&orderby=%s" % (url, orderby) +# new_item.title = title + " (%s)" % (content) +# if imgs: +# imagenes = scrapertools.find_multiple_matches(imgs, 'data-src="([^"]+)"') +# from random import randint +# random = randint(0, len(imagenes) - 1) +# new_item.thumbnail = imagenes[random].replace("msmall", "large") +# itemlist.append(new_item) +# elif item.accion == "lista_movie": +# movieid = item.url.rsplit("=", 1)[1] +# url = "http://m.filmaffinity.com/%s/edtmovielists.php?movie_id=%s" % (langf, movieid) +# data = httptools.downloadpage(url).data +# patron = 'data-list-id="([^"]+)"(.*?)
    ([^<]+)<' +# matches = scrapertools.find_multiple_matches(data, patron) +# for listid, chequeo, title in matches: +# new_item = item.clone(folder=not config.is_xbmc()) +# new_item.infoLabels["duration"] = "" +# new_item.listid = listid +# if "checked" in chequeo: +# new_item.title = "[COLOR %s]%s[/COLOR] %s" % ("green", u"\u0474".encode('utf-8'), title) +# new_item.accion = "removeMovieFromList" +# else: +# new_item.title = "%s %s" % ( u"\u04FE".encode('utf-8'), title) +# new_item.accion = "addMovieToList" +# itemlist.append(new_item) +# new_item = item.clone(action="newlist", title=config.get_localized_string(70333), ) +# new_item.infoLabels["duration"] = "" +# itemlist.append(new_item) +# else: +# url = "http://filmaffinity.com/%s/movieslist.ajax.php" % langf +# movieid = item.url.rsplit("=", 1)[1] +# post = "action=%s&listId=%s&movieId=%s&itk=%s" % (item.accion, item.listid, movieid, item.itk) +# data = jsontools.load(httptools.downloadpage(url, post=post).data) +# if not item.folder: +# import xbmc +# return xbmc.executebuiltin("Container.Refresh") +# else: +# if data["result"] == 0: +# title = config.get_localized_string(70334) +# else: +# title = config.get_localized_string(70335) +# itemlist.append(item.clone(action="", title=title)) + +# return itemlist + + +# def votar_fa(item): +# # Window to select the vote +# log() + +# list_controls = [] +# valores = {} +# dict_values = None +# if item.voto: +# dict_values = {'voto': item.voto} +# list_controls.append({'id': 'voto', 'label': config.get_localized_string(70468), 'enabled': True, +# 'type': 'list', 'default': 0, 'visible': True}) +# list_controls[0]['lvalues'] = ['No vista'] +# valores['voto'] = ["-1"] +# for i in range(1, 11): +# list_controls[0]['lvalues'].append(str(i)) +# valores['voto'].append(i) + +# item.valores = valores +# return platformtools.show_channel_settings(list_controls=list_controls, dict_values=dict_values, +# caption=config.get_localized_string(70336) % item.contentTitle, item=item, +# callback='callback_voto') + + +# def callback_voto(item, values): +# item.voto = item.valores["voto"][values["voto"]] +# item.action = "acciones_fa" +# movieid = item.url.rsplit("=", 1)[1] +# post = "id=%s&rating=%s&itk=%s&action=rate" % (movieid, item.voto, item.itk) +# data = jsontools.load(httptools.downloadpage("http://filmaffinity.com/%s/ratingajax.php" % langf, post=post).data) + +# if not item.folder: +# import xbmc +# return xbmc.executebuiltin("Container.Refresh") +# else: +# if data["result"] == 0: +# title = config.get_localized_string(70337) +# else: +# title = config.get_localized_string(70335) +# itemlist.append(item.clone(action="", title=title)) +# return itemlist + + +# def newlist(item): +# # Creation of new list in filmaffinity +# itemlist = [] +# if item.accion == "lista": +# location = httptools.downloadpage(item.url, only_headers=True).headers["location"] +# data = httptools.downloadpage("http://m.filmaffinity.com" + location).data +# itemlist.append(item.clone(action="", title=config.get_localized_string(70338))) +# else: +# url = "http://m.filmaffinity.com/%s/addlist.php?rp=%s" % (langf, item.url) +# data = httptools.downloadpage(url).data +# data = re.sub(r"\n|\r|\t| |\s{2}", "", data) + +# patron = 'data-list-id="[^"]+" href="([^"]+)"><[^>]+>
    ' \ +# '([^<]+)
    ]+>
    ' +# matches = scrapertools.find_multiple_matches(data, patron) +# for scrapedurl, title in matches: +# scrapedurl = "http://m.filmaffinity.com" + scrapedurl +# itemlist.append(item.clone(title=title, url=scrapedurl, accion="lista")) + +# return itemlist ##-------------------- IMAGE LISTINGS ------------------------## @@ -1880,23 +1711,21 @@ def imagenes(item): itemlist = [] - if item.extra == "menu": + if item.args == "menu": item.folder = not config.is_xbmc() if "tmdb" in item.images: - itemlist.append(item.clone(title="Tmdb", extra="")) - itemlist.append(item.clone(title="Fanart.Tv", extra="")) + itemlist.append(item.clone(title="Tmdb", args="")) + itemlist.append(item.clone(title="Fanart.Tv", args="")) if "imdb" in item.images: - itemlist.append(item.clone(title="Imdb", extra="")) + itemlist.append(item.clone(title="Imdb", args="")) if "filmaffinity" in item.images: - itemlist.append(item.clone(title="Filmaffinity", extra="")) + itemlist.append(item.clone(title="Filmaffinity", args="")) if "myanimelist" in item.images: - data = httptools.downloadpage(item.url + "/pics", cookies=False).data - images = scrapertools.find_multiple_matches(data, - '
    .*?href.*?>([^<]+)<.*?
    ' \ - '(.*?)
    .*?(\d{4}|-).*?]+>.*?href.*?>([^<]+)<.*?
    (.*?)
    .*?(\d{4}|-).*?') + next_page = match(matches.data, patron=r'limit=(\d+)" class="link-blue-box next">').match if next_page: next_page = item.url.rsplit("=", 1)[0] + "=%s" % next_page - itemlist.append(item.clone(title=config.get_localized_string(70065), url=next_page, )) + itemlist.append(item.clone(title=typo(config.get_localized_string(30992), 'color kod bold'), url=next_page, thumbnail=thumb())) return itemlist -def detalles_mal(item): +def details_mal(item): itemlist = [] cookie_session = get_cookie_value() header_mal = {'Cookie': '%s search_sort_anime=score; search_view=tile; is_logged_in=1' % cookie_session} - data = httptools.downloadpage(item.url, headers=header_mal, cookies=False).data - data = re.sub(r"\n|\r|\t| ", "", data) - data = re.sub(r"\s{2}", " ", data) + data = match(item.url, headers=header_mal, cookies=False).data item.contentTitle = item.contentTitle.replace("(TV)", "").replace("(Movie)", "") item.fanart = default_fan item.infoLabels["plot"] = "" title_mal = item.contentTitle - if not item.extra: - extra = scrapertools.find_single_match(data, 'Type:.*?>([^<]+)
    ').lower() - item.tipo = extra - if extra == "movie" or extra == "special": - item.extra = "movie" + if not item.args: + args = match(data, patron=r'Type:.*?>([^<]+)').match.lower() + item.tipo = args + if args == "movie" or args == "special": + item.args = "movie" item.contentType = "movie" else: - item.extra = "tv" + item.args = "tv" item.contentType = "tvshow" if item.infoLabels['rating'] != "0.0": rating = item.infoLabels['rating'] else: - rating = scrapertools.find_single_match(data, '(\d.\d+)') + rating = match(data, patron=r'(\d.\d+)').match if not item.infoLabels["year"]: - item.infoLabels["year"] = scrapertools.find_single_match(data, '>Aired:.*?(\d{4})') + item.infoLabels["year"] = match(data, patron=r'>Aired:.*?(\d{4})').match - eng_title = scrapertools.find_single_match(data, 'English: ([^<]+)
    ').strip() + eng_title = match(data, patron=r'English: ([^<]+)
    ').match.strip() item_tmdb = item.clone() if item.contentType == "movie": - ob_tmdb = Tmdb(texto_buscado=item_tmdb.contentTitle, year=item_tmdb.infoLabels['year'], tipo=item_tmdb.extra, - idioma_busqueda=langt) + ob_tmdb = Tmdb(text_buscado=item_tmdb.contentTitle, year=item_tmdb.infoLabels['year'], tipo=item_tmdb.args, idioma_searching=langt) if not ob_tmdb.result and eng_title: - ob_tmdb = Tmdb(texto_buscado=eng_title, year=item_tmdb.infoLabels['year'], - tipo=item_tmdb.extra, idioma_busqueda=langt) + ob_tmdb = Tmdb(text_buscado=eng_title, year=item_tmdb.infoLabels['year'], tipo=item_tmdb.args, idioma_searching=langt) if not ob_tmdb.result and ("Special (" in item.title or item.tipo == "special"): - item_tmdb.extra = "tv" - search = {'url': 'search/tv', 'language': langt, 'query': item_tmdb.contentTitle, - 'first_air_date': item_tmdb.infoLabels["year"]} - ob_tmdb = Tmdb(discover=search, tipo=item_tmdb.extra, idioma_busqueda=langt) + item_tmdb.args = "tv" + search = {'url': 'search/tv', 'language': langt, 'query': item_tmdb.contentTitle, 'first_air_date': item_tmdb.infoLabels["year"]} + ob_tmdb = Tmdb(discover=search, tipo=item_tmdb.args, idioma_searching=langt) else: - search = {'url': 'search/tv', 'language': langt, 'query': eng_title, - 'first_air_date': item_tmdb.infoLabels["year"]} - ob_tmdb = Tmdb(discover=search, tipo=item_tmdb.extra, idioma_busqueda=langt) + search = {'url': 'search/tv', 'language': langt, 'query': eng_title, 'first_air_date': item_tmdb.infoLabels["year"]} + ob_tmdb = Tmdb(discover=search, tipo=item_tmdb.args, idioma_searching=langt) if not ob_tmdb.result and eng_title: search['query'] = eng_title - ob_tmdb = Tmdb(discover=search, tipo=item_tmdb.extra, idioma_busqueda=langt) + ob_tmdb = Tmdb(discover=search, tipo=item_tmdb.args, idioma_searching=langt) if not ob_tmdb.result and ("OVA (" in item.title or item.tipo == "ova"): - item_tmdb.extra = "movie" - ob_tmdb = Tmdb(texto_buscado=item_tmdb.contentTitle, tipo=item_tmdb.extra, idioma_busqueda=langt, - year=item_tmdb.infoLabels['year']) + item_tmdb.args = "movie" + ob_tmdb = Tmdb(text_buscado=item_tmdb.contentTitle, tipo=item_tmdb.args, idioma_searching=langt, year=item_tmdb.infoLabels['year']) if ob_tmdb.result: - ob_tmdb = Tmdb(id_Tmdb=ob_tmdb.get_id(), tipo=item_tmdb.extra, idioma_busqueda=langt) + ob_tmdb = Tmdb(id_Tmdb=ob_tmdb.get_id(), tipo=item_tmdb.args, idioma_searching=langt) item.infoLabels = ob_tmdb.get_infoLabels(item.infoLabels) # Myanimelist synopsis is concatenated with that of tmdb if any - plot = scrapertools.find_single_match(data, '(.*?)') + plot = match(data, patron=r'(.*?)').match plot = plot.replace("
    ", "\n").replace("", "[I]").replace("", "[/I]") - plot = scrapertools.decodeHtmlentities(plot) - if plot and (item.infoLabels['plot'] and item.infoLabels['plot'] != plot): - item.infoLabels['plot'] += " (TMDB)\n\n" + plot + " (MYANIMELIST)" - elif plot and not item.infoLabels['plot']: - item.infoLabels['plot'] = plot + plot = decodeHtmlentities(plot) + if plot and (item.infoLabels['plot'] and item.infoLabels['plot'] != plot): item.infoLabels['plot'] += " (TMDB)\n\n" + plot + " (MYANIMELIST)" + elif plot and not item.infoLabels['plot']: item.infoLabels['plot'] = plot if not item.infoLabels['duration']: try: - horas, min1, min2 = scrapertools.find_single_match(data, - 'Duration:\s*(?:(\d+) hr\. (\d+) min|(\d+) min)') - if horas: - horas = int(horas) * 360 - else: - horas = 0 - if not min1: - min1 = min2 + horas, min1, min2 = match(data, patron=r'Duration:\s*(?:(\d+) hr\. (\d+) min|(\d+) min)').match + if horas: horas = int(horas) * 360 + else: horas = 0 + if not min1: min1 = min2 item.infoLabels['duration'] = horas + (int(min1) * 60) except: pass # Myanimelist info overwrites tmdb info - generos = scrapertools.find_single_match(data, 'Genres:(.*?)
    ') - if generos: - item.infoLabels['genre'] = scrapertools.htmlclean(generos) + generos = match(data, patron=r'Genres:(.*?)
    ').match + if generos: item.infoLabels['genre'] = htmlclean(generos) - item.infoLabels['rating'] = float(rating) - votos = scrapertools.find_single_match(data, '([^<]+)<') + item.infoLabels['rating'] = float(rating) if rating in item.infoLabels else 0 + votos = match(data, patron=r'([^<]+)<').match item.infoLabels['votes'] = votos.replace(",", "") - if item.infoLabels['fanart']: - item.fanart = item.infoLabels['fanart'] - if item.infoLabels['thumbnail']: - item.thumbnail = item.infoLabels['thumbnail'] - if not item.thumbnail: - item.thumbnail = scrapertools.find_single_match(data, '/pics">.*?.*?" in data and config.is_xbmc(): - itemlist.append( - item.clone(title=config.get_localized_string(70321) % score, action="menu_mal", contentTitle=title_mal)) + itemlist.append(item.clone(title=config.get_localized_string(70321) % score, action="menu_mal", contentTitle=title_mal)) elif item.login and config.is_xbmc(): - status = {'1': config.get_localized_string(70479), '2': config.get_localized_string(70480), '3': config.get_localized_string(70384), '4': config.get_localized_string(70385), - '6': config.get_localized_string(70481)} - estado = scrapertools.find_single_match(data, 'myinfo_updateInfo".*?option selected="selected" value="(\d+)"') + status = {'1': config.get_localized_string(70479), '2': config.get_localized_string(70480), '3': config.get_localized_string(70384), '4': config.get_localized_string(70385), '6': config.get_localized_string(70481)} + estado = match(data, patron=r'myinfo_updateInfo".*?option selected="selected" value="(\d+)"').match try: estado = status[estado] - itemlist.append( - item.clone(title=config.get_localized_string(70322) % (estado, score), - action="menu_mal", - contentTitle=title_mal)) + itemlist.append(item.clone(title=config.get_localized_string(70322) % (estado, score), action="menu_mal", contentTitle=title_mal)) except: pass token_auth = config.get_setting("token_trakt", "trakt") if token_auth and ob_tmdb.result: - itemlist.append(item.clone(title=config.get_localized_string(70323), action="menu_trakt")) + itemlist.append(item.clone(title=config.get_localized_string(70323), action="menu_trakt", thumbnail=thumb('setting_0'))) # Prequels, sequels and alternative series are listed - prequel = scrapertools.find_single_match(data, 'Prequel:(.*?)') + prequel = match(data, patron=r'Prequel:(.*?)').match if prequel: - matches = scrapertools.find_multiple_matches(prequel, 'href="([^"]+)">(.*?)') + matches = match(prequel, patron=r'href="([^"]+)">(.*?)').matches for url, title in matches: - new_item = item.clone(infoLabels={'mediatype': item.contentType}, extra="", fanart=default_fan, - thumbnail="") + new_item = item.clone(args="") new_item.title = config.get_localized_string(70355) % title new_item.contentTitle = title - new_item.url = "https://myanimelist.net%s" % url + new_item.url = "https://myanimelist.net" + url if not url.startswith('http') else url + new_item.thumbnail = thumb('back') itemlist.append(new_item) - sequel = scrapertools.find_single_match(data, 'Sequel:(.*?)') + sequel = match(data, patron=r'Sequel:(.*?)').match if sequel: - matches = scrapertools.find_multiple_matches(sequel, 'href="([^"]+)">(.*?)') + matches = match(sequel, patron=r'href="([^"]+)">(.*?)').matches for url, title in matches: - new_item = item.clone(infoLabels={'mediatype': item.contentType}, extra="", fanart=default_fan, - thumbnail="") + new_item = item.clone(args="") new_item.title = config.get_localized_string(70356) % title new_item.contentTitle = title - new_item.url = "https://myanimelist.net%s" % url + new_item.url = "https://myanimelist.net" + url if not url.startswith('http') else url + new_item.thumbnail = thumb('next') itemlist.append(new_item) - alt_version = scrapertools.find_single_match(data, 'Alternative version:(.*?)') + alt_version = match(data, patron=r'Alternative version:(.*?)').match if alt_version: - matches = scrapertools.find_multiple_matches(alt_version, 'href="([^"]+)">(.*?)') + matches = match(alt_version, patron=r'href="([^"]+)">(.*?)').matches for url, title in matches: - new_item = item.clone(infoLabels={'mediatype': item.contentType}, extra="", fanart=default_fan, - thumbnail="") + new_item = item.clone(args="") new_item.title = config.get_localized_string(70357) % title new_item.contentTitle = title - new_item.url = "https://myanimelist.net%s" % url + new_item.url = "https://myanimelist.net" + url if not url.startswith('http') else url + new_item.thumbnail = thumb('alternative') itemlist.append(new_item) if ob_tmdb.result: - itemlist.append(item.clone(title="", action="", infoLabels={})) + # itemlist.append(item.clone(title="", action="", infoLabels={})) if ob_tmdb.result.get("belongs_to_collection"): - new_item = item.clone(infoLabels={'mediatype': item.contentType}, action="listado_tmdb", ) + new_item = item.clone(action="list_tmdb", ) saga = ob_tmdb.result["belongs_to_collection"] new_item.infoLabels["tmdb_id"] = saga["id"] if saga["poster_path"]: @@ -2509,18 +2254,14 @@ def detalles_mal(item): if saga["backdrop_path"]: new_item.fanart = 'http://image.tmdb.org/t/p/original' + saga["backdrop_path"] new_item.search = {'url': 'collection/%s' % saga['id'], 'language': langt} - new_item.title = "Es parte de: %s" % saga["name"] + new_item.title = config.get_localized_string(70327) % saga["name"] itemlist.append(new_item) - itemlist.append( - item.clone(title=config.get_localized_string(70358), action="listado_tmdb", infoLabels={'mediatype': item.contentType}, - search={'url': '%s/%s/recommendations' % (item.extra, item.infoLabels['tmdb_id']), - 'language': langt, 'page': 1}, )) + itemlist.append(item.clone(title=config.get_localized_string(70358), action="list_tmdb", search={'url': '%s/%s/recommendations' % (item.args, item.infoLabels['tmdb_id']), 'language': langt, 'page': 1}, thumbnail=thumb('popular'))) # Myanimelist recommendations and info search on anidb (fansubs in Spanish) - itemlist.append(item.clone(title=config.get_localized_string(70359), action="reco_mal")) - anidb_link = scrapertools.find_single_match(data, - '([^<]+)<(.*?)([^<]+)<(.*?)More') - if next_page: - itemlist.append(item.clone(title=config.get_localized_string(70361), url=next_page, )) - if itemlist: - itemlist.insert(0, item.clone(title=config.get_localized_string(70362), action="", )) + next_page = match(data, patron=r'More').match + if next_page: itemlist.append(item.clone(title=config.get_localized_string(70361), url=next_page, )) + if itemlist: itemlist.insert(0, item.clone(title=config.get_localized_string(70362), action="", )) - patron = '([^<]+)<' - matches = scrapertools.find_multiple_matches(data, patron) + patron = r'([^<]+)<' + matches = match(data, patron=patron).matches if matches: itemlist.append(item.clone(title=config.get_localized_string(70363), action="", )) for url, thumb, title in matches: url = url.replace("embed/", "watch?v=") - itemlist.append( - item.clone(title=title, url=url, server="youtube", action="play", thumbnail=thumb, )) + itemlist.append(item.clone(title=title, url=url, server="youtube", action="play", thumbnail=thumb, )) return itemlist @@ -2574,23 +2307,15 @@ def reco_mal(item): # Myanimelist recommendations itemlist = [] - data = httptools.downloadpage(item.url + "/userrecs", cookies=False).data - data = re.sub(r"\n|\r|\t| ", "", data) - data = re.sub(r"\s{2}", " ", data) - bloque = scrapertools.find_single_match(data, - '
    ') - patron = '
    (.*?).*?' \ - '
    (.*?)
    ' - matches = scrapertools.find_multiple_matches(data, patron) + # patronBlock = r'
    ' + patron = r'
    ]+>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>([^<\(]+)(?:\([^<]+)?<[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>([^<]+)' + matches = match(item.url + "/userrecs", cookies=False, patron=patron).matches for url, thumb, title, plot in matches: - new_item = item.clone(infoLabels={'mediatype': item.contentType}, action="detalles_mal", fanart=default_fan, - title=title, contentType="", extra="", - contentTitle=title) - new_item.infoLabels["plot"] = scrapertools.htmlclean(plot) - new_item.url = "https://myanimelist.net%s" % url + new_item = item.clone(action="details_mal", fanart=default_fan, title=title, contentType="", args="", contentTitle=title) + new_item.infoLabels["plot"] = htmlclean(plot) + new_item.url = "https://myanimelist.net" + url if not url.startswith('http') else url new_item.thumbnail = thumb.replace("r/50x70/", "").replace(".jpg", "l.jpg") itemlist.append(new_item) - return itemlist @@ -2598,36 +2323,29 @@ def indices_mal(item): # Seasonal and gender indices itemlist = [] url_base = "" - if "Temporadas" in item.title: - data = httptools.downloadpage("https://myanimelist.net/anime/season/archive", cookies=False).data - data = re.sub(r"\n|\r|\t| ", "", data) - data = re.sub(r"\s{2}", " ", data) - matches = scrapertools.find_multiple_matches(data, '\s*\s*(.*?)\s*') + if config.get_localized_string(30140) in item.title: + matches = match("https://myanimelist.net/anime/season/archive", cookies=False, patron=r'\s*\s*(.*?)\s*').matches for url, title in matches: year = title.rsplit(" ", 1)[1] thumbnail = item.thumbnail if int(year) >= 1968: - thumbnail = url_base % year - title = title.replace("Winter", config.get_localized_string(70364)).replace("Spring", config.get_localized_string(70365)) \ - .replace("Summer", config.get_localized_string(70366)).replace("Fall", config.get_localized_string(70367)) - itemlist.append(Item(channel=item.channel, action="season_mal", title=title, url=url, - thumbnail=thumbnail, info=True, fanart=thumbnail)) + thumbnail = url_base + year + title = title.replace("Winter", config.get_localized_string(70364)).replace("Spring", config.get_localized_string(70365)).replace("Summer", config.get_localized_string(70366)).replace("Fall", config.get_localized_string(70367)) + itemlist.append(Item(channel=item.channel, action="season_mal", title=typo(title, 'bold'), url=url, thumbnail=thumbnail, info=True, fanart=thumbnail)) else: - data = httptools.downloadpage("https://myanimelist.net/anime.php", cookies=False).data - data = re.sub(r"\n|\r|\t| ", "", data) - data = re.sub(r"\s{2}", " ", data) - bloque = scrapertools.find_single_match(data, 'Genres
    (.*?)View More') - matches = scrapertools.find_multiple_matches(bloque, '(.*?)') + patronBlock = r'Genres
    (.*?)View More' + patron = r'(.*?)' + matches = match("https://myanimelist.net/anime.php", cookies=False, patronBlock=patronBlock, patron=patron).matches for url, title in matches: genero = title.split(" (", 1)[0] - thumbnail = url_base % genero.lower().replace(" ", "%20") + log(url_base, genero) + thumbnail = url_base + genero.lower().replace(" ", "%20") if genero in ["Hentai", "Yaoi", "Yuri"] and not adult_mal: continue - url = "https://myanimelist.net%s" % url - itemlist.append(Item(channel=item.channel, action="season_mal", title=title, url=url, - thumbnail=thumbnail, fanart=thumbnail, )) + if not url.startswith('http'): url = "https://myanimelist.net" + url + itemlist.append(Item(channel=item.channel, action="season_mal", title=typo(title, 'bold'), url=url, thumbnail=thumbnail, fanart=thumbnail)) - return itemlist + return thumb(itemlist, genre=True) def season_mal(item): @@ -2636,87 +2354,71 @@ def season_mal(item): cookie_session = get_cookie_value() header_mal = {'Cookie': '%s search_sort_anime=score; search_view=tile; is_logged_in=1' % cookie_session} - data = httptools.downloadpage(item.url, headers=header_mal, cookies=False).data - data = re.sub(r"\n|\r|\t| ", "", data) - data = re.sub(r"\s{2}", " ", data) - + data = match(item.url, headers=header_mal, cookies=False).data if item.info: - patron = '
    ([^<]+)
    (.*?)
    \s*
    ' - bloques = scrapertools.find_multiple_matches(data, patron) - for head_title, bloque in bloques: + blocks = match(data, patron=r'
    ([^<]+)
    (.*?)
    \s*
    ').matches + for head_title, block in blocks: head_title = head_title.replace("(New)", config.get_localized_string(70369)).replace("(Continuing)", config.get_localized_string(70369)) - patron = '(.*?).*?(\? ep|\d+ ep).*?' \ - '
    (.*?)
    .*?
    (.*?).*?
    \s*(.*?)\s*-.*?(\d{4}).*?' \ - 'title="Score">\s*(N/A|\d\.\d+)' - matches = scrapertools.find_multiple_matches(bloque, patron) + patron = r'(.*?).*?(\? ep|\d+ ep).*?
    (.*?)
    .*?
    (.*?).*?
    \s*(.*?)\s*-.*?(\d{4}).*?title="Score">\s*(N/A|\d\.\d+)' + matches = match(block, patron=patron, debug=True).matches if matches: itemlist.append(Item(channel=item.channel, action="", title=head_title, )) - for url, scrapedtitle, epis, generos, thumb, plot, tipo, year, score in matches: - if ("Hentai" in generos or "Yaoi" in generos or "Yuri" in generos) and adult_mal: - continue + for url, scrapedtitle, episode, genres, thumb, plot, tipo, year, score in matches: + if ("Hentai" in genres or "Yaoi" in genres or "Yuri" in genres) and adult_mal: continue scrapedtitle = scrapedtitle.replace("(TV)", "").replace("(Movie)", "") - if tipo == "Movie": - title = scrapedtitle + " (%s)" % year - else: - title = scrapedtitle + " %ss (%s)" % (epis, year) + if tipo == "Movie": title = scrapedtitle + " (%s)" % year + else: title = scrapedtitle + " %ss (%s)" % (episode, year) infoLabels = {} if score != "N/A": title += " %s" % (score) infoLabels["rating"] = float(score) - infoLabels["plot"] = scrapertools.htmlclean(plot) + infoLabels["plot"] = htmlclean(plot) infoLabels["year"] = year - genres = scrapertools.find_multiple_matches(generos, 'title="([^"]+)"') + genres = match(genres, patron=r'title="([^"]+)"').matches infoLabels["genre"] = ", ".join(genres) tipo = tipo.lower() if tipo == "movie" or tipo == "special": - extra = "movie" + args = "movie" contentType = "movie" else: - extra = "tv" + args = "tv" contentType = "tvshow" thumb = thumb.replace("r/167x242/", "") + "l.jpg" - itemlist.append(Item(channel=item.channel, action="detalles_mal", url=url, title=title, - thumbnail=thumb, infoLabels=infoLabels, extra=extra, tipo=tipo, - contentTitle=scrapedtitle, contentType=contentType, - fanart=default_fan)) + itemlist.append(Item(channel=item.channel, action="details_mal", url=url, title=title, thumbnail=thumb, infoLabels=infoLabels, args=args, tipo=tipo, contentTitle=scrapedtitle, contentType=contentType, fanart=default_fan)) else: - patron = '(.*?).*?(\? ep|\d+ ep).*?' \ - '
    (.*?)
    .*?
    (.*?).*?
    \s*(.*?)\s*-.*?(\d{4}).*?' \ - 'title="Score">\s*(N/A|\d\.\d+)' - matches = scrapertools.find_multiple_matches(data, patron) - for url, scrapedtitle, epis, generos, thumb, plot, tipo, year, score in matches: - if ("Hentai" in generos or "Yaoi" in generos or "Yuri" in generos) and not adult_mal: + patron = r'(.*?).*?(\? ep|\d+ ep).*?
    (.*?)
    .*?
    (.*?).*?
    \s*(.*?)\s*-.*?(\d{4}).*?title="Score">\s*(N/A|\d\.\d+)' + matches = match(data, patron=patron).matches + for url, scrapedtitle, epis, scrapedgenres, thumbnail, plot, tipo, year, score in matches: + if ("Hentai" in scrapedgenres or "Yaoi" in scrapedgenres or "Yuri" in scrapedgenres) and not adult_mal: continue scrapedtitle = scrapedtitle.replace("(TV)", "").replace("(Movie)", "") if tipo == "Movie": - title = scrapedtitle + " (%s)" % year + title = scrapedtitle + " (%s)" % year else: - title = scrapedtitle + " %ss (%s)" % (epis, year) + title = scrapedtitle + " %ss (%s)" % (epis, year) infoLabels = {} if score != "N/A": title += " %s" % (score) infoLabels["rating"] = float(score) - infoLabels["plot"] = scrapertools.htmlclean(plot) + infoLabels["plot"] = htmlclean(plot) infoLabels["year"] = year - genres = scrapertools.find_multiple_matches(generos, 'title="([^"]+)"') + genres = match(scrapedgenres, patron=r'title="([^"]+)"').matches infoLabels["genre"] = ", ".join(genres) tipo = tipo.lower() if tipo == "movie" or tipo == "special": - extra = "movie" + args = "movie" contentType = "movie" else: - extra = "tv" + args = "tv" contentType = "tvshow" - thumb = thumb.replace("r/167x242/", "") + "l.jpg" - itemlist.append(Item(channel=item.channel, action="detalles_mal", url=url, title=title, - thumbnail=thumb, infoLabels=infoLabels, extra=extra, tipo=tipo, + thumbnail = thumbnail.replace("r/167x242/", "") + "l.jpg" + itemlist.append(Item(channel=item.channel, action="details_mal", url=url, title=title, + thumbnail=thumbnail, infoLabels=infoLabels, args=args, tipo=tipo, contentTitle=scrapedtitle, contentType=contentType, fanart=default_fan)) - next_page = scrapertools.find_single_match(data, '' - matches = scrapertools.find_multiple_matches(data, patron) + data = match(item.url, cookies=False).data + patron = r'(/character/[^"]+)".*?data-src="([^"]+)".*?href=.*?>([^<]+)<.*?([^<]+)(.*?)' + matches = match(data, patron=patron).matches if matches: - itemlist.append(item.clone(title=config.get_localized_string(70370), action="", )) - for url, thumb, nombre, rol, voces in matches: + # itemlist.append(item.clone(title=config.get_localized_string(70370), action="", )) + for url, thumbnail, nombre, rol, voces in matches: url = "https://myanimelist.net%s" % url - rol = rol.replace("Main", "Principal").replace("Supporting", "Secundario") - nombre = " %s [%s]" % (nombre, rol) - thumb = thumb.replace("r/46x64/", "") - itemlist.append(Item(channel=item.channel, action="detail_staff", url=url, - thumbnail=thumb, fanart=default_fan, title=nombre, extra="character")) - patron_voces = '([^<]+)<.*?([^<]+).*?data-src="([^"]+)"' - voces_match = scrapertools.find_multiple_matches(voces, patron_voces) + nombre = "%s [%s]" % (nombre, rol) + thumbnail = thumbnail.replace("r/46x64/", "").replace("r/42x62/", "") + itemlist.append(Item(channel=item.channel, action="detail_staff", url=url, thumbnail=thumbnail, fanart=default_fan, title=nombre, args="character")) + patron_voces = r'(/people[^"]+)">([^<]+)<.*?([^<]+).*?data-src="([^"]+)"' + voces_match = match(voces, patron=patron_voces).matches for vurl, vnombre, vidioma, vthumb in voces_match: vurl = "https://myanimelist.net%s" % vurl - vnombre = " %s [%s]" % (vnombre, vidioma) - vthumb = vthumb.replace("r/46x64/", "") - itemlist.append(Item(channel=item.channel, action="detail_staff", url=vurl, - thumbnail=vthumb, fanart=default_fan, title=vnombre)) - bloque = scrapertools.find_single_match(data, '(.*?)') - patron = '([^<]+)<.*?([^<]+)' - matches = scrapertools.find_multiple_matches(bloque, patron) + vnombre = " - %s [%s]" % (vnombre, vidioma) + vthumb = vthumb.replace("r/46x64/", "").replace("r/42x62/", "") + itemlist.append(Item(channel=item.channel, action="detail_staff", url=vurl, thumbnail=vthumb, fanart=default_fan, title=vnombre)) + patronBlock = r'(.*?)' + patron = r'(/people[^"]+)".*?data-src="([^"]+)".*?href=.*?>([^<]+)<.*?([^<]+)' + matches = match(data, patronBlock=patronBlock, patron=patron).matches if matches: itemlist.append(item.clone(title="Staff", action="", )) for url, thumb, nombre, rol in matches: url = "https://myanimelist.net%s" % url - nombre = " %s [%s]" % (nombre, rol) - thumb = thumb.replace("r/46x64/", "") - itemlist.append(Item(channel=item.channel, action="detail_staff", url=url, - thumbnail=thumb, fanart=default_fan, title=nombre)) + nombre = " - %s [%s]" % (nombre, rol) + thumb = thumb.replace("r/46x64/", "").replace("r/42x62/", "") + itemlist.append(Item(channel=item.channel, action="detail_staff", url=url, thumbnail=thumb, fanart=default_fan, title=nombre)) return itemlist def detail_staff(item): itemlist = [] - data = httptools.downloadpage(item.url, cookies=False).data - data = re.sub(r"\n|\r|\t| ", "", data) - data = re.sub(r"\s{2}", " ", data) - - if item.extra == "character" and not "No biography written" in data: - bio = scrapertools.find_single_match(data, - 'itemprop="name">.*?
    (.*?)
    [^>]+>(.*?)
    ", "\n") - bio = scrapertools.htmlclean(bio) + bio = htmlclean(bio) if not "questionmark" in item.thumbnail: - data_img = httptools.downloadpage(item.url + "/pictures", cookies=False).data - matches = scrapertools.find_multiple_matches(data_img, 'rel="gallery-character">(.*?)') + matches = match(data, patron=r'(/anime[^"]+)">(.*?)').matches if matches: - itemlist.append(Item(channel=item.channel, title="Animes donde aparece:", action="", )) - for url, thumb, title in matches: + itemlist.append(Item(channel=item.channel, title=typo(config.get_localized_string(70373),'bold, bullet'), action="", thumbnail=thumb('info') )) + for url, thumbnail, title in matches: url = "https://myanimelist.net%s" % url - thumb = thumb.replace("r/23x32/", "") - itemlist.append(Item(channel=item.channel, action="detalles_mal", url=url, - thumbnail=thumb, fanart=default_fan, title=title, contentTitle=title)) + thumbnail = thumbnail.replace("r/23x32/", "").replace("r/42x62/", "") + itemlist.append(Item(channel=item.channel, action="details_mal", url=url, thumbnail=thumbnail, fanart=default_fan, title= typo(title, 'submenu'), contentTitle=title)) else: - patron_bio = '
    .*?
    (.*?)' - bio = scrapertools.find_single_match(data, patron_bio) - bio = scrapertools.htmlclean(bio.replace("
    ", "\n")) + patron_bio = r'(.*?)' + bio = match(data, patron=patron_bio).match + bio = htmlclean(bio.replace("
    ", "\n")) + log(bio) infoLabels = {'plot': bio} if not "No voice acting roles" in data: - itemlist.append(Item(channel=item.channel, title="Da voz a/en:", action="", - thumbnail=item.thumbnail, infoLabels=infoLabels)) - bloque = scrapertools.find_single_match(data, 'Voice Acting Roles
    (.*?)') - patron = '(.*?).*?href="(/character[^"]+)".*?' \ - '>(.*?).*?data-src="([^"]+)"' - matches = scrapertools.find_multiple_matches(bloque, patron) - for url, thumb, title, url_p, personaje, thumb_p in matches: + itemlist.append(Item(channel=item.channel, title=typo(config.get_localized_string(70374),'bold bullet'), action="", thumbnail=item.thumbnail, infoLabels=infoLabels)) + patronBlock = r'Voice Acting Roles
    (.*?)' + patron = r'(/anime[^"]+)">]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>([^<]+)<[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>.*?(/character[^"]+)"[^>]*>([^<]+)<[^>]*>[^>]*>[^>]*>[^>]*>[^>]*>[^>]*>[^>]*>(.*?)') - patron = '(.*?).*?(.*?)
    ' - matches = scrapertools.find_multiple_matches(bloque, patron) - for url, thumb, title, rol in matches: + itemlist.append(Item(channel=item.channel, title=typo(config.get_localized_string(70375),'bold bullet'), action="", thumbnail=item.thumbnail, infoLabels=infoLabels)) + patronBlock = r'Anime Staff Positions
    (.*?)' + patron = r'(/anime[^"]+)">(.*?).*?(.*?)
    ' + matches = match(data, patronBlock=patronBlock, patron=patron).matches + for url, thumbnails, title, rol in matches: url = "https://myanimelist.net%s" % url - thumb = thumb.replace("r/46x64/", "") - rol = scrapertools.htmlclean(rol) - titulo = "%s [%s]" % (title, rol) - itemlist.append(Item(channel=item.channel, action="detalles_mal", url=url, - thumbnail=thumb, fanart=default_fan, title=titulo, contentTitle=title)) + thumbnails = thumbnails.replace("r/46x64/", "").replace("r/84x124/", "") + rol = htmlclean(rol) + titulo = typo("%s [%s]" % (title, rol), 'submenu') + itemlist.append(Item(channel=item.channel, action="details_mal", url=url, thumbnail=thumbnails, fanart=default_fan, title=titulo, contentTitle=title)) return itemlist -def busqueda_mal(item): +def searching_mal(item): # Scraper for myanimelist searches itemlist = [] cookie_session = get_cookie_value() header_mal = {'Cookie': '%s search_sort_anime=score; search_view=tile; is_logged_in=1' % cookie_session} - data = httptools.downloadpage(item.url, headers=header_mal, cookies=False).data - data = re.sub(r"\n|\r|\t| ", "", data) - data = re.sub(r"\s{2}", " ", data) - - patron = '([^<]+)<.*?
    (.*?)<' \ - '.*?(.*?).*?(.*?).*?(.*?).*?(.*?)' - matches = scrapertools.find_multiple_matches(data, patron) - for url, thumb, titulo, plot, tipo, epis, rating, date in matches: + data = match(item.url, headers=header_mal, cookies=False).data + patron = r'([^<]+)<.*?
    (.*?)<.*?(.*?).*?(.*?).*?(.*?).*?(.*?)' + matches = match(data, patron=patron).matches + for url, thumb, title, plot, tipo, epis, rating, date in matches: infolabels = {"mediatype": "tvshow"} contentType = "tvshow" - extra = "tv" - titulo = titulo.strip() + args = "tv" + title = title.strip() tipo = tipo.strip() rating = rating.strip() epis = epis.strip() - infolabels["plot"] = scrapertools.htmlclean(plot.strip()) + infolabels["plot"] = htmlclean(plot.strip()) thumb = thumb.replace("r/50x70/", "").replace(".jpg", "l.jpg") - show = titulo - contentitle = titulo - title = titulo + show = title + contentitle = title try: year = date.strip().rsplit("-", 1)[1] if year.isdigit(): @@ -2874,12 +2550,12 @@ def busqueda_mal(item): title += " (%s)" % year except: import traceback - logger.error(traceback.format_exc()) + error(traceback.format_exc()) if tipo == "Movie" or tipo == "OVA": infolabels["mediatype"] = "movie" contentType = "movie" - extra = "movie" + args = "movie" show = "" if epis and tipo != "Movie": @@ -2887,9 +2563,9 @@ def busqueda_mal(item): if rating != "0.00" and rating != "N/A": infolabels["rating"] = float(rating) title += " %s" % (rating) - itemlist.append(Item(channel=item.channel, title=title, action="detalles_mal", url=url, show=show, + itemlist.append(Item(channel=item.channel, title=title, action="details_mal", url=url, show=show, thumbnail=thumb, infoLabels=infolabels, contentTitle=contentitle, - contentType=contentType, tipo=tipo.lower(), extra=extra)) + contentType=contentType, tipo=tipo.lower(), args=args)) if not "&show=" in item.url: next_page = item.url + "&show=50" @@ -2910,61 +2586,54 @@ def busqueda_mal(item): def info_anidb(item, itemlist, url): # Extract info, score and fansubs on anidb - data = httptools.downloadpage(url).data - data = re.sub(r"\n|\r|\t| ", "", data) - data = re.sub(r"\s{2}", " ", data) + data = match(url).data infoLabels = {'mediatype': item.contentType} - plot = scrapertools.find_single_match(data, 'itemprop="description">(.*?)
    ') - infoLabels["plot"] = scrapertools.htmlclean(plot) + plot = match(data, patron=r'itemprop="description">(.*?)
    ').match + infoLabels["plot"] = htmlclean(plot) - generos = scrapertools.find_multiple_matches(data, '
    (.*?)') + generos = match(data, patron=r'
    (.*?)').matches for i, genero in enumerate(generos): generos[i] = genero.capitalize() infoLabels["genre"] = ", ".join(generos) - rating = scrapertools.find_single_match(data, 'itemprop="ratingValue">(.*?)') + rating = match(data, patron=r'itemprop="ratingValue">(.*?)').match try: infoLabels["rating"] = float(rating) except: pass - infoLabels["votes"] = scrapertools.find_single_match(data, 'itemprop="ratingCount">(.*?)') - thumbnail = scrapertools.find_single_match(data, '
    .*?src="([^"]+)"') + infoLabels["votes"] = match(data, patron=r'itemprop="ratingCount">(.*?)').match + thumbnail = match(data, patron=r'
    .*?src="([^"]+)"').match if infoLabels: title = config.get_localized_string(70376) % (rating) if re.search(r'(?:subtitle|audio) | language: spanish"', data): title += config.get_localized_string(70377) - itemlist.append(Item(channel=item.channel, title=title, infoLabels=infoLabels, action="", - thumbnail=thumbnail, )) + itemlist.append(Item(channel=item.channel, title=title, infoLabels=infoLabels, action="", thumbnail=thumbnail)) if re.search(r'(?:subtitle|audio) | language: spanish"', data): - epi_total = scrapertools.find_single_match(data, 'itemprop="numberOfEpisodes">([^<]+)') - patron = '.*?title="([^"]+)">(.*?).*?>([^<]+).*?' \ - '([^<]+).*?title="audio(.*?).*?' \ - 'class="source" title="([^"]+)"' - matches = scrapertools.find_multiple_matches(data, patron) + epi_total = match(data, patron=r'itemprop="numberOfEpisodes">([^<]+)').match + patron = r'.*?title="([^"]+)">(.*?).*?>([^<]+).*?([^<]+).*?title="audio(.*?).*?class="source" title="([^"]+)"' + matches = match(data, patron=patron).matches for fansub, abrev, estado, epis, lang, source in matches: if not "spanish" in lang: continue title = " " + fansub if abrev != title: title += " [%s]" % abrev - estado = estado.replace("complete", config.get_localized_string(70378)).replace("finished", config.get_localized_string(70379)) \ - .replace("stalled", config.get_localized_string(70380)).replace("dropped", config.get_localized_string(70381)) + estado = estado.replace("complete", config.get_localized_string(70378)).replace("finished", config.get_localized_string(70379)).replace("stalled", config.get_localized_string(70380)).replace("dropped", config.get_localized_string(70381)) title += " (%s) %s/%s [%s]" % (estado, epis, epi_total, source) - itemlist.append(Item(channel=item.channel, title=title, infoLabels=infoLabels, action="", - thumbnail=thumbnail, )) + itemlist.append(Item(channel=item.channel, title=title, infoLabels=infoLabels, action="", thumbnail=thumbnail)) -def filtro_mal(item): - logger.log() +def filter_mal(item): + log() list_controls = [] valores = {} dict_values = None # Default / saved values ​​are used - valores_guardados = config.get_setting("filtro_defecto_mal", item.channel) - if valores_guardados: - dict_values = valores_guardados + saved_values = config.get_setting("default_filter_mal", item.channel) + if saved_values: + dict_values = saved_values list_controls.append({'id': 'keyword', 'label': config.get_localized_string(70465), 'enabled': True, 'type': 'text', 'default': '', 'visible': True}) @@ -2987,26 +2656,20 @@ def filtro_mal(item): try: data = httptools.downloadpage('https://myanimelist.net/anime.php', cookies=False).data - patron = 'name="genre\[\]" type="checkbox" value="([^"]+)">.*?>([^<]+)<' + patron = r'name="genre\[\]" type="checkbox" value="([^"]+)">.*?>([^<]+)<' generos = scrapertools.find_multiple_matches(data, patron) if generos: - list_controls.append({'id': 'labelgenre', 'enabled': True, 'type': 'label', 'default': None, - 'label': config.get_localized_string(70451), - 'visible': True, 'color': '0xFFC52020'}) + list_controls.append({'id': 'labelgenre', 'enabled': True, 'type': 'label', 'default': None, 'label': config.get_localized_string(70451), 'visible': True}) for value, genre in generos: - list_controls.append({'id': 'genre' + value, 'label': genre, 'enabled': True, - 'type': 'bool', 'default': False, 'visible': True}) + list_controls.append({'id': 'genre' + value, 'label': genre, 'enabled': True, 'type': 'bool', 'default': False, 'visible': True}) except: pass - list_controls.append({'id': 'espacio', 'label': '', 'enabled': False, - 'type': 'label', 'default': None, 'visible': True}) - list_controls.append({'id': 'save', 'label': config.get_localized_string(70464), 'enabled': True, - 'type': 'bool', 'default': False, 'visible': True}) + list_controls.append({'id': 'espacio', 'label': '', 'enabled': False, 'type': 'label', 'default': None, 'visible': True}) + list_controls.append({'id': 'save', 'label': config.get_localized_string(70464), 'enabled': True, 'type': 'bool', 'default': False, 'visible': True}) item.valores = valores - return platformtools.show_channel_settings(list_controls=list_controls, dict_values=dict_values, - caption=config.get_localized_string(70320), item=item, callback='callback_mal') + return platformtools.show_channel_settings(list_controls=list_controls, dict_values=dict_values, caption=config.get_localized_string(70320), item=item, callback='callback_mal') def callback_mal(item, values): @@ -3014,7 +2677,7 @@ def callback_mal(item, values): # Save the filter to be the one loaded by default if "save" in values and values["save"]: values_copy.pop("save") - config.set_setting("filtro_defecto_mal", values_copy, item.channel) + config.set_setting("default_filter_mal", values_copy, item.channel) genero_ids = [] for v in values: @@ -3034,19 +2697,18 @@ def callback_mal(item, values): if genero_ids: item.url += "&" + genero_ids - item.action = "busqueda_mal" - return busqueda_mal(item) + item.action = "searching_mal" + return searching_mal(item) def musica_anime(item): # List available anime and songs similar to the anime title - logger.log() + log() itemlist = [] - data = httptools.downloadpage("http://www.freeanimemusic.org/song_search.php", post=item.post).data - patron = "(\d+).*?([^<]+)<.*?([^<]+)<" \ - ".*?href='http://www.freeanimemusic.org/anime/([^/]+)/index.php\?var=(\d+)" - matches = scrapertools.find_multiple_matches(data, patron) + data = match("http://www.freeanimemusic.org/song_search.php", post=item.post).data + patron = r"(\d+).*?([^<]+)<.*?([^<]+)<.*?href='http://www.freeanimemusic.org/anime/([^/]+)/index.php\?var=(\d+)" + matches = match(data, patron=patron).matches animes = {} action = "" if config.is_xbmc(): @@ -3068,7 +2730,7 @@ def musica_anime(item): v.sort(key=lambda x: (x.url, int(x.number))) for lt in v: if lt.action == "move": - lt.extra = len(v) + lt.args = len(v) lt.folder = False itemlist.append(lt) @@ -3076,7 +2738,9 @@ def musica_anime(item): def login_mal(from_list=False): - logger.log() + log() + from core import httptools + from base64 import b64decode as bdec try: user = config.get_setting("usuariomal", "tvmoviedb") @@ -3088,26 +2752,26 @@ def login_mal(from_list=False): password = bdec("dFlTakE3ekYzbng1") generic = True else: - return False, config.get_localized_string(70381), user + return False, config.get_localized_string(70393), user data = httptools.downloadpage("https://myanimelist.net/login.php?from=%2F").data if re.search(r'(?i)' + user, data) and not generic: return True, "", user - token = scrapertools.find_single_match(data, "name='csrf_token' content='([^']+)'") + token = match(data, patron=r"name='csrf_token' content='([^']+)'").match response = httptools.downloadpage("https://myanimelist.net/logout.php", post="csrf_token=%s" % token) post = "user_name=%s&password=%s&cookie=1&sublogin=Login&submit=1&csrf_token=%s" % (user, password, token) response = httptools.downloadpage("https://myanimelist.net/login.php?from=%2F", post=post) if not re.search(r'(?i)' + user, response.data): - logger.error("Error en el login") + error("Login failed") return False, config.get_localized_string(70330), user else: if generic: - return False, config.get_localized_string(70381), user - logger.log("Login correcto") + return False, config.get_localized_string(70393), user + log("Correct login") return True, "", user except: import traceback - logger.error(traceback.format_exc()) + error(traceback.format_exc()) return False, config.get_localized_string(70331) @@ -3135,15 +2799,11 @@ def cuenta_mal(item): def items_mal(item): # Scraper for personal lists - logger.log() + log() itemlist = [] - data = httptools.downloadpage(item.url).data - data = re.sub(r"\n|\r|\t| ", "", data) - data = re.sub(r"\s{2}", " ", data) + data = match(item.url).data - data_items = scrapertools.find_single_match(data, 'data-items="([^"]+)"') - data_items = data_items.replace(""", "'").replace("null", "None") \ - .replace("false", "False").replace("true", "True") + data_items = match(data, patron=r'data-items="([^"]+)"').match.replace(""", "'").replace("null", "None").replace("false", "False").replace("true", "True") data_items = eval(data_items) for d in data_items: if d["anime_airing_status"] == 1: @@ -3157,7 +2817,8 @@ def items_mal(item): title = title.replace("\\", "") contentTitle = d["anime_title"].replace("\\", "") thumbnail = d["anime_image_path"].replace("\\", "").replace("r/96x136/", "").replace(".jpg", "l.jpg") - url = "https://myanimelist.net" + d["anime_url"].replace("\\", "") + if d["anime_url"].startswith('http'): url= d["anime_url"].replace("\\", "") + else: url = "https://myanimelist.net" + d["anime_url"].replace("\\", "") if d["score"] != 0: title += typo(" Punt:%s" % (d["score"]),'color kod bold') if title.count("(TV)") == 2: @@ -3165,13 +2826,13 @@ def items_mal(item): elif title.count("(Movie)") == 2: title = title.replace("] (Movie)", "]") tipo = "tvshow" - extra = "tv" + args = "tv" if "Movie" in d["anime_media_type_string"]: tipo = "movie" - extra = "movie" - itemlist.append(Item(channel=item.channel, action="detalles_mal", url=url, title=title, thumbnail=thumbnail, + args = "movie" + itemlist.append(Item(channel=item.channel, action="details_mal", url=url, title=title, thumbnail=thumbnail, - contentTitle=contentTitle, contentType=tipo, extra=extra, login=True)) + contentTitle=contentTitle, contentType=tipo, args=args, login=True)) if itemlist: itemlist.insert(0, Item(channel=item.channel, action="", title=config.get_localized_string(70387))) @@ -3183,12 +2844,10 @@ def menu_mal(item): # Options BAD account, add to list / vote itemlist = [] - data = httptools.downloadpage(item.url).data + data = match(item.url).data try: - status = {'1': config.get_localized_string(70479), '2': config.get_localized_string(70480), '3': config.get_localized_string(70384), '4': config.get_localized_string(70385), - '6': config.get_localized_string(70481)} - button, estado = scrapertools.find_single_match(data, - 'myinfo_updateInfo"(.*?)>.*?option selected="selected" value="(\d+)"') + status = {'1': config.get_localized_string(70479), '2': config.get_localized_string(70480), '3': config.get_localized_string(70384), '4': config.get_localized_string(70385), '6': config.get_localized_string(70481)} + button, estado =match(data, patron=r'myinfo_updateInfo"(.*?)>.*?option selected="selected" value="(\d+)"').match if "disabled" in button: title_estado = config.get_localized_string(70388) estado = "1" @@ -3197,39 +2856,36 @@ def menu_mal(item): except: title_estado = config.get_localized_string(70388) - score = scrapertools.find_single_match(data, 'id="myinfo_score".*?selected" value="(\d+)"') + score = match(data, patron=r'id="myinfo_score".*?selected" value="(\d+)"').match if score != "0": title_estado += " (Punt:%s)" % score if "lista" in title_estado: item.lista = True itemlist.append(item.clone(title="Anime: %s%s" % (item.contentTitle, title_estado), action="")) - status = {'1': config.get_localized_string(70479), '2': config.get_localized_string(70480), '3': config.get_localized_string(70384), '4': config.get_localized_string(70385), - '6': config.get_localized_string(70481)} + status = {'1': config.get_localized_string(70479), '2': config.get_localized_string(70480), '3': config.get_localized_string(70384), '4': config.get_localized_string(70385), '6': config.get_localized_string(70481)} for key, value in status.items(): if not value in title_estado: itemlist.append( - item.clone(title=typo(config.get_localized_string(70391) % value, 'bold'), action="addlist_mal", value=key, - estado=value)) + item.clone(title=typo(config.get_localized_string(70391) % value, 'bold'), action="addlist_mal", value=key, estado=value)) for i in range(10, 0, -1): if i != int(score): - itemlist.append(item.clone(title=typo(config.get_localized_string(70392) % (i), 'bold'), action="addlist_mal", - value=estado, estado=status[estado], score=i)) + itemlist.append(item.clone(title=typo(config.get_localized_string(70392) % (i), 'bold'), action="addlist_mal", value=estado, estado=status[estado], score=i)) return itemlist def addlist_mal(item): - data = httptools.downloadpage(item.url).data + data = match(item.url).data - anime_id = scrapertools.find_single_match(data, 'id="myinfo_anime_id" value="([^"]+)"') + anime_id = match(data, patron=r'id="myinfo_anime_id" value="([^"]+)"').match if item.value == "2": - vistos = scrapertools.find_single_match(data, 'id="myinfo_watchedeps".*?(\d+)') + vistos = match(data, patron=r'id="myinfo_watchedeps".*?(\d+)').match else: - vistos = scrapertools.find_single_match(data, 'id="myinfo_watchedeps".*?value="(\d+)"') + vistos = match(data, patron=r'id="myinfo_watchedeps".*?value="(\d+)"').match if not item.score: - item.score = scrapertools.find_single_match(data, 'id="myinfo_score".*?selected" value="(\d+)"') - token = scrapertools.find_single_match(data, "name='csrf_token' content='([^']+)'") + item.score = match(data, patron=r'id="myinfo_score".*?selected" value="(\d+)"').match + token = match(data, patron=r"name='csrf_token' content='([^']+)'").match post = {'anime_id': int(anime_id), 'status': int(item.value), 'score': int(item.score), 'num_watched_episodes': int(vistos), 'csrf_token': token} @@ -3239,7 +2895,7 @@ def addlist_mal(item): if item.lista: url = "https://myanimelist.net/ownlist/anime/edit.json" # data = httptools.downloadpage(url, post=jsontools.dump(post), headers=headers_mal, replace_headers=True).data - data = httptools.downloadpage(url, post=jsontools.dump(post), headers=headers_mal).data + data = match(url, post=jsontools.dump(post), headers=headers_mal).data item.title = "En tu lista" if config.is_xbmc(): import xbmc @@ -3248,7 +2904,7 @@ def addlist_mal(item): def move(item): import xbmcgui, xbmc - item_focus = str(item.extra) + item_focus = str(item.args) wnd = xbmcgui.Window(xbmcgui.getCurrentWindowId()) id = wnd.getFocusId() return xbmc.executebuiltin('Control.Move(' + str(id) + ',' + item_focus + ')') @@ -3257,18 +2913,17 @@ def move(item): def play(item): itemlist = [] if not item.server: - data = httptools.downloadpage(item.url).data + data = match(item.url).data if "Sorry, this video is not available to be embedded" in data: - id_video = scrapertools.find_single_match(data, '