Update trollvid.py

Should now work a lot better
master
Blatzar 2020-09-17 21:41:34 +00:00 committed by GitHub
parent 80ac3fcca3
commit 723fbb5018
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 27 additions and 4 deletions

View File

@ -10,8 +10,31 @@ class Trollvid(BaseExtractor):
referer = 'https://anistream.xyz'
req = helpers.get(self.url, referer=referer)
stream_url = re.findall('<source src="(.*?)"', req.text)[0]
source_regex = r'<source src="(.*?)"'
source = re.search(source_regex, req.text)
return {
'stream_url': stream_url
}
# Matches: token="eyJ0eXA"
token_regex = r"token\s*=\s*['\"|']([^\"']*)"
token = re.search(token_regex, req.text)
if source:
return {
'stream_url': source.group()
}
elif token:
token = token.group(1)
trollvid_id = self.url.split('/')[-1] # something like: 084df78d215a
post = helpers.post(f'https://mp4.sh/v/{trollvid_id}',
data={'token': token},
referer=self.url,
).json()
# {'success':True} on success.
if post.get('success') and post.get('data'):
return {
'stream_url': post['data']
}
# In case neither methods work.
return {'stream_url': ''}