Merge ba7396afd1e3e7b0a77c39a7bc48065a5e3542f3 into 2b4fbfce25902d557b86b003cf48f738129efce4

This commit is contained in:
schnusch 2025-03-26 08:03:43 +00:00 committed by GitHub
commit bf118b6556
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 70 additions and 0 deletions

View File

@ -829,6 +829,7 @@ from .niconico import (
from .ninecninemedia import NineCNineMediaIE from .ninecninemedia import NineCNineMediaIE
from .ninegag import NineGagIE from .ninegag import NineGagIE
from .ninenow import NineNowIE from .ninenow import NineNowIE
from .ninjastream import NinjaStreamIE
from .nintendo import NintendoIE from .nintendo import NintendoIE
from .njpwworld import NJPWWorldIE from .njpwworld import NJPWWorldIE
from .nobelprize import NobelPrizeIE from .nobelprize import NobelPrizeIE

View File

@ -0,0 +1,69 @@
# coding: utf-8
from __future__ import unicode_literals
import json
import posixpath
from .common import InfoExtractor
from ..utils import urljoin
class NinjaStreamIE(InfoExtractor):
"""
Handles downloading video from ninjastream.to
"""
_VALID_URL = r'https?://(?:www\.)?ninjastream\.to/(?:download|watch)/(?P<id>[^/?#]+)'
_TESTS = [
{
'url': 'https://ninjastream.to/watch/GbJQP8rawQ7rw',
'info_dict': {
'id': 'GbJQP8rawQ7rw',
'ext': 'mp4',
'title': 'Big Buck Bunny 360 10s 5MB'
},
}
]
def _real_extract(self, url):
video_id = self._match_id(url)
# Get the hosted webpage
webpage = self._download_webpage(url, video_id)
# The v-bind:file will give us the correct title for the video
file_meta = self._parse_json(
self._html_search_regex(r'v-bind:file="([^"]*)"', webpage,
video_id),
video_id, fatal=False) or {}
try:
filename = posixpath.splitext(file_meta['name'])[0]
except KeyError:
filename = 'ninjastream.to'
thumbnail = file_meta.get('poster_id')
if thumbnail:
thumbnail = urljoin('https://cdn.ninjastream.to/', thumbnail)
data = {'id': video_id}
headers = {
'X-Requested-With': 'XMLHttpRequest',
'Content-Type': 'application/json',
'Referer': url,
}
data = json.dumps(data, separators=(',', ':')).encode('utf-8')
stream_meta = self._download_json('https://ninjastream.to/api/video/get',
video_id, data=data, headers=headers)
# Get and parse the m3u8 information
stream_url = stream_meta['result']['playlist']
formats = self._extract_m3u8_formats(
stream_url, video_id, 'mp4', entry_protocol='m3u8_native',
m3u8_id='hls')
return {
'formats': formats,
'id': video_id,
'thumbnail': thumbnail,
'title': filename,
}