def _get_sources(self): version = self.config['version'] servers = self.config['servers'] server_links = { 'mp4upload': 'https://www.mp4upload.com/embed-{}.html', 'trollvid': 'https://trollvid.net/embed/{}', 'mp4sh': 'https://mp4.sh/embed/{0}{1}', 'vidstreaming': 'https://vidstreaming.io/download?id={}' } soup = str(helpers.soupify(helpers.get(self.url))) x = re.search(r"xuath = '([^']*)", soup).group(1) episode_regex = r'var episode = (.*?});' api = json.loads(re.search(episode_regex, soup).group(1)) slug = api['slug'] sources = api['videos'] try: # Continues even if vidstream api fails vidstream = helpers.get(f'https://vid.xngine.com/api/episode/{slug}', referer=self.url).json() except: vidstream = [] for a in vidstream: if a['host'] == 'vidstreaming' and 'id' in a and 'type' in a: sources.append(a) for a in servers: # trying all supported servers in order using the correct language for b in sources: if b['type'] == version: if b['host'] == a: if get_extractor(a) == None: continue else: provider = a[:] embed = server_links.get(provider, '{}').format(b['id'], x) return [(provider, embed,)] logger.debug('No servers found in selected language. Trying all supported servers') for a in servers: # trying all supported servers in order for b in sources: if b['host'] == a: if get_extractor(a) == None: continue else: provider = a[:] embed = server_links.get(provider, '{}').format(b['id'], x) return [(provider, embed,)] logger.debug('No supported servers found, trying mp4sh') if re.search(r'"trollvid","id":"([^"]*)', soup): token = re.search(r'"trollvid","id":"([^"]*)', soup).group(1) embed = server_links.get('mp4sh', '{}').format(token, x) return [('mp4sh', embed,)] else: logger.debug('No servers found') return [('no_extractor', '',)]
def _get_sources(self): server = self.config['server'] soup = helpers.soupify(helpers.get(self.url)) regex = r'var json = ([^;]*)' sources = json.loads(re.search( regex, str(soup)).group(1)) #Lots of sources can be found here for a in sources: #Testing sources with selected language and provider if a['type'] == self.config['version']: if a['host'] == self.config['server']: if get_extractor(a['host']) == None: server = 'no_extractor' else: server = (a['host']) embed = re.search(r"src=['|\"]([^\'|^\"]*)", str(a['player']), re.IGNORECASE).group(1) return [( server, embed, )] logger.debug( 'Preferred server %s not found. Trying all supported servers in selected language.', server) for a in sources: #Testing sources with selected language if a['type'] == self.config['version']: if get_extractor(a['host']) == None: server = 'no_extractor' else: server = (a['host']) embed = re.search(r"src=['|\"]([^\'|^\"]*)", str(a['player']), re.IGNORECASE).group(1) return [( server, embed, )] logger.debug('No %s servers found, trying all servers', self.config['version']) if get_extractor(sources[0]['host']) == None: server = 'no_extractor' else: server = (sources[0]['host']) embed = re.search(r"src=['|\"]([^\'|^\"]*)", str(sources[0]['player']), re.IGNORECASE).group(1) return [( server, embed, )]
def _get_data(self): ''' Config: List of servers. Will use servers in order. For example: ["hydrax","vidstream"] will prioritize the HydraX link. Available servers: links (below) and vidstream ''' links = { "gcloud": "https://gcloud.live/", "mp4upload": "https://www.mp4upload.com/", "cloud9": "https://cloud9.to", "hydrax": "https://hydrax.net" } url = self.url.replace('https:////', 'https://') url = url.replace('https://vidstreaming.io/download', 'https://vidstreaming.io/server.php') soup = helpers.soupify(helpers.get(url)) servers = Config._read_config()['siteconfig']['vidstream']['servers'] sources_regex = r'sources:(\[{.*?}])' sources = re.search(sources_regex, str(soup)) linkserver = soup.select('li.linkserver') for a in servers: if a == 'vidstream': return self._get_link(sources) for b in linkserver: if b.get('data-video').startswith(links.get(a, 'None')): self.url = b.get('data-video') return extractors.get_extractor(a)._get_data(self)
def source(self, index=0): """ Get the source for episode Returns ------- `anime_downloader.extractors.base_extractor.BaseExtractor` Extractor depending on the source. """ if not self._sources: try: self.get_data() except NotFoundError: raise NotFoundError("No episode sources found. source()") try: sitename, url = self._sources[index] except TypeError: return self._sources[index] except IndexError: raise NotFoundError("No episode sources found. sources[index]") ext = get_extractor(sitename)(url, quality=self.quality) self._sources[index] = ext return ext
def _get_sources(self): html = helpers.get(self.url).text # Matches: # var episode = {"id":"187961", # "url":"https:\/\/animebinge.net\/episode\/187961-yakusoku-no-neverland-episode-1", # "lang":"dubbed"}; </script> # And parses the json in the script. episode_regex = r'var\s*episode\s*=\s*({[\W\w]*?);\s*<\/script>' source = re.search(episode_regex, str(html)) if source: source_json = json.loads(source.group(1))['videos'] else: return '' logger.debug('Sources: {}'.format(source_json)) mappings = { 'mp4upload': 'https://www.mp4upload.com/embed-{}.html', 'trollvid': 'https://trollvid.net/embed/{}', 'xstreamcdn': 'https://xstreamcdn.com/v/{}' } sources_list = [] for i in source_json: if mappings.get(i.get('host')): extractor = 'no_extractor' if not get_extractor(i['host']) else i['host'] sources_list.append({ 'extractor': extractor, 'url': mappings[i['host']].format(i['id']), 'server': i['host'], 'version': i.get('type', 'subbed') }) return self.sort_sources(sources_list)
def _get_data(self): ''' Config: List of servers. Will use servers in order. For example: ["hydrax","vidstream"] will prioritize the HydraX link. Available servers: links (below) and vidstream ''' links = { "gcloud": "https://gcloud.live/", "mp4upload": "https://www.mp4upload.com/", "cloud9": "https://cloud9.to", "hydrax": "https://hydrax.net" } url = self.url.replace('https:////', 'https://') url = url.replace('https://vidstreaming.io/download', 'https://vidstreaming.io/server.php') soup = helpers.soupify(helpers.get(url)) servers = Config._read_config()['siteconfig']['vidstream']['servers'] linkserver = soup.select('li.linkserver') for a in servers: if a == 'vidstream': return self._get_link(soup) for b in linkserver: if b.get('data-video').startswith(links.get(a, 'None')): """ Another class needs to get created instead of using self not to impact future loops If the extractor fails vidstream.py will get run again with changed self """ info = self.__dict__.copy() info['url'] = b.get('data-video') _self = Extractor(info) return extractors.get_extractor(a)._get_data(_self)
def source(self, index=0): if not self._sources: self.get_data() try: sitename, url = self._sources[index] except TypeError: return self._sources[index] ext = get_extractor(sitename)(url, quality=self.quality) self._sources[index] = ext return ext
def _get_data(self): """ Config: List of servers. Will use servers in order. For example: ["hydrax","vidstream"] will prioritize the HydraX link. Available servers: links (below) and vidstream """ links = { "gcloud": "https://gcloud.live/", "mp4upload": "https://www.mp4upload.com/", "cloud9": "https://cloud9.to", "hydrax": "https://hydrax.net", "mixdrop": "https://mixdrop.co" } url = self.url.replace('https:////', 'https://') url = url.replace('https://gogo-stream.com/download', 'https://gogo-stream.com/server.php') soup = helpers.soupify(helpers.get(url)) linkserver = soup.select('li.linkserver') logger.debug('Linkserver: {}'.format(linkserver)) """Dirty, but self.config isn't supported for extractors.""" servers = Config._read_config()['siteconfig']['vidstream']['servers'] for i in servers: """ Will only use _get_link() if the site is actually the real vidstream, as clones use a different layout for their own videos """ if 'vidstream' in i and 'vidstream' in self.url: return self._get_link(soup) for j in linkserver: if j.get('data-video').startswith(links.get(i, 'None')): """ Another class needs to get created instead of using self, not to impact future loops. If the extractor fails it will rerun, which would lead to an error if self was changed """ info = self.__dict__.copy() info['url'] = j.get('data-video') _self = Extractor(info) """Gives away the link to another extractor""" return extractors.get_extractor(i)._get_data(_self) return {'stream_url': ''}
def _get_sources(self): soup = helpers.soupify(helpers.get(self.url)) regex = r'var json = ([^;]*)' sources = json.loads(re.search(regex,str(soup)).group(1)) #Lots of sources can be found here logger.debug('Sources: {}'.format(sources)) sources_list = [] for i in sources: extractor = 'no_extractor' if not get_extractor(i['host']) else i['host'] embed = re.search(r"src=['|\"]([^\'|^\"]*)",str(i['player']), re.IGNORECASE).group(1) sources_list.append({ 'extractor':extractor, 'url':embed, 'server':i['host'], 'version':i.get('type','subbed') }) return self.sort_sources(sources_list)
def _get_sources(self): soup = helpers.soupify(helpers.get(self.url)) servers = soup.select("#servers-list > ul > li") servers = [{ "name": server.find('span').text.strip(), "link": server.find('a')['data-embed'] } for server in servers] servers = sorted(servers, key=lambda x: x['name'].lower() in self.config[ 'servers'][0].lower())[::-1] # noqa sources = [] for server in servers: ext = get_extractor('wcostream')(server['link'], quality=self.quality, headers={}) sources.extend([('no_extractor', x['stream_url']) for x in ext._get_data()]) # noqa return sources