diff --git a/channels/altadefinizionecommunity.py b/channels/altadefinizionecommunity.py
index 5b20ce99..49740139 100644
--- a/channels/altadefinizionecommunity.py
+++ b/channels/altadefinizionecommunity.py
@@ -24,28 +24,155 @@ def mainlist(item):
logger.debug(item)
film = ['/type/movie',
- # Voce Menu,['url','action','args',contentType]
- ('Generi', ['/type/movie', 'genres', 'genres']),
- ('Anni', ['/type/movie', 'genres', 'year']),
- # ('Qualità', ['', 'genres', 'quality']),
- ]
+ ('Generi', ['/type/movie', 'genres', 'genres']),
+ ('Anni', ['/type/movie', 'genres', 'year']),]
tvshow = ['/serie-tv/tvshow',
- # Voce Menu,['url','action','args',contentType]
- ('Generi', ['/serie-tv/tvshow', 'genres', 'genres']),
- ('Anni', ['/serie-tv/tvshow', 'genres', 'year']),
- # ('Qualità', ['', 'genres', 'quality']),
- ]
-
- # altri = [
- # # ('A-Z', ['/lista-film', 'genres', 'letters']),
- # ('Qualità', ['', 'genres', 'quality']),
- # ('Anni', ['/anno', 'genres', 'years'])
- # ]
+ ('Generi', ['/serie-tv/tvshow', 'genres', 'genres']),
+ ('Anni', ['/serie-tv/tvshow', 'genres', 'year'])]
return locals()
+def search(item, text):
+ logger.debug("search ", text)
+
+ item.args = 'search'
+ item.url = host + "/search?s={}&f={}&page=1".format(text, item.contentType)
+ try:
+ return peliculas(item)
+
+ # Continua la ricerca in caso di errore
+ except:
+ import sys
+ for line in sys.exc_info():
+ support.logger.error("%s" % line)
+ return []
+
+
+@support.scrape
+def genres(item):
+ logger.debug(item)
+ data = support.httptools.downloadpage(item.url).data
+ blacklist= ['Film', 'Serie TV']
+
+ if item.args == 'genres':
+ categories ={}
+ res = support.match(host + '/cerca', patron=r'for="cat-(\d+)[^>]+>([^<]+)').matches
+ for _id, name in res:
+ categories[name] = _id
+
+ patronBlock = r'{}(?P.*?)\s*(?P[^<]+)'
+
+ def itemHook(it):
+ it.cat_id = categories[it.fulltitle]
+ return it
+
+ if item.args == 'year':
+ patron = r'value="(?P[^"]+)"[^>]*>(?P\d+)'
+ patronBlock = r'Anno(?P.*?)'
+
+ elif item.args == 'quality':
+ patronMenu = r'quality/(?P[^"]+)">(?P[^<]+)'
+ patronBlock = r'Risoluzione(?P.*?)'
+
+ action = 'peliculas'
+ return locals()
+
+
+@support.scrape
+def peliculas(item):
+ item.quality = 'HD'
+ json = {}
+ params ={'type':item.contentType, 'anno':item.year_id, 'quality':item.quality_id, 'cat':item.cat_id, 'order':order}
+
+
+ if item.contentType == 'movie':
+ action = 'findvideos'
+ else:
+ action = 'episodios'
+ if not item.page: item.page = 1
+ try:
+ # support.dbg()
+ if item.args in ['search']:
+ page = support.httptools.downloadpage(item.url, headers=headers)
+ if page.json:
+ data = "\n".join(page.json['data'])
+ else:
+ data = page.data
+ else:
+ params['page'] = item.page
+
+ url = '{}/load-more-film?{}'.format(host, support.urlencode(params))
+ json = support.httptools.downloadpage(url, headers=headers).json
+ data = "\n".join(json['data'])
+ except:
+ data = ' '
+
+ patron = r'wrapFilm">\s*[^>]+>(?P\d+)(?:[^>]+>){2}(?P[^<]+)(?:[^>]+>){4}\s*
]+>){3}(?P[^<[]+)(?:\[(?P[sSuUbBiItTaA-]+))?'
+ # patron = r'wrapFilm">\s*[^>]+>(?P\d+)(?:[^>]+>){2}(?P[^<]+)(?:[^>]+>){2}(?P[^<]+)(?:[^>]+>){2}\s*
]+>){3}(?P[^<[]+)(?:\[(?P[sSuUbBiItTaA-]+))?'
+
+ # paginazione
+ if json.get('have_next') or 'have_next_film=true' in data:
+ def fullItemlistHook(itemlist):
+ cat_id = support.match(data, patron=r''''cat':"(\d+)"''').match
+ if cat_id: item.cat_id = cat_id
+ item.page += 1
+ support.nextPage(itemlist, item, function_or_level='peliculas')
+ return itemlist
+
+ return locals()
+
+
+@support.scrape
+def episodios(item):
+ logger.debug(item)
+ # debug = True
+ data = item.data
+ patron = r'class="playtvshow "\s+data-href="(?P[^"]+)'
+
+ def itemHook(it):
+ spl = it.url.split('/')[-2:]
+ it.infoLabels['season'] = int(spl[0])+1
+ it.infoLabels['episode'] = int(spl[1])+1
+ it.url = it.url.replace('/watch-unsubscribed', '/watch-external')
+ it.title = '{}x{:02d} - {}'.format(it.contentSeason, it.contentEpisodeNumber, it.fulltitle)
+ return it
+
+ return locals()
+
+
+def findvideos(item):
+ itemlist = []
+ resolve_url(item)
+
+ itemlist.append(item.clone(action='play', url=support.match(item.url, patron='allowfullscreen[^<]+src="([^"]+)"', cloudscraper=True).match, quality=''))
+
+ return support.server(item, itemlist=itemlist)
+
+
+def play(item):
+ if host in item.url: # intercetto il server proprietario
+ if registerOrLogin():
+ return support.get_jwplayer_mediaurl(support.httptools.downloadpage(item.url, cloudscraper=True).data, 'Diretto')
+ else:
+ platformtools.play_canceled = True
+ return []
+ else:
+ return [item]
+
+
+def resolve_url(item):
+ registerOrLogin()
+ if '/watch-unsubscribed' not in item.url and '/watch-external' not in item.url:
+ playWindow = support.match(support.httptools.downloadpage(item.url, cloudscraper=True).data, patron='playWindow" href="([^"]+)')
+ video_url = playWindow.match
+ item.data = playWindow.data
+ item.url = video_url.replace('/watch-unsubscribed', '/watch-external')
+ return item
+
+
def login():
r = support.httptools.downloadpage(host, cloudscraper=True)
Token = support.match(r.data, patron=r'name=\s*"_token"\s*value=\s*"([^"]+)', cloudscraper=True).match
@@ -130,139 +257,3 @@ def registerOrLogin():
return False
return True
-
-
-@support.scrape
-def peliculas(item):
- json = {}
- params ={'type':item.contentType, 'anno':item.year_id, 'quality':item.quality_id, 'order':order}
-
- # if item.contentType == 'undefined':
- # action = 'check'
- if item.contentType == 'movie':
- action = 'findvideos'
- else:
- action = 'episodios'
- if not item.page: item.page = 1
- try:
- if item.args == 'search':
- page = support.httptools.downloadpage(item.url, headers=headers, cloudscraper=True)
- if page.json:
- data = "\n".join(page.json['data'])
- else:
- data = page.data
- else:
- params['page'] = item.page
-
- url = '{}/load-more-film?{}'.format(host, support.urlencode(params))
- json = support.httptools.downloadpage(url, headers=headers, cloudscraper=True).json
- data = "\n".join(json['data'])
- except:
- data = ' '
-
- patron = r'wrapFilm">\s*\s*(?P[0-9]{4})\s*(?:]+>[^<]+)?\s*(?P[^<]+).*?
]+>.*?(?P[^<[]+)(?:\[(?P[sSuUbBiItTaA-]+))?'
- # paginazione
- if json.get('have_next'):
- def fullItemlistHook(itemlist):
- item.page += 1
- support.nextPage(itemlist, item, function_or_level='peliculas')
- return itemlist
-
- return locals()
-
-
-def search(item, texto):
- logger.debug("search ", texto)
-
- item.args = 'search'
- item.url = host + "/search?s={}&f={}&page=1".format(texto, item.contentType)
- try:
- return peliculas(item)
- # Continua la ricerca in caso di errore
- except:
- import sys
- for line in sys.exc_info():
- support.logger.error("%s" % line)
- return []
-
-
-@support.scrape
-def genres(item):
- logger.debug(item)
- data = support.httptools.downloadpage(item.url, cloudscraper=True).data
- blacklist= ['Film', 'Serie TV']
-
- patronBlock = r'{}(?P.*?)\s*[^"]+)">(?P[^<]+)'
-
- if item.args == 'year':
- patron = r'value="(?P[^"]+)">(?P\d+)'
- patronBlock = r'Anno(?P.*?)'
- elif item.args == 'quality':
- patronMenu = r'quality/(?P[^"]+)">(?P[^<]+)'
- patronBlock = r'Risoluzione(?P.*?)'
- # elif item.args == 'years':
- # item.contentType = 'undefined'
- # patronBlock = r'ANNO(?P.*?)'
- # else:
- # patronBlock = ('Film' if item.contentType == 'movie' else 'Serie TV') + r'
\s+