1
1
mirror of https://github.com/ytdl-org/youtube-dl synced 2024-09-01 13:05:11 +02:00

Compare commits

...

8 Commits

Author SHA1 Message Date
schnusch
93da938b31
Merge ba7396afd1 into 4d05f84325 2024-06-27 06:35:46 +08:00
schnusch
ba7396afd1 [ninjastream] add thumbnail 2021-04-30 18:20:53 +02:00
schnusch
01924f678a [ninjastream] request API to obtain playlist URL 2021-04-30 18:14:49 +02:00
schnusch
0ad70a76f0 [ninjastream] fix video ID 2021-04-30 18:13:25 +02:00
schnusch
291703cefd [ninjastream] replace test 2021-04-30 18:13:25 +02:00
schnusch
6b1e477197 [ninjastream] fix line endings 2021-04-30 17:36:47 +02:00
J█████
db63c10d4e
[ninjastream] Addressing coding convention issues 2021-01-27 14:14:16 -05:00
J█████
5adc36f2ae
[ninjastream] Adding new extractor 2021-01-27 12:12:39 -05:00
2 changed files with 70 additions and 0 deletions

View File

@ -829,6 +829,7 @@ from .niconico import (
from .ninecninemedia import NineCNineMediaIE
from .ninegag import NineGagIE
from .ninenow import NineNowIE
from .ninjastream import NinjaStreamIE
from .nintendo import NintendoIE
from .njpwworld import NJPWWorldIE
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,
}