mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2025-01-30 22:59:48 +00:00
[ninjastream] Addressing coding convention issues
This commit is contained in:
parent
5adc36f2ae
commit
db63c10d4e
@ -28,39 +28,50 @@ class NinjaStreamIE(InfoExtractor):
|
|||||||
Parses the URL into the video's URL.
|
Parses the URL into the video's URL.
|
||||||
"""
|
"""
|
||||||
# Parse the video id
|
# Parse the video id
|
||||||
video_id = self._search_regex(r'https?://(?:\w+\.)?ninjastream\.to/watch/([0-9a-zA-Z]+)',
|
video_id = self._search_regex(
|
||||||
url, 'video_id', fatal=False) or ''
|
r'https?://(?:\w+\.)?ninjastream\.to/watch/([0-9a-zA-Z]+)',
|
||||||
|
url, 'video_id', fatal=False, default='')
|
||||||
|
|
||||||
# Get the hosted webpage
|
# Get the hosted webpage
|
||||||
webpage = self._download_webpage(url, video_id)
|
webpage = self._download_webpage(url, video_id)
|
||||||
|
|
||||||
# The links to the m3u8 file will be buried and html encoded in the <file-watch-jwplayer> tag
|
# The links to the m3u8 file will be buried and html encoded in
|
||||||
jwplayer_link = self._html_search_regex(r'<file-watch-jwplayer (.*)', webpage,
|
# the <file-watch-jwplayer> tag
|
||||||
'file-watch-jwplayer', fatal=False)
|
jwplayer_link = self._html_search_regex(
|
||||||
|
r'<file-watch-jwplayer (.*)', webpage,
|
||||||
|
'file-watch-jwplayer', fatal=False)
|
||||||
|
|
||||||
if jwplayer_link is None:
|
if jwplayer_link is None:
|
||||||
raise ExtractorError('NinjaStream: Failed to find the file information on the website')
|
raise ExtractorError(
|
||||||
|
'NinjaStream: Failed to find the file information on the website')
|
||||||
|
|
||||||
# The v-bind:file will give us the correct title for the video
|
# The v-bind:file will give us the correct title for the video
|
||||||
file_meta = self._parse_json(self._search_regex(r'v-bind:file=\"(\{.*?\})\"', jwplayer_link, video_id),
|
file_meta = self._parse_json(
|
||||||
video_id, fatal=False)
|
self._search_regex(r'v-bind:file=\"(\{.*?\})\"', jwplayer_link,
|
||||||
|
video_id),
|
||||||
|
video_id, fatal=False)
|
||||||
|
|
||||||
filename = video_id
|
filename = video_id
|
||||||
if file_meta is not None and 'name' in file_meta:
|
if file_meta is not None:
|
||||||
filename = os.path.splitext(file_meta['name'])[0]
|
filename = os.path.splitext(file_meta.get('name'))[0]
|
||||||
|
|
||||||
# The v-bind:stream will give us the location of the m3u8 file
|
# The v-bind:stream will give us the location of the m3u8 file
|
||||||
stream_meta = self._parse_json(self._search_regex(r'v-bind:stream=\"(\{.*?\})\"', jwplayer_link, video_id),
|
stream_meta = self._parse_json(
|
||||||
video_id, fatal=False)
|
self._search_regex(r'v-bind:stream=\"(\{.*?\})\"',
|
||||||
|
jwplayer_link, video_id),
|
||||||
|
video_id, fatal=False)
|
||||||
|
|
||||||
if stream_meta is None:
|
if stream_meta is None:
|
||||||
raise ExtractorError('NinjaStream: Failed to find the m3u8 information on website')
|
raise ExtractorError(
|
||||||
|
'NinjaStream: Failed to find the m3u8 information on website')
|
||||||
|
|
||||||
url = '{0}/{1}/index.m3u8'.format(stream_meta['host'], stream_meta['hash'])
|
url = '{0}/{1}/index.m3u8'.format(stream_meta['host'],
|
||||||
|
stream_meta['hash'])
|
||||||
|
|
||||||
# Get and parse the m3u8 information
|
# Get and parse the m3u8 information
|
||||||
formats = self._extract_m3u8_formats(url, video_id, 'mp4', entry_protocol='m3u8_native',
|
formats = self._extract_m3u8_formats(
|
||||||
m3u8_id='hls', fatal=False)
|
url, video_id, 'mp4', entry_protocol='m3u8_native',
|
||||||
|
m3u8_id='hls', fatal=False)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'formats': formats,
|
'formats': formats,
|
||||||
|
Loading…
Reference in New Issue
Block a user