2020-05-16 01:30:17 -07:00
|
|
|
from anime_downloader.extractors.base_extractor import BaseExtractor
|
|
|
|
from anime_downloader.sites import helpers
|
|
|
|
import logging
|
2020-07-14 13:20:40 -07:00
|
|
|
import base64
|
2020-05-16 01:30:17 -07:00
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
2020-09-20 04:08:12 -07:00
|
|
|
|
2020-05-16 01:30:17 -07:00
|
|
|
class Hydrax(BaseExtractor):
|
|
|
|
def _get_data(self):
|
|
|
|
url = self.url
|
2020-09-24 07:57:11 -07:00
|
|
|
# Should probably be urlparse.
|
2020-09-20 04:08:12 -07:00
|
|
|
end = url[url.find('=') + 1:]
|
2020-09-24 07:57:11 -07:00
|
|
|
# Note that this url can change.
|
|
|
|
obfuscated_url = helpers.post('https://ping.iamcdn.net/',
|
2020-09-20 04:08:12 -07:00
|
|
|
data={'slug': end},
|
2020-09-24 07:57:11 -07:00
|
|
|
referer=f'https://play.hydracdn.network/watch?v={end}',
|
2020-09-20 04:08:12 -07:00
|
|
|
).json()['url']
|
2020-07-14 13:20:40 -07:00
|
|
|
|
|
|
|
decoded_url = base64.b64decode(obfuscated_url[-1] + obfuscated_url[:-1]).decode('utf-8')
|
2020-05-16 01:30:17 -07:00
|
|
|
|
2020-07-27 13:24:52 -07:00
|
|
|
# HydraX uses www.url for high quality and url for low quality
|
2020-09-20 04:08:12 -07:00
|
|
|
quality = '' if self.quality in ['360p', '480p'] else 'www.'
|
2020-07-27 13:24:52 -07:00
|
|
|
|
2020-05-16 01:30:17 -07:00
|
|
|
return {
|
2020-07-27 13:24:52 -07:00
|
|
|
'stream_url': f'https://{quality}{decoded_url}',
|
2020-05-16 01:30:17 -07:00
|
|
|
'referer': url
|
|
|
|
}
|