def tvshow(self, imdb, tvdb, tvshowtitle, localtvshowtitle, aliases, year): try: 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 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 = 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 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 not url: return episode = tvmaze.tvMaze().episodeAbsoluteNumber(tvdb, int(season), int(episode)) data = parse_qs(url) data = dict([(i, data[i][0]) if data[i] else (i, '') for i in data]) data.update({'episode': episode}) return urlencode(data) 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 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
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 sources(self, url, hostDict, hostprDict): sources = [] try: if not url: return sources data = 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 = 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(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', '720p']] # 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 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