def tvshow(self, imdb, tvdb, tvshowtitle, localtvshowtitle, aliases, year): try: tv_maze = tvmaze.tvMaze() tvshowtitle = tv_maze.showLookup('thetvdb', tvdb) tvshowtitle = tvshowtitle['name'] t = cleantitle.get(tvshowtitle) q = urlparse.urljoin(self.base_link, self.search_link) q = q % urllib.quote_plus(tvshowtitle) r = client.request(q) r = client.parseDOM(r, 'ul', attrs={'class': 'items'}) r = client.parseDOM(r, 'li') r = [(client.parseDOM(i, 'a', ret='href'), client.parseDOM(i, 'a', ret='title'), re.findall('\d{4}', i)) for i in r] r = [(i[0][0], i[1][0], i[2][-1]) for i in r if i[0] and i[1] and i[2]] r = [i for i in r if t == cleantitle.get(i[1]) and year == i[2]] r = r[0][0] url = re.findall('(?://.+?|)(/.+)', r)[0] url = client.replaceHTMLCodes(url) url = url.encode('utf-8') return url except: failure = traceback.format_exc() log_utils.log('GoGoAnime - Exception: \n' + str(failure)) return
def tvshow(self, imdb, tvdb, tvshowtitle, year): try: r = 'search/tvdb/%s?type=show&extended=full' % tvdb r = json.loads(trakt.getTrakt(r)) if not r: return '0' d = r[0]['show']['genres'] if not ('anime' in d or 'animation' in d): return '0' tv_maze = tvmaze.tvMaze() tvshowtitle = tv_maze.showLookup('thetvdb', tvdb) tvshowtitle = tvshowtitle['name'] t = cleantitle.get(tvshowtitle) q = urlparse.urljoin(self.base_link, self.search_link) q = q % urllib.quote_plus(tvshowtitle) r = client.request(q) r = client.parseDOM(r, 'ul', attrs={'class': 'items'}) r = client.parseDOM(r, 'li') r = [(client.parseDOM(i, 'a', ret='href'), client.parseDOM(i, 'a', ret='title'), re.findall('\d{4}', i)) for i in r] r = [(i[0][0], i[1][0], i[2][-1]) for i in r if i[0] and i[1] and i[2]] r = [i for i in r if t == cleantitle.get(i[1]) and year == i[2]] r = r[0][0] url = re.findall('(?://.+?|)(/.+)', r)[0] url = client.replaceHTMLCodes(url) url = url.encode('utf-8') return url except: return
def sources(self, url, hostDict, hostprDict): sources = [] try: if not url: return sources data = urlparse.parse_qs(url) data = dict([(i, data[i][0]) if data[i] else (i, '') for i in data]) tvshowtitle = data.get('tvshowtitle') localtvshowtitle = data.get('localtvshowtitle') aliases = source_utils.aliases_to_array(eval(data['aliases'])) episode = tvmaze.tvMaze().episodeAbsoluteNumber(data.get('tvdb'), int(data.get('season')), int(data.get('episode'))) alt_title = anilist.getAlternativTitle(tvshowtitle) links = self.__search([alt_title] + aliases, episode) if not links and localtvshowtitle != alt_title: links = self.__search([localtvshowtitle] + aliases, episode) if not links and tvshowtitle != localtvshowtitle: links = self.__search([tvshowtitle] + aliases, episode) for link in links: valid, host = source_utils.is_host_valid(link, hostDict) if not valid: continue sources.append({'source': host, 'quality': 'SD', 'language': 'de', 'url': link, 'direct': False, 'debridonly': False}) return sources except: return sources
def tvshow(self, imdb, tvdb, tvshowtitle, localtvshowtitle, aliases, year): try: tv_maze = tvmaze.tvMaze() tvshowtitle = tv_maze.showLookup('thetvdb', tvdb) tvshowtitle = tvshowtitle['name'] t = cleantitle.get(tvshowtitle) q = self.search_link % (urllib.quote_plus(tvshowtitle)) q = urlparse.urljoin(self.base_link, q) r = client.request(q) r = client.parseDOM(r, 'ol', attrs = {'id': 'searchresult'})[0] r = client.parseDOM(r, 'h2') r = [(client.parseDOM(i, 'a', ret='href'), client.parseDOM(i, 'a')) for i in r] r = [(i[0][0], i[1][0]) for i in r if len(i[0]) > 0 and len(i[1]) > 0] r = [(i[0], re.sub('<.+?>|</.+?>','', i[1])) for i in r] r = [i for i in r if t == cleantitle.get(i[1])] r = r[-1][0] url = re.findall('(?://.+?|)(/.+)', r)[0] url = client.replaceHTMLCodes(url) url = url.encode('utf-8') return url except: return
def tvshow(self, imdb, tvdb, tvshowtitle, localtvshowtitle, year): try: r = 'search/tvdb/%s?type=show&extended=full' % tvdb r = json.loads(trakt.getTrakt(r)) if not r: return '0' d = r[0]['show']['genres'] if not ('anime' in d or 'animation' in d): return '0' tv_maze = tvmaze.tvMaze() tvshowtitle = tv_maze.showLookup('thetvdb', tvdb) tvshowtitle = tvshowtitle['name'] t = cleantitle.get(tvshowtitle) q = self.search_link % (urllib.quote_plus(tvshowtitle)) q = urlparse.urljoin(self.base_link, q) r = client.request(q) r = client.parseDOM(r, 'ol', attrs = {'id': 'searchresult'})[0] r = client.parseDOM(r, 'h2') r = [(client.parseDOM(i, 'a', ret='href'), client.parseDOM(i, 'a')) for i in r] r = [(i[0][0], i[1][0]) for i in r if len(i[0]) > 0 and len(i[1]) > 0] r = [(i[0], re.sub('<.+?>|</.+?>','', i[1])) for i in r] r = [i for i in r if t == cleantitle.get(i[1])] r = r[-1][0] url = re.findall('(?://.+?|)(/.+)', r)[0] url = client.replaceHTMLCodes(url) url = url.encode('utf-8') return url except: return
def tvshow(self, imdb, tvdb, tvshowtitle, localtvshowtitle, year): try: if not self.__is_anime('show', 'tvdb', tvdb): return url = self.__search([tvshowtitle, localtvshowtitle, tvmaze.tvMaze().showLookup('thetvdb', tvdb).get('name')], year) return urllib.urlencode({'url': url}) if url else None except: return
def tvshow(self, imdb, tvdb, tvshowtitle, localtvshowtitle, aliases, year): try: url = self.__search(self.tvsearch_link, tvshowtitle, year) if not url: url = self.__search(self.tvsearch_link, tvshowtitle + '-', year) if not url: url = self.__search(self.tvsearch_link, tvmaze.tvMaze().getTVShowTranslation(tvdb, 'es'), year) return url except: return
def episode(self, url, imdb, tvdb, title, premiered, season, episode): try: if not url: return return urllib.urlencode({'url': url, 'episode': tvmaze.tvMaze().episodeAbsoluteNumber(tvdb, int(season), int(episode))}) except: return
def tvshow(self, imdb, tvdb, tvshowtitle, localtvshowtitle, aliases, year): try: if not source_utils.is_anime('show', 'tvdb', tvdb): return url = self.__search([tvshowtitle, localtvshowtitle, tvmaze.tvMaze().showLookup('thetvdb', tvdb).get('name')] + source_utils.aliases_to_array(aliases), year) return urllib.urlencode({'url': url}) if url else None except: return
def tvshow(self, imdb, tvdb, tvshowtitle, localtvshowtitle, aliases, year): try: url = None for title in [tvshowtitle, localtvshowtitle, tvmaze.tvMaze().showLookup('thetvdb', tvdb).get('name')] + source_utils.aliases_to_array(aliases): if url: break url = self.__search(title) return urllib.urlencode({'url': url}) if url else None except: return
def tvshow(self, imdb, tvdb, tvshowtitle, localtvshowtitle, aliases, year): try: url = self.__search([localtvshowtitle] + source_utils.aliases_to_array(aliases), year) if not url and tvshowtitle != localtvshowtitle: url = self.__search( [tvshowtitle] + source_utils.aliases_to_array(aliases), year) if not url: url = self.__search(tvmaze.tvMaze().getTVShowTranslation(tvdb, 'el'), year) return url except: return
def sources(self, url, hostDict, hostprDict): sources = [] try: if not url: return sources data = urlparse.parse_qs(url) data = dict([(i, data[i][0]) if data[i] else (i, '') for i in data]) url = data.get('url') season = data.get('season') episode = data.get('episode') abs_episode = 0 if season and episode: abs_episode = str(tvmaze.tvMaze().episodeAbsoluteNumber(data.get('tvdb'), int(season), int(episode))) url = urlparse.urljoin(self.base_link, url) r = client.request(url) r = r.decode('cp1251').encode('utf-8') r = dom_parser.parse_dom(r, 'div', attrs={'class': 'players'}, req='data-player') r = [(i.attrs['data-player'], dom_parser.parse_dom(i, 'a', req='href')) for i in r] r = [(i[0], i[1][0].attrs['href']) for i in r if i[1]] for post_id, play_url in r: i = client.request(play_url, referer=url, output='extended') headers = i[3] headers.update({'Cookie': i[2].get('Set-Cookie')}) i = client.request(urlparse.urljoin(self.base_link, self.player_link), post={'post_id': post_id}, headers=headers, referer=i, XHR=True) i = json.loads(i).get('message', {}).get('translations', {}).get('flash', {}) for title, link in i.iteritems(): try: link = self.decode_direct_media_url(link) if link.endswith('.txt'): link = self.decode_direct_media_url(client.request(link)) link = json.loads(link).get('playlist', []) link = [i.get('playlist', []) for i in link] link = [x.get('file') for i in link for x in i if (x.get('season') == season and x.get('serieId') == episode) or (x.get('season') == '0' and x.get('serieId') == abs_episode)][0] urls = [(source_utils.label_to_quality(q), self.format_direct_link(link, q)) for q in self.get_qualitys(link)] urls = [{'quality': x[0], 'url': x[1]} for x in urls if x[0] in ['SD', 'HD']] # filter premium for i in urls: sources.append({'source': 'CDN', 'quality': i['quality'], 'info': title, 'language': 'ru', 'url': i['url'], 'direct': True, 'debridonly': False}) except: pass return sources except: return sources
def episode(self, url, imdb, tvdb, title, premiered, season, episode): try: if not url: return episode = tvmaze.tvMaze().episodeAbsoluteNumber(tvdb, int(season), int(episode)) data = urlparse.parse_qs(url) data = dict([(i, data[i][0]) if data[i] else (i, '') for i in data]) data.update({'episode': episode}) return urllib.urlencode(data) except: return
def episode(self, url, imdb, tvdb, title, premiered, season, episode): try: if not url: return tv_maze = tvmaze.tvMaze() num = tv_maze.episodeAbsoluteNumber(tvdb, int(season), int(episode)) url = self.base_link + self.show_link % (url, num) return url except: return
def tvshow(self, imdb, tvdb, tvshowtitle, localtvshowtitle, aliases, year): try: if not source_utils.is_anime('show', 'tvdb', tvdb): return url = self.__search([ tvshowtitle, localtvshowtitle, tvmaze.tvMaze().showLookup('thetvdb', tvdb).get('name') ] + source_utils.aliases_to_array(aliases), year) return urllib.urlencode({'url': url}) if url else None except: return
def getLocalTitle(self, title, imdb, tvdb, content): lang = self._getPrimaryLang() if not lang: return title if content == 'movie': t = trakt.getMovieTranslation(imdb, lang) else: t = tvmaze.tvMaze().getTVShowTranslation(tvdb, lang) return t or title
def tvshow(self, imdb, tvdb, tvshowtitle, localtvshowtitle, year): try: if not self.__is_anime('show', 'tvdb', tvdb): return url = self.__search([ tvshowtitle, localtvshowtitle, tvmaze.tvMaze().showLookup('thetvdb', tvdb).get('name') ], year) return urllib.urlencode({'url': url}) if url else None except: return
def getLocalTitle(self, title, imdb, tvdb, content): lang = self._getPrimaryLang() if not lang: return title if content == 'movie': t = trakt.getMovieTranslation(imdb, lang) else: t = tvmaze.tvMaze().getTVShowTranslation(tvdb, lang) return t or title
def tvshow(self, imdb, tvdb, tvshowtitle, localtvshowtitle, aliases, year): try: url = None for title in [ tvshowtitle, localtvshowtitle, tvmaze.tvMaze().showLookup('thetvdb', tvdb).get('name') ] + source_utils.aliases_to_array(aliases): if url: break url = self.__search(title) return urllib.urlencode({'url': url}) if url else None except: return
def episode(self, url, imdb, tvdb, title, premiered, season, episode): try: if url == None: return tv_maze = tvmaze.tvMaze() num = tv_maze.episodeAbsoluteNumber(tvdb, int(season), int(episode)) url = [i for i in url.strip('/').split('/')][-1] url = self.episode_link % (url, num) return url except: return
def episode(self, url, imdb, tvdb, title, premiered, season, episode): try: if url == None: return tv_maze = tvmaze.tvMaze() num = tv_maze.episodeAbsoluteNumber(tvdb, int(season), int(episode)) url = [i for i in url.strip('/').split('/')][-1] url = self.episode_link % (url, num) return url except: return
def episode(self, url, imdb, tvdb, title, premiered, season, episode): try: if url == None: return tv_maze = tvmaze.tvMaze() num = tv_maze.episodeAbsoluteNumber(tvdb, int(season), int(episode)) url = self.episode_link % (url.replace('http://www.animeshow.tv/', '').replace('/', ''), num) return url except: return
def tvshow(self, imdb, tvdb, tvshowtitle, localtvshowtitle, aliases, year): try: url = self.__search(localtvshowtitle, year) if not url and tvshowtitle != localtvshowtitle: url = self.__search(tvshowtitle, year) if not url and source_utils.is_anime('show', 'tvdb', tvdb): url = self.__search( tvmaze.tvMaze().showLookup('thetvdb', tvdb).get('name'), year) return url except: return
def episode(self, url, imdb, tvdb, title, premiered, season, episode): try: if not url: return episode = tvmaze.tvMaze().episodeAbsoluteNumber(tvdb, int(season), int(episode)) data = urlparse.parse_qs(url) data = dict([(i, data[i][0]) if data[i] else (i, '') for i in data]) data.update({'episode': episode}) return urllib.urlencode(data) except: return
def getLocalTitle(self, title, imdb, tvdb, content): langDict = {'German': 'de', 'German+English': 'de', 'French': 'fr', 'French+English': 'fr', 'Portuguese': 'pt', 'Portuguese+English': 'pt', 'Polish': 'pl', 'Polish+English': 'pl', 'Korean': 'ko', 'Korean+English': 'ko'} name = control.setting('providers.lang') lang = langDict.get(name) if not lang: return title if content == 'movie': t = trakt.getMovieTranslation(imdb, lang) else: t = tvmaze.tvMaze().getTVShowTranslation(tvdb, lang) return t or title
def tvshow(self, imdb, tvdb, tvshowtitle, localtvshowtitle, aliases, year): try: url = self.__search(self.tvsearch_link, tvshowtitle, year) if not url: url = self.__search(self.tvsearch_link, tvshowtitle + '-', year) if not url: url = self.__search( self.tvsearch_link, tvmaze.tvMaze().getTVShowTranslation(tvdb, 'es'), year) return url except: return
def getLocalTitle(self, title, imdb, tvdb, content): langDict = {'German': 'de', 'German+English': 'de', 'French': 'fr', 'French+English': 'fr', 'Portuguese': 'pt', 'Portuguese+English': 'pt'} name = control.setting('providers.lang') lang = langDict.get(name) if not lang: return title if content == 'movie': t = trakt.getMovieTranslation(imdb, lang) else: t = tvmaze.tvMaze().getTVShowTranslation(tvdb, lang) return t or title
def episode(self, url, imdb, tvdb, title, premiered, season, episode): try: if not url: return return urllib.urlencode({ 'url': url, 'episode': tvmaze.tvMaze().episodeAbsoluteNumber(tvdb, int(season), int(episode)) }) except: return
def tvshow(self, imdb, tvdb, tvshowtitle, localtvshowtitle, aliases, year): try: url = self.__search([localtvshowtitle] + source_utils.aliases_to_array(aliases), year) if not url and tvshowtitle != localtvshowtitle: url = self.__search([tvshowtitle] + source_utils.aliases_to_array(aliases), year) if not url: url = self.__search( tvmaze.tvMaze().getTVShowTranslation(tvdb, 'el'), year) return url except: return
def episode(self, url, imdb, tvdb, title, premiered, season, episode): try: if url == None: return tv_maze = tvmaze.tvMaze() num = tv_maze.episodeAbsoluteNumber(tvdb, int(season), int(episode)) url = [i for i in url.strip('/').split('/')][-1] url = self.episode_link % (url, num) return url except: failure = traceback.format_exc() log_utils.log('GoGoAnime - Exception: \n' + str(failure)) return
def tvshow(self, imdb, tvdb, tvshowtitle, localtvshowtitle, aliases, year): try: tv_maze = tvmaze.tvMaze() tvshowtitle = tv_maze.showLookup('thetvdb', tvdb) tvshowtitle = tvshowtitle['name'] t = cleantitle.get(tvshowtitle) q = self.base_link + self.search_link %(tvshowtitle) r = client.request(q) match = re.compile('<div class="genres_result"><a href="(.+?)">',re.DOTALL).findall(r) for url in match: if t in cleantitle.get(url): return url except: return
def episode(self, url, imdb, tvdb, title, premiered, season, episode): try: if url == None: return tv_maze = tvmaze.tvMaze() num = tv_maze.episodeAbsoluteNumber(tvdb, int(season), int(episode)) url = [i for i in url.strip('/').split('/')][-1] url = self.episode_link % (url, num) return url except: failure = traceback.format_exc() log_utils.log('GoGoAnime - Exception: \n' + str(failure)) return
def tvshow(self, imdb, tvdb, tvshowtitle, localtvshowtitle, aliases, year): try: linkAndTitle = self.__search( [tvshowtitle, localtvshowtitle] + source_utils.aliases_to_array(aliases), year) aliases = source_utils.aliases_to_array(aliases) if not tvshowtitle and source_utils.is_anime('show', 'tvdb', tvdb): linkAndTitle = self.__search( [tvmaze.tvMaze().showLookup('thetvdb', tvdb).get('name')] + source_utils.aliases_to_array(aliases), year) return linkAndTitle except: return ""
def tvshow(self, imdb, tvdb, tvshowtitle, localtvshowtitle, aliases, year): try: tv_maze = tvmaze.tvMaze() tvshowtitle = tv_maze.showLookup('thetvdb', tvdb) tvshowtitle = tvshowtitle['name'] t = cleantitle.get(tvshowtitle) q = self.base_link + self.search_link % (tvshowtitle) r = client.request(q) r = client.parseDOM(r, 'div', attrs={'class': 'featured-image'}) for i in r: match = re.compile('<a href="(.+?)"', re.DOTALL).findall(i) for url in match: if t in cleantitle.get(url): return source_utils.strip_domain(url) except: return
def episode(self, url, imdb, tvdb, title, premiered, season, episode): try: if not url: return data = urlparse.parse_qs(url) data = dict([(i, data[i][0]) if data[i] else (i, '') for i in data]) tvshowtitle = data['tvshowtitle'] localtvshowtitle = data['localtvshowtitle'] aliases = source_utils.aliases_to_array(eval(data['aliases'])) year = data['year'] episode = tvmaze.tvMaze().episodeAbsoluteNumber(tvdb, int(season), int(episode)) url = self.__search([localtvshowtitle] + aliases, year, episode) if not url and tvshowtitle != localtvshowtitle: url = self.__search([tvshowtitle] + aliases, year, episode) return url except: return
def episode(self, url, imdb, tvdb, title, premiered, season, episode): try: if not url: return url = urlparse.urljoin(self.base_link, url) episode = tvmaze.tvMaze().episodeAbsoluteNumber(tvdb, int(season), int(episode)) r = client.request(url) r = dom_parser.parse_dom(r, 'article') r = dom_parser.parse_dom(r, 'div', attrs={'class': 'entry-content'}) r = dom_parser.parse_dom(r, 'li') r = dom_parser.parse_dom(r, 'a', attrs={'href': re.compile('.*-episode-%s-.*' % episode)}, req='href')[0].attrs['href'] return source_utils.strip_domain(r) except: return
def episode(self, url, imdb, tvdb, title, premiered, season, episode): try: if not url: return url = urlparse.urljoin(self.base_link, url) episode = tvmaze.tvMaze().episodeAbsoluteNumber(tvdb, int(season), int(episode)) r = client.request(url) r = dom_parser.parse_dom(r, 'article') r = dom_parser.parse_dom(r, 'div', attrs={'class': 'entry-content'}) r = dom_parser.parse_dom(r, 'li') r = dom_parser.parse_dom(r, 'a', attrs={'href': re.compile('.*-episode-%s-.*' % episode)}, req='href')[0].attrs['href'] return source_utils.strip_domain(r) except: return
def episode(self, url, imdb, tvdb, title, premiered, season, episode): try: if not url: return data = urlparse.parse_qs(url) data = dict([(i, data[i][0]) if data[i] else (i, '') for i in data]) tvshowtitle = data['tvshowtitle'] localtvshowtitle = data['localtvshowtitle'] aliases = source_utils.aliases_to_array(eval(data['aliases'])) year = data['year'] episode = tvmaze.tvMaze().episodeAbsoluteNumber(tvdb, int(season), int(episode)) url = self.__search([localtvshowtitle] + aliases, year, episode) if not url and tvshowtitle != localtvshowtitle: url = self.__search([tvshowtitle] + aliases, year, episode) return url except: return
def episode(self, url, imdb, tvdb, title, premiered, season, episode_n): try: show_id = url link = '' e_nr = tvmaze.tvMaze().episodeAbsoluteNumber( tvdb, season, episode_n) if int(season) == 1: s_nr = int(season) if int(season) >= 2: s_nr = int(season) - 1 url = 'https://apis.justwatch.com/content/titles/show/{}/locale/de_DE/'.format( show_id) req = cache.get(requests.get, 6, url) data = req.json() while link == '': s_id = data['seasons'][s_nr - 1]['id'] # 2te anfrage um aus der season id die folge zu bekommen url = 'https://apis.justwatch.com/content/titles/show_season/{}/locale/de_DE'.format( s_id) req = cache.get(requests.get, 6, url) soup = req.json() if soup['max_episode_number'] > int(e_nr): for episode in soup['episodes']: if episode['episode_number'] == int(e_nr): for offer in episode['offers']: if offer['provider_id'] == 171: link = offer['urls']['standard_web'] return link break s_nr += 1 if int(season) + 1 == s_nr: link = 'no hit' break return except: return
def sources(self, url, hostDict, hostprDict): sources = [] try: if not url: return sources data = urlparse.parse_qs(url) data = dict([(i, data[i][0]) if data[i] else (i, '') for i in data]) tvshowtitle = data.get('tvshowtitle') localtvshowtitle = data.get('localtvshowtitle') aliases = source_utils.aliases_to_array(eval(data['aliases'])) episode = tvmaze.tvMaze().episodeAbsoluteNumber( data.get('tvdb'), int(data.get('season')), int(data.get('episode'))) alt_title = anilist.getAlternativTitle(tvshowtitle) links = self.__search([alt_title] + aliases, episode) if not links and localtvshowtitle != alt_title: links = self.__search([localtvshowtitle] + aliases, episode) if not links and tvshowtitle != localtvshowtitle: links = self.__search([tvshowtitle] + aliases, episode) for link in links: valid, host = source_utils.is_host_valid(link, hostDict) if not valid: continue sources.append({ 'source': host, 'quality': 'SD', 'language': 'de', 'url': link, 'direct': False, 'debridonly': False }) return sources except: source_faultlog.logFault(__name__, source_faultlog.tagScrape) return sources
def tvshow(self, imdb, tvdb, tvshowtitle, year): try: r = 'search/tvdb/%s?type=show&extended=full' % tvdb r = json.loads(trakt.getTrakt(r)) if not r: return '0' d = r[0]['show']['genres'] if not ('anime' in d or 'animation' in d): return '0' tv_maze = tvmaze.tvMaze() t = tv_maze.showLookup('thetvdb', tvdb) t = tv_maze.showID() if not t: return '0' url = self.searchTitle(tvshowtitle) url = {'tvMazeID': t, 'title': tvshowtitle, 'items': url} url = json.dumps(url).encode('base64') return url except: return
def episode(self, url, imdb, tvdb, title, premiered, season, episode): try: if url == None: return tv_maze = tvmaze.tvMaze() num = tv_maze.episodeAbsoluteNumber(tvdb, int(season), int(episode)) num = str(num) url = urlparse.urljoin(self.base_link, url) r = client.request(url) r = client.parseDOM(r, 'tr', attrs = {'class': ''}) r = [(client.parseDOM(i, 'a', ret='href'), client.parseDOM(i, 'td', attrs = {'class': 'epnum'})) for i in r] r = [(i[0][0], i[1][0]) for i in r if len(i[0]) > 0 and len(i[1]) > 0] r = [i[0] for i in r if num == i[1]][0] url = re.findall('(?://.+?|)(/.+)', r)[0] url = client.replaceHTMLCodes(url) url = url.encode('utf-8') return url except: return
def episode(self, url, imdb, tvdb, title, premiered, season, episode): try: if url == None: return tv_maze = tvmaze.tvMaze() num = tv_maze.episodeAbsoluteNumber(tvdb, int(season), int(episode)) num = str(num) url = urlparse.urljoin(self.base_link, url) r = client.request(url) r = client.parseDOM(r, 'tr', attrs = {'class': ''}) r = [(client.parseDOM(i, 'a', ret='href'), client.parseDOM(i, 'td', attrs = {'class': 'epnum'})) for i in r] r = [(i[0][0], i[1][0]) for i in r if len(i[0]) > 0 and len(i[1]) > 0] r = [i[0] for i in r if num == i[1]][0] url = re.findall('(?://.+?|)(/.+)', r)[0] url = client.replaceHTMLCodes(url) url = url.encode('utf-8') return url except: return
def tvshow(self, imdb, tvdb, tvshowtitle, year): try: r = 'search/tvdb/%s?type=show&extended=full' % tvdb r = json.loads(trakt.getTrakt(r)) if not r: return '0' d = r[0]['show']['genres'] if not ('anime' in d or 'animation' in d): return '0' tv_maze = tvmaze.tvMaze() tvshowtitle = tv_maze.showLookup('thetvdb', tvdb) tvshowtitle = tvshowtitle['name'] t = cleantitle.get(tvshowtitle) q = self.search_link % (urllib.quote_plus(tvshowtitle)) q = urlparse.urljoin(self.base_link, q) r = client.request(q) r = r.decode('iso-8859-1').encode('utf-8') r = client.parseDOM(r, 'ol', attrs={'id': 'searchresult'})[0] r = client.parseDOM(r, 'h2') r = [(client.parseDOM(i, 'a', ret='href'), client.parseDOM(i, 'a')) for i in r] r = [(i[0][0], i[1][0]) for i in r if len(i[0]) > 0 and len(i[1]) > 0] r = [(i[0], re.sub('<.+?>|</.+?>', '', i[1])) for i in r] r = [i for i in r if t == cleantitle.get(i[1])] r = r[-1][0] url = re.findall('(?://.+?|)(/.+)', r)[0] url = client.replaceHTMLCodes(url) url = url.encode('utf-8') return url except: return
def tvshow(self, imdb, tvdb, tvshowtitle, localtvshowtitle, year): try: r = 'search/tvdb/%s?type=show&extended=full' % tvdb r = json.loads(trakt.getTrakt(r)) if not r: return '0' d = r[0]['show']['genres'] if not ('anime' in d or 'animation' in d): return '0' tv_maze = tvmaze.tvMaze() tvshowtitle = tv_maze.showLookup('thetvdb', tvdb) tvshowtitle = tvshowtitle['name'] t = cleantitle.get(tvshowtitle) q = urlparse.urljoin(self.base_link, self.search_link) q = q % urllib.quote_plus(tvshowtitle) r = client.request(q) r = client.parseDOM(r, 'ul', attrs={'class': 'items'}) r = client.parseDOM(r, 'li') r = [(client.parseDOM(i, 'a', ret='href'), client.parseDOM(i, 'a', ret='title'), re.findall('\d{4}', i)) for i in r] r = [(i[0][0], i[1][0], i[2][-1]) for i in r if i[0] and i[1] and i[2]] r = [i for i in r if t == cleantitle.get(i[1]) and year == i[2]] r = r[0][0] url = re.findall('(?://.+?|)(/.+)', r)[0] url = client.replaceHTMLCodes(url) url = url.encode('utf-8') return url except: return
def tvshow(self, imdb, tvdb, tvshowtitle, localtvshowtitle, aliases, year): try: tv_maze = tvmaze.tvMaze() tvshowtitle = tv_maze.showLookup('thetvdb', tvdb) tvshowtitle = tvshowtitle['name'] t = cleantitle.get(tvshowtitle) q = urlparse.urljoin(self.base_link, self.search_link) q = q % urllib.quote_plus(tvshowtitle) r = client.request(q) r = client.parseDOM(r, 'ul', attrs={'class': 'items'}) r = client.parseDOM(r, 'li') r = [(client.parseDOM(i, 'a', ret='href'), client.parseDOM(i, 'a', ret='title'), re.findall('\d{4}', i)) for i in r] r = [(i[0][0], i[1][0], i[2][-1]) for i in r if i[0] and i[1] and i[2]] r = [i for i in r if t == cleantitle.get(i[1]) and year == i[2]] r = r[0][0] url = re.findall('(?://.+?|)(/.+)', r)[0] url = client.replaceHTMLCodes(url) url = url.encode('utf-8') return url except: return
def sources(self, url, hostDict, hostprDict): try: print '------------------------------- -------------------------------' sources = [] data = urlparse.parse_qs(url) data = dict([(i, data[i][0]) if data[i] else (i, '') for i in data]) print data title = data['tvshowtitle'] if 'tvshowtitle' in data else data['title'] year = data['year'] if 'year' in data else data['year'] season = data['season'] if 'season' in data else False episode = data['episode'] if 'episode' in data else False localtitle = data['localtitle'] if 'localtitle' in data else False if season and episode: aTitle = tvmaze.tvMaze().getTVShowTranslation(data['tvdb'], 'fr') else: aTitle = trakt.getMovieTranslation(data['imdb'], 'fr') if not aTitle == None: print '' else : aTitle = title if season and episode: query = 'http://www.skstream.org/recherche/?s=' + urllib.quote_plus(aTitle) query = urlparse.urljoin(self.base_link, query) else: query = self.key_link + 's=' + urllib.quote_plus(aTitle) query = urlparse.urljoin(self.base_link, query) print query r = client.request(query) try: r0 = re.compile('<center><h3>(.+?)</h3></center>').findall(r)[0] if 'Aucun film à afficher.' in r0: aTitle = re.sub(':', '-', aTitle) query = self.key_link + 'r_film=' + urllib.quote_plus(aTitle) query = urlparse.urljoin(self.base_link, query) r = client.request(query) except: pass print query aTitle = cleantitle.get(cleantitle.normalize(aTitle)) t = cleantitle.get(cleantitle.normalize(aTitle)) r = client.parseDOM(r, 'div', attrs={'class': 'panel-body'}) r = client.parseDOM(r, 'div', attrs={'class': 'col-xs-3 col-sm-3 col-md-3 col-lg-3 movie_single'}) r = [(client.parseDOM(client.parseDOM(i, 'div', attrs={'class': 'text-center'}), 'a', ret='href'), client.parseDOM(i, 'img', attrs={'class': 'img-responsive img-thumbnail'}, ret='title')) for i in r] r = [(i[0][0], i[1][0].lower()) for i in r if len(i[0]) > 0 and len(i[1]) > 0] try: r = [i[0] for i in r if t + year == cleantitle.get(i[1])][0] except: for i in r: print 't = %s, i[1] = %s' % (t, cleantitle.normalize(cleantitle.get(i[1]))) if t == cleantitle.normalize(cleantitle.get(i[1])): r = i[0] if season and episode: url = '%s%s' % (self.base_link , r) else: url = '%s/%s' % (self.base_link, r) url = client.replaceHTMLCodes(url) #url = url.encode('utf-8') url = urlparse.urljoin('http://www.skstream.org', url) print url r = client.request(url) if season and episode: r = client.request(url) r = r.replace(' = ', '=') unChunk = client.parseDOM(r, 'div', attrs={'class': 'jumbotron'}) desSaisons = client.parseDOM(r, 'i', attrs={'class': 'fa fa-television'}, ret='id') desLiens = client.parseDOM(r, 'div', attrs={'class': 'btn-group'}) desLiens = client.parseDOM(desLiens, 'a',ret='href') for unLienTV in desLiens: tempSaisonEpisode = '/saison-%s/episode-%s/' % (season, episode) if '/series/' in unLienTV and tempSaisonEpisode in unLienTV: urlTV = 'http://www.skstream.org/%s' % unLienTV break print urlTV s = client.request(urlTV) urlLoop = urlTV s = client.parseDOM(s, 'table', attrs={'class': 'players table table-striped table-hover'}) else: s = client.request(url) urlLoop = url s = client.parseDOM(r, 'table', attrs={'class': 'players table table-striped table-hover'}) leVideo = client.parseDOM(s, 'input', attrs={'name': 'levideo'}, ret='value') leHost = re.compile(' (.+?)</a></form>').findall(s[0]) #uneLangue = client.parseDOM(s, 'span', attrs={'class': 'badge'}) #uneQualite = re.compile('</span></td>\n\s+<td>(.+?)</td>', re.MULTILINE | re.DOTALL).findall(s) leHost = [x.lower() for x in leHost] #uneLangue = [x.lower() for x in uneLangue] #uneQualite = [x.lower() for x in uneQualite] counter = 0 for unVideo in leVideo: if season and episode: url = urlLoop + '***' + unVideo + '***' + 'TV' else: url = urlLoop + '***' + unVideo + '***' + 'Movie' url = url.encode('utf-8') try: if leHost[counter] == 'openload': host = filter(lambda s: leHost[counter] in str(s), hostDict)[1] else: host = filter(lambda s: leHost[counter] in str(s), hostDict)[0] except: counter = counter + 1 continue host = host.encode('utf-8') #langue = uneLangue[counter] #quality2 = uneQualite[counter] #quality2 = re.sub('-', '', quality2) quality2 = '' if '1080p' in quality2: quality = '1080p' elif '720p' in quality2 or 'bdrip' in quality2 or 'hdrip' in quality2: quality = 'HD' else: quality = 'SD' if 'dvdscr' in quality2 or 'r5' in quality2 or 'r6' in quality2: quality2 = 'SCR' elif 'camrip' in quality2 or 'tsrip' in quality2 or 'hdcam' in quality2 or 'hdts' in quality2 or 'dvdcam' in quality2 or 'dvdts' in quality2 or 'cam' in quality2 or 'telesync' in quality2 or 'ts' in quality2: quality2 = 'CAM' sources.append({'source': host, 'quality': quality, 'language': 'FR', 'url': url, 'info': '', 'direct': False, 'debridonly': False}) counter = counter + 1 print sources return sources except Exception as e: exc_type, exc_obj, exc_tb = sys.exc_info() fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1] print(exc_type, fname, exc_tb.tb_lineno) return sources
def tvshow(self, imdb, tvdb, tvshowtitle, localtvshowtitle, year): try: url = self.__search(tvshowtitle, year) if not url and tvshowtitle != localtvshowtitle: url = self.__search(localtvshowtitle, year) if not url and self.__is_anime('show', 'tvdb', tvdb): url = self.__search(tvmaze.tvMaze().showLookup('thetvdb', tvdb).get('name'), year) return url except: return
def sources(self, url, hostDict, hostprDict): sources = [] try: if not url: return sources data = urlparse.parse_qs(url) data = dict([(i, data[i][0]) if data[i] else (i, '') for i in data]) url = data.get('url') season = data.get('season') episode = data.get('episode') abs_episode = 0 if season and episode: abs_episode = str(tvmaze.tvMaze().episodeAbsoluteNumber( data.get('tvdb'), int(season), int(episode))) url = urlparse.urljoin(self.base_link, url) r = client.request(url) r = r.decode('cp1251').encode('utf-8') r = dom_parser.parse_dom(r, 'div', attrs={'class': 'players'}, req='data-player') r = [(i.attrs['data-player'], dom_parser.parse_dom(i, 'a', req='href')) for i in r] r = [(i[0], i[1][0].attrs['href']) for i in r if i[1]] for post_id, play_url in r: i = client.request(play_url, referer=url, output='extended') headers = i[3] headers.update({'Cookie': i[2].get('Set-Cookie')}) i = client.request(urlparse.urljoin(self.base_link, self.player_link), post={'post_id': post_id}, headers=headers, referer=i, XHR=True) i = json.loads(i).get('message', {}).get('translations', {}).get('flash', {}) for title, link in i.iteritems(): try: link = self.decode_direct_media_url(link) if link.endswith('.txt'): link = self.decode_direct_media_url( client.request(link)) link = json.loads(link).get('playlist', []) link = [i.get('playlist', []) for i in link] link = [ x.get('file') for i in link for x in i if (x.get('season') == season and x.get('serieId') == episode) or ( x.get('season') == '0' and x.get('serieId') == abs_episode) ][0] urls = [(source_utils.label_to_quality(q), self.format_direct_link(link, q)) for q in self.get_qualitys(link)] urls = [{ 'quality': x[0], 'url': x[1] } for x in urls if x[0] in ['SD', 'HD']] # filter premium for i in urls: sources.append({ 'source': 'CDN', 'quality': i['quality'], 'info': title, 'language': 'ru', 'url': i['url'], 'direct': True, 'debridonly': False }) except: pass return sources except: return sources
def sources(self, url, hostDict, hostprDict): try: print '------------------------------- -------------------------------' sources = [] data = urlparse.parse_qs(url) data = dict([(i, data[i][0]) if data[i] else (i, '') for i in data]) print data title = data['tvshowtitle'] if 'tvshowtitle' in data else data[ 'title'] year = data['year'] if 'year' in data else data['year'] season = data['season'] if 'season' in data else False episode = data['episode'] if 'episode' in data else False localtitle = data['localtitle'] if 'localtitle' in data else False if season and episode: aTitle = tvmaze.tvMaze().getTVShowTranslation( data['tvdb'], 'fr') else: aTitle = trakt.getMovieTranslation(data['imdb'], 'fr') if not aTitle == None: print '' else: aTitle = title if season and episode: query = 'http://www.skstream.org/recherche/?s=' + urllib.quote_plus( aTitle) query = urlparse.urljoin(self.base_link, query) else: query = self.key_link + 's=' + urllib.quote_plus(aTitle) query = urlparse.urljoin(self.base_link, query) print query r = client.request(query) try: r0 = re.compile('<center><h3>(.+?)</h3></center>').findall( r)[0] if 'Aucun film à afficher.' in r0: aTitle = re.sub(':', '-', aTitle) query = self.key_link + 'r_film=' + urllib.quote_plus( aTitle) query = urlparse.urljoin(self.base_link, query) r = client.request(query) except: pass print query aTitle = cleantitle.get(cleantitle.normalize(aTitle)) t = cleantitle.get(cleantitle.normalize(aTitle)) r = client.parseDOM(r, 'div', attrs={'class': 'panel-body'}) r = client.parseDOM( r, 'div', attrs={ 'class': 'col-xs-3 col-sm-3 col-md-3 col-lg-3 movie_single' }) r = [(client.parseDOM(client.parseDOM( i, 'div', attrs={'class': 'text-center'}), 'a', ret='href'), client.parseDOM( i, 'img', attrs={'class': 'img-responsive img-thumbnail'}, ret='title')) for i in r] r = [(i[0][0], i[1][0].lower()) for i in r if len(i[0]) > 0 and len(i[1]) > 0] try: r = [i[0] for i in r if t + year == cleantitle.get(i[1])][0] except: for i in r: print 't = %s, i[1] = %s' % ( t, cleantitle.normalize(cleantitle.get(i[1]))) if t == cleantitle.normalize(cleantitle.get(i[1])): r = i[0] if season and episode: url = '%s%s' % (self.base_link, r) else: url = '%s/%s' % (self.base_link, r) url = client.replaceHTMLCodes(url) #url = url.encode('utf-8') url = urlparse.urljoin('http://www.skstream.org', url) print url r = client.request(url) if season and episode: r = client.request(url) r = r.replace(' = ', '=') unChunk = client.parseDOM(r, 'div', attrs={'class': 'jumbotron'}) desSaisons = client.parseDOM( r, 'i', attrs={'class': 'fa fa-television'}, ret='id') desLiens = client.parseDOM(r, 'div', attrs={'class': 'btn-group'}) desLiens = client.parseDOM(desLiens, 'a', ret='href') for unLienTV in desLiens: tempSaisonEpisode = '/saison-%s/episode-%s/' % (season, episode) if '/series/' in unLienTV and tempSaisonEpisode in unLienTV: urlTV = 'http://www.skstream.org/%s' % unLienTV break print urlTV s = client.request(urlTV) urlLoop = urlTV s = client.parseDOM( s, 'table', attrs={'class': 'players table table-striped table-hover'}) else: s = client.request(url) urlLoop = url s = client.parseDOM( r, 'table', attrs={'class': 'players table table-striped table-hover'}) leVideo = client.parseDOM(s, 'input', attrs={'name': 'levideo'}, ret='value') leHost = re.compile(' (.+?)</a></form>').findall(s[0]) #uneLangue = client.parseDOM(s, 'span', attrs={'class': 'badge'}) #uneQualite = re.compile('</span></td>\n\s+<td>(.+?)</td>', re.MULTILINE | re.DOTALL).findall(s) leHost = [x.lower() for x in leHost] #uneLangue = [x.lower() for x in uneLangue] #uneQualite = [x.lower() for x in uneQualite] counter = 0 for unVideo in leVideo: if season and episode: url = urlLoop + '***' + unVideo + '***' + 'TV' else: url = urlLoop + '***' + unVideo + '***' + 'Movie' url = url.encode('utf-8') try: if leHost[counter] == 'openload': host = filter(lambda s: leHost[counter] in str(s), hostDict)[1] else: host = filter(lambda s: leHost[counter] in str(s), hostDict)[0] except: counter = counter + 1 continue host = host.encode('utf-8') #langue = uneLangue[counter] #quality2 = uneQualite[counter] #quality2 = re.sub('-', '', quality2) quality2 = '' if '1080p' in quality2: quality = '1080p' elif '720p' in quality2 or 'bdrip' in quality2 or 'hdrip' in quality2: quality = 'HD' else: quality = 'SD' if 'dvdscr' in quality2 or 'r5' in quality2 or 'r6' in quality2: quality2 = 'SCR' elif 'camrip' in quality2 or 'tsrip' in quality2 or 'hdcam' in quality2 or 'hdts' in quality2 or 'dvdcam' in quality2 or 'dvdts' in quality2 or 'cam' in quality2 or 'telesync' in quality2 or 'ts' in quality2: quality2 = 'CAM' sources.append({ 'source': host, 'quality': quality, 'language': 'FR', 'url': url, 'info': '', 'direct': False, 'debridonly': False }) counter = counter + 1 print sources return sources except Exception as e: exc_type, exc_obj, exc_tb = sys.exc_info() fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1] print(exc_type, fname, exc_tb.tb_lineno) return sources
def tvshow(self, imdb, tvdb, tvshowtitle, localtvshowtitle, aliases, year): try: url = self.__search([localtvshowtitle] + source_utils.aliases_to_array(aliases), year) if not url and tvshowtitle != localtvshowtitle: url = self.__search([tvshowtitle] + source_utils.aliases_to_array(aliases), year) if not url and source_utils.is_anime('show', 'tvdb', tvdb): url = self.__search([tvmaze.tvMaze().showLookup('thetvdb', tvdb).get('name')] + source_utils.aliases_to_array(aliases), year) return url except: return