diff --git a/servers/ninjastream.py b/servers/ninjastream.py index 6f89060a..fb4c391b 100644 --- a/servers/ninjastream.py +++ b/servers/ninjastream.py @@ -20,17 +20,24 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= logger.debug("URL", page_url) video_urls = [] - h = json.loads(support.match(data, patron='stream="([^"]+)"').match.replace('"','"')) - baseurl = decode(h['host']) + h['hash'] - matches = support.match(baseurl + '/index.m3u8', patron=r'RESOLUTION=\d+x(\d+)\s*([^\s]+)').matches + headers = {'User-Agent': httptools.get_user_agent(), + 'Referer': page_url, + 'Origin': 'https://ninjastream.to', + 'X-Requested-With': 'XMLHttpRequest'} - for quality, url in matches: - video_urls.append(["{} {}p [NinjaStream]".format(url.split('.')[-1], quality), '{}/{}'.format(baseurl, url)]) + apiUrl = 'https://ninjastream.to/api/video/get' + post = {'id':page_url.split('/')[-1]} + data = httptools.downloadpage(apiUrl, headers=headers, post=post).json + + if data.get('result',{}).get('playlist'): + url = data.get('result',{}).get('playlist') + + video_urls.append([url.split('.')[-1], url]) return video_urls -def decode(host): - Host = '' - for n in range(len(host)): - Host += chr(ord(host[n]) ^ ord('2')) - return Host \ No newline at end of file +# def decode(host): +# Host = '' +# for n in range(len(host)): +# Host += chr(ord(host[n]) ^ ord('2')) +# return Host \ No newline at end of file