diff --git a/channels/0example.py.txt b/channels/0example.py.txt index f418da4a..40f8d6ed 100644 --- a/channels/0example.py.txt +++ b/channels/0example.py.txt @@ -76,8 +76,7 @@ def findhost(): # cancellare host non utilizzato host = scrapertoolsV2.find_single_match(permUrl, r'
', categoria) - findhost() + itemlist = [] item = Item() diff --git a/channels/cb01anime.py b/channels/cb01anime.py index b996eb58..dae08f83 100644 --- a/channels/cb01anime.py +++ b/channels/cb01anime.py @@ -6,8 +6,7 @@ from core import support -__channel__ = "cb01anime" -host = support.config.get_channel_url(__channel__) + '/anime' +host = support.config.get_channel_url() + '/anime' Blacklist = ['AVVISO IMPORTANTE – CB01.ROCKS', 'Lista Alfabetica Completa Anime/Cartoon', 'CB01.UNO ▶ TROVA L’INDIRIZZO UFFICIALE','Lista Richieste Up & Re-Up'] list_servers = ['verystream', 'openload', 'streamango', 'thevideome'] diff --git a/channels/cineblog01.py b/channels/cineblog01.py index e9acf907..19a10851 100644 --- a/channels/cineblog01.py +++ b/channels/cineblog01.py @@ -10,23 +10,17 @@ from core.item import Item from lib import unshortenit from platformcode import logger, config -#impostati dinamicamente da findhost() -host = "https://cb01.cx" -headers = "" - def findhost(): - pass - # global host, headers - # permUrl = httptools.downloadpage('https://www.cb01.uno/', follow_redirects=False).headers - # if 'google' in permUrl['location']: - # if host[:4] != 'http': - # host = 'https://'+permUrl['location'].replace('https://www.google.it/search?q=site:', '') - # else: - # host = permUrl['location'].replace('https://www.google.it/search?q=site:', '') - # else: - # host = permUrl['location'] - # headers = [['Referer', host]] + permUrl = httptools.downloadpage('https://www.cb01.uno/', follow_redirects=False).headers + if 'google' in permUrl['location']: + host = permUrl['location'].replace('https://www.google.it/search?q=site:', '') + else: + host = permUrl['location'] + return host + +host = config.get_channel_url(findhost) +headers = [['Referer', host]] list_servers = ['verystream', 'openload', 'streamango', 'wstream'] list_quality = ['HD', 'SD', 'default'] @@ -37,7 +31,6 @@ checklinks_number = config.get_setting('checklinks_number', 'cineblog01') @support.menu def mainlist(item): - findhost() film = [ ('HD', ['', 'menu', 'Film HD Streaming']), ('Generi', ['', 'menu', 'Film per Genere']), @@ -60,7 +53,6 @@ def mainlist(item): @support.scrape def menu(item): - findhost() patronBlock = item.args + r'<\/span>.*?(?P.*?)<\/ul>' patronMenu = r'href="?(?P[^">]+)"?>(?P.*?)<\/a>' action = 'peliculas' @@ -70,7 +62,7 @@ def menu(item): # @support.scrape # def newest(categoria): -# findhost() +# # # debug = True # patron = r'<a href="?(?P<url>[^">]+)"?>(?P<title>[^<([]+)(?:\[(?P<lang>Sub-ITA|B/N|SUB-ITA)\])?\s*(?:\[(?P<quality>HD|SD|HD/3D)\])?\s*\((?P<year>[0-9]{4})\)<\/a>' @@ -100,7 +92,7 @@ def menu(item): def newest(categoria): support.log(categoria) - findhost() + item = support.Item() try: if categoria == "series": @@ -175,7 +167,7 @@ def episodios(item): def findvideos(item): - findhost() + if item.contentType == "episode": return findvid_serie(item) diff --git a/channels/cinemalibero.py b/channels/cinemalibero.py index 3ebd21c3..d39fc1f8 100644 --- a/channels/cinemalibero.py +++ b/channels/cinemalibero.py @@ -12,8 +12,7 @@ from platformcode import config list_servers = ['akstream', 'wstream', 'backin', 'clipwatching', 'cloudvideo', 'verystream', 'onlystream', 'mixdrop'] list_quality = ['default'] -__channel__ = "cinemalibero" -host = config.get_channel_url(__channel__) +host = config.get_channel_url() headers = [['Referer', host]] @support.menu diff --git a/channels/documentaristreamingda.py b/channels/documentaristreamingda.py index 876a3a95..80b2bb76 100644 --- a/channels/documentaristreamingda.py +++ b/channels/documentaristreamingda.py @@ -10,8 +10,7 @@ from core import httptools, scrapertools, servertools, support from core.item import Item from platformcode import logger, config -__channel__ = "documentaristreamingda" -host = config.get_channel_url(__channel__) +host = config.get_channel_url() list_servers = [''] list_quality = [''] diff --git a/channels/dreamsub.py b/channels/dreamsub.py index 4e69bb3d..962f01b6 100644 --- a/channels/dreamsub.py +++ b/channels/dreamsub.py @@ -51,8 +51,7 @@ from core import scrapertoolsV2, httptools, servertools, tmdb from core.item import Item ##### fine import -__channel__ = "dreamsub" -host = config.get_channel_url(__channel__) +host = config.get_channel_url() headers = [['Referer', host]] # server di esempio... diff --git a/channels/eurostreaming.py b/channels/eurostreaming.py index 1547180a..f0b1432e 100644 --- a/channels/eurostreaming.py +++ b/channels/eurostreaming.py @@ -35,7 +35,7 @@ list_quality = ['default'] @support.menu def mainlist(item): support.log() - findhost() + tvshow = ['' ] @@ -113,7 +113,7 @@ def pagina(url): # =========== def ricerca ============= def search(item, texto): support.log() - findhost() + item.url = "%s/?s=%s" % (host, texto) item.contentType = 'tvshow' @@ -131,7 +131,7 @@ def search(item, texto): def newest(categoria): support.log() - findhost() + itemlist = [] item = Item() item.contentType = 'tvshow' diff --git a/channels/fastsubita.py b/channels/fastsubita.py index ef6d52ff..6acad4aa 100644 --- a/channels/fastsubita.py +++ b/channels/fastsubita.py @@ -21,8 +21,7 @@ from core.item import Item from core.support import log from platformcode import config -__channel__ = 'fastsubita' -host = config.get_channel_url(__channel__) +host = config.get_channel_url() headers = [['Referer', host]] list_servers = ['verystream', 'openload', 'speedvideo', 'wstream', 'flashx', 'vidoza', 'vidtome'] list_quality = ['default'] diff --git a/channels/filmigratis.py b/channels/filmigratis.py index a40c92aa..284f381c 100644 --- a/channels/filmigratis.py +++ b/channels/filmigratis.py @@ -17,8 +17,7 @@ from core import servertools, httptools, support from core.item import Item from platformcode import config -__channel__ = 'filmigratis' -host = config.get_channel_url(__channel__) +host = config.get_channel_url() list_servers = ['verystream', 'openload', 'streamango', 'vidoza', 'okru'] list_quality = ['1080p', '720p', '480p', '360'] diff --git a/channels/filmpertutti.py b/channels/filmpertutti.py index 6e1899ab..fb2a18e8 100644 --- a/channels/filmpertutti.py +++ b/channels/filmpertutti.py @@ -22,8 +22,7 @@ from core.item import Item from platformcode import config -__channel__ = 'filmpertutti' -host = config.get_channel_url(__channel__) +host = config.get_channel_url() headers = [['Referer', host]] list_servers = ['speedvideo', 'verystream', 'openload', 'streamango', 'wstream', 'akvideo'] list_quality = ['HD', 'SD'] diff --git a/channels/filmsenzalimiticc.py b/channels/filmsenzalimiticc.py index f4e25faf..2f3fd290 100644 --- a/channels/filmsenzalimiticc.py +++ b/channels/filmsenzalimiticc.py @@ -14,8 +14,7 @@ from platformcode import logger from specials import autoplay # Necessario per Autoplay -__channel__ = 'filmsenzalimiticc' -host = config.get_channel_url(__channel__) +host = config.get_channel_url() IDIOMAS = {'Italiano': 'IT'} list_language = IDIOMAS.values() diff --git a/channels/guardaserieclick.py b/channels/guardaserieclick.py index 1e129c45..99380efd 100644 --- a/channels/guardaserieclick.py +++ b/channels/guardaserieclick.py @@ -19,8 +19,7 @@ from core.item import Item from platformcode import config from core.support import log -__channel__ = 'guardaserieclick' -host = config.get_channel_url(__channel__) +host = config.get_channel_url() headers = [['Referer', host]] list_servers = ['speedvideo', 'openload'] diff --git a/channels/ilgeniodellostreaming.py b/channels/ilgeniodellostreaming.py index 5f79d839..10defaf6 100644 --- a/channels/ilgeniodellostreaming.py +++ b/channels/ilgeniodellostreaming.py @@ -38,8 +38,7 @@ from core.support import log from core.item import Item from platformcode import config -__channel__ = 'ilgeniodellostreaming' -host = config.get_channel_url(__channel__) +host = config.get_channel_url() list_servers = ['verystream', 'openload', 'streamango'] list_quality = ['default'] diff --git a/channels/italiaserie.py b/channels/italiaserie.py index 4a072910..dfdaaa20 100644 --- a/channels/italiaserie.py +++ b/channels/italiaserie.py @@ -19,8 +19,7 @@ from core import support, httptools, scrapertoolsV2 from core.item import Item from platformcode import config -__channel__ = 'italiaserie' -host = config.get_channel_url(__channel__) +host = config.get_channel_url() headers = [['Referer', host]] list_servers = ['speedvideo'] diff --git a/channels/mondoserietv.py b/channels/mondoserietv.py index 3b77b9e7..220997f0 100644 --- a/channels/mondoserietv.py +++ b/channels/mondoserietv.py @@ -5,8 +5,7 @@ from core import support -__channel__ = "mondoserietv" -host = support.config.get_channel_url(__channel__) +host = support.config.get_channel_url() IDIOMAS = {'Italiano': 'IT'} list_language = IDIOMAS.values() diff --git a/channels/netfreex.py b/channels/netfreex.py index e0be74ca..ec192c87 100644 --- a/channels/netfreex.py +++ b/channels/netfreex.py @@ -7,8 +7,7 @@ from core import support from core.item import Item from platformcode import logger, config -__channel__ = "netfreex" -host = config.get_channel_url(__channel__) +host = config.get_channel_url() headers = "" IDIOMAS = {'Italiano': 'IT'} diff --git a/channels/piratestreaming.py b/channels/piratestreaming.py index 0c72b846..c8b797a3 100644 --- a/channels/piratestreaming.py +++ b/channels/piratestreaming.py @@ -7,8 +7,7 @@ from core import support from core.support import config, log -__channel__ = "piratestreaming" -host = config.get_channel_url(__channel__) +host = config.get_channel_url() list_servers = ['mixdrop', 'speedvideo', 'gounlimited', 'onlystream', 'youtube'] list_quality = ['default'] diff --git a/channels/polpotv.py b/channels/polpotv.py index 98ed41e0..71e9560d 100644 --- a/channels/polpotv.py +++ b/channels/polpotv.py @@ -9,8 +9,7 @@ from core.item import Item from platformcode import config import json, datetime -__channel__ = "polpotv" -host = config.get_channel_url(__channel__) +host = config.get_channel_url() headers = [['Accept', 'application/ld+json']] diff --git a/channels/seriehd.py b/channels/seriehd.py index 1c56836d..70878705 100644 --- a/channels/seriehd.py +++ b/channels/seriehd.py @@ -7,8 +7,7 @@ from core import scrapertoolsV2, httptools, support from core.item import Item -__channel__ = 'seriehd' -host = support.config.get_channel_url(__channel__) +host = support.config.get_channel_url() # host = 'https://www.seriehd.watch' headers = '' @@ -26,7 +25,7 @@ list_quality = ['1080p', '720p', '480p', '360'] @support.menu def mainlist(item): - findhost() + tvshow = [('Genere', ['', 'genre']), ('Americane', ['/serie-tv-streaming/serie-tv-americane', 'peliculas']), ('Italiane', ['/serie-tv-streaming/serie-tv-italiane', 'peliculas']),] @@ -73,7 +72,7 @@ def genre(item): def search(item, texto): support.log(texto) - findhost() + item.contentType = 'tvshow' item.url = host + "/?s=" + texto @@ -88,7 +87,7 @@ def search(item, texto): def newest(categoria): support.log(categoria) - findhost() + itemlist = [] item = support.Item() try: diff --git a/channels/serietvonline.py b/channels/serietvonline.py index 636ca41e..b3dca249 100644 --- a/channels/serietvonline.py +++ b/channels/serietvonline.py @@ -39,7 +39,7 @@ list_quality = ['default'] @support.menu def mainlist(item): support.log() - findhost() + film = ['/ultimi-film-aggiunti/', ('Lista', ['/lista-film/', 'peliculas', 'lista']) @@ -129,7 +129,7 @@ def episodios(item): def search(item, text): support.log("CERCA :" ,text, item) - findhost() + item.url = "%s/?s=%s" % (host, text) try: @@ -144,7 +144,7 @@ def search(item, text): def newest(categoria): support.log(categoria) - findhost() + itemlist = [] item = Item() diff --git a/channels/serietvsubita.py b/channels/serietvsubita.py index 659a90fb..1345fffa 100644 --- a/channels/serietvsubita.py +++ b/channels/serietvsubita.py @@ -12,8 +12,7 @@ from core.item import Item from core.support import log from platformcode import logger, config -__channel__ = "serietvsubita" -host = config.get_channel_url(__channel__) +host = config.get_channel_url() headers = [['Referer', host]] IDIOMAS = {'Italiano': 'IT'} diff --git a/channels/serietvu.py b/channels/serietvu.py index 35afa4bb..6460bcd4 100644 --- a/channels/serietvu.py +++ b/channels/serietvu.py @@ -13,8 +13,7 @@ from core.item import Item from core.support import log from platformcode import config -__channel__ = 'serietvu' -host = config.get_channel_url(__channel__) +host = config.get_channel_url() headers = [['Referer', host]] list_servers = ['speedvideo'] diff --git a/channels/streamingaltadefinizione.py b/channels/streamingaltadefinizione.py index 1123b72f..b964d84d 100644 --- a/channels/streamingaltadefinizione.py +++ b/channels/streamingaltadefinizione.py @@ -30,7 +30,7 @@ def findhost(): @support.menu def mainlist(item): - findhost() + film = ["/film/"] anime = ["/genere/anime/"] tvshow = ["/serietv/"] @@ -56,17 +56,17 @@ def generos(item): def peliculas(item): - findhost() + return support.dooplay_peliculas(item, True if "/genere/" in item.url else False) def episodios(item): - findhost() + return support.dooplay_get_episodes(item) def findvideos(item): - findhost() + itemlist = [] for link in support.dooplay_get_links(item, host): if link['title'] != 'Guarda il trailer': diff --git a/channels/streamtime.py b/channels/streamtime.py index 9301a723..8df2fbe4 100644 --- a/channels/streamtime.py +++ b/channels/streamtime.py @@ -9,8 +9,7 @@ Nota per i tester: questo non è un canale 'tradizionale', essendo un canale tel la lista delle pagine non sarà affatto 'uniforme' (a seconda di come viene presentata la preview) """ -__channel__ = "streamtime" -host = config.get_channel_url(__channel__) +host = config.get_channel_url() headers = [['Referer', 'org.telegram.messenger']] list_servers = ['directo'] list_quality = ['default'] diff --git a/channels/tantifilm.py b/channels/tantifilm.py index 92929123..8c3d9c6a 100644 --- a/channels/tantifilm.py +++ b/channels/tantifilm.py @@ -34,7 +34,7 @@ list_quality = ['default'] @support.menu def mainlist(item): log() - findhost() + #top = [(support.typo('Novità Film/Serie/Anime/Altro', 'bold'),['/film/'])] top = [('Novità Film/Serie/Anime/Altro', ['/film/', 'peliculas', 'all'])] @@ -62,7 +62,7 @@ def mainlist(item): @support.scrape def peliculas(item): log() - findhost() + if item.args == 'search': patron = r'<a href="(?P<url>[^"]+)" title="Permalink to\s(?P<title>[^"]+) \((?P<year>[^<]+)\).*?".*?<img[^s]+src="(?P<thumb>[^"]+)".*?<div class="calitate">\s*<p>(?P<quality>[^<]+)<\/p>' @@ -82,7 +82,7 @@ def peliculas(item): @support.scrape def episodios(item): log() - findhost() + if not item.data: data_check = httptools.downloadpage(item.url, headers=headers).data data_check = re.sub('\n|\t', ' ', data_check) @@ -125,7 +125,7 @@ def player_or_not(item): def category(item): log() - findhost() + blacklist = ['Serie TV Altadefinizione', 'HD AltaDefinizione', 'Al Cinema', 'Serie TV', 'Miniserie', 'Programmi Tv', 'Live', 'Trailers', 'Serie TV Aggiornate', 'Aggiornamenti', 'Featured'] itemlist = support.scrape(item, '<li><a href="([^"]+)"><span></span>([^<]+)</a></li>', ['url', 'title'], headers, blacklist, patron_block='<ul class="table-list">(.*?)</ul>', action='peliculas') return support.thumb(itemlist) @@ -163,7 +163,7 @@ def anime(item): def search(item, texto): log(texto) - findhost() + item.url = host + "/?s=" + texto try: @@ -276,7 +276,6 @@ def findvideos(item): url = '\t' + scrapertoolsV2.find_single_match(page,'<meta name="og:url" content="([^=]+)">') if url: listurl.add(url) - support.dbg() return support.server(item, data=listurl if listurl else data)#, headers=headers) # return itemlist diff --git a/channels/toonitalia.py b/channels/toonitalia.py index 693861cc..7736f26d 100644 --- a/channels/toonitalia.py +++ b/channels/toonitalia.py @@ -5,8 +5,7 @@ from core import support -__channel__ = "toonitalia" -host = support.config.get_channel_url(__channel__) +host = support.config.get_channel_url() headers = [['Referer', host]] diff --git a/channels/vedohd.py b/channels/vedohd.py index 1c71a669..094934c2 100644 --- a/channels/vedohd.py +++ b/channels/vedohd.py @@ -8,8 +8,7 @@ from core.item import Item from platformcode import logger, config from specials import autoplay -__channel__ = "vedohd" -host = config.get_channel_url(__channel__) +host = config.get_channel_url() headers = "" IDIOMAS = {'Italiano': 'IT'} diff --git a/channels/vvvvid.py b/channels/vvvvid.py index 29a4e4a2..6ddacfbf 100644 --- a/channels/vvvvid.py +++ b/channels/vvvvid.py @@ -8,8 +8,7 @@ from core.item import Item from specials import autorenumber from lib.concurrent import futures -__channel__ = "vvvvid" -host = support.config.get_channel_url(__channel__) +host = support.config.get_channel_url() # Creating persistent session current_session = requests.Session() diff --git a/core/support.py b/core/support.py index ad71e8e6..80bb7548 100755 --- a/core/support.py +++ b/core/support.py @@ -377,7 +377,16 @@ def scrape(func): log('PATRON= ', patron) if not data: - data = httptools.downloadpage(item.url, headers=headers, ignore_response_code=True, session=item.session).data.replace("'", '"') + page = httptools.downloadpage(item.url, headers=headers, ignore_response_code=True, session=item.session) + # if url may be changed and channel has findhost to update + if (not page.data or scrapertoolsV2.get_domain_from_url(page.url) != scrapertoolsV2.get_domain_from_url(item.url)) and 'findhost' in func.__globals__: + host = func.__globals__['findhost']() + from core import jsontools + jsontools.update_node(host, func.__module__.split('.')[-1], 'url') + item.url = item.url.replace(scrapertoolsV2.get_domain_from_url(item.url), scrapertoolsV2.get_domain_from_url(host)) + page = httptools.downloadpage(item.url, headers=headers, ignore_response_code=True, + session=item.session) + data = page.data.replace("'", '"') data = re.sub('\n|\t', ' ', data) data = re.sub(r'>\s+<', '> <', data) # replace all ' with " and eliminate newline, so we don't need to worry about diff --git a/platformcode/config.py b/platformcode/config.py index ba6813fc..386e4b99 100644 --- a/platformcode/config.py +++ b/platformcode/config.py @@ -90,16 +90,24 @@ def is_xbmc(): def get_videolibrary_support(): return True -def get_channel_url(name): - try: - import json - except: - import simplejson as json - ROOT_DIR = xbmc.translatePath(__settings__.getAddonInfo('Path')) - LOCAL_FILE = os.path.join(ROOT_DIR, "channels.json") - with open(LOCAL_FILE) as f: - data = json.load(f) - return data[name] +def get_channel_url(findhostMethod=None): + from core import jsontools + import inspect + + frame = inspect.stack()[1] + name = os.path.basename(frame[0].f_code.co_filename).replace('.py', '') + if findhostMethod: + url = jsontools.get_node_from_file(name, 'url') + if not url: + url = findhostMethod() + jsontools.update_node(url, name, 'url') + return url + else: + ROOT_DIR = xbmc.translatePath(__settings__.getAddonInfo('Path')) + LOCAL_FILE = os.path.join(ROOT_DIR, "channels.json") + with open(LOCAL_FILE) as f: + data = jsontools.load(f.read()) + return data[name] def get_system_platform(): """ fonction: pour recuperer la platform que xbmc tourne """