mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-12-26 03:56:49 -05:00
[jwplatform] Improved m3u8 and rtmp support
Changes made for SendtoNewsIE. Part of #9522
This commit is contained in:
parent
9f54e692d2
commit
612b5f403e
@ -5,33 +5,47 @@ import re
|
|||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
|
determine_ext,
|
||||||
float_or_none,
|
float_or_none,
|
||||||
int_or_none,
|
int_or_none,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class JWPlatformBaseIE(InfoExtractor):
|
class JWPlatformBaseIE(InfoExtractor):
|
||||||
def _parse_jwplayer_data(self, jwplayer_data, video_id, require_title=True):
|
def _parse_jwplayer_data(self, jwplayer_data, video_id, require_title=True, m3u8_id=None, rtmp_params=None):
|
||||||
video_data = jwplayer_data['playlist'][0]
|
video_data = jwplayer_data['playlist'][0]
|
||||||
|
|
||||||
formats = []
|
formats = []
|
||||||
for source in video_data['sources']:
|
for source in video_data['sources']:
|
||||||
source_url = self._proto_relative_url(source['file'])
|
source_url = self._proto_relative_url(source['file'])
|
||||||
source_type = source.get('type') or ''
|
source_type = source.get('type') or ''
|
||||||
if source_type in ('application/vnd.apple.mpegurl', 'hls'):
|
if source_type in ('application/vnd.apple.mpegurl', 'hls') or determine_ext(source_url) == 'm3u8':
|
||||||
formats.extend(self._extract_m3u8_formats(
|
formats.extend(self._extract_m3u8_formats(
|
||||||
source_url, video_id, 'mp4', 'm3u8_native', fatal=False))
|
source_url, video_id, 'mp4', 'm3u8_native', m3u8_id=m3u8_id, fatal=False))
|
||||||
elif source_type.startswith('audio'):
|
elif source_type.startswith('audio'):
|
||||||
formats.append({
|
formats.append({
|
||||||
'url': source_url,
|
'url': source_url,
|
||||||
'vcodec': 'none',
|
'vcodec': 'none',
|
||||||
})
|
})
|
||||||
else:
|
else:
|
||||||
formats.append({
|
a_format = {
|
||||||
'url': source_url,
|
'url': source_url,
|
||||||
'width': int_or_none(source.get('width')),
|
'width': int_or_none(source.get('width')),
|
||||||
'height': int_or_none(source.get('height')),
|
'height': int_or_none(source.get('height')),
|
||||||
|
}
|
||||||
|
if source_url.startswith('rtmp'):
|
||||||
|
# See com/longtailvideo/jwplayer/media/RTMPMediaProvider.as
|
||||||
|
# of jwplayer.flash.swf
|
||||||
|
rtmp_url, prefix, play_path = re.split(
|
||||||
|
r'((?:mp4|mp3|flv):)', source_url, 1)
|
||||||
|
a_format.update({
|
||||||
|
'url': rtmp_url,
|
||||||
|
'ext': 'flv',
|
||||||
|
'play_path': prefix + play_path,
|
||||||
})
|
})
|
||||||
|
if rtmp_params:
|
||||||
|
a_format.update(rtmp_params)
|
||||||
|
formats.append(a_format)
|
||||||
self._sort_formats(formats)
|
self._sort_formats(formats)
|
||||||
|
|
||||||
subtitles = {}
|
subtitles = {}
|
||||||
|
Loading…
Reference in New Issue
Block a user