1
0
mirror of https://github.com/l1ving/youtube-dl synced 2025-02-11 00:03:01 +08:00

Get all formats, not just RTMP ones, so that users don't need to install rtmpdump.

This commit is contained in:
mars67857 2017-10-15 16:58:55 -07:00
parent 437dd510d3
commit 5ce4b7599a

View File

@ -22,7 +22,8 @@ class CamModelsIE(InfoExtractor):
r'manifestUrlRoot=(?P<id>https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*))', r'manifestUrlRoot=(?P<id>https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*))',
webpage, webpage,
'manifest', 'manifest',
fatal=False) None,
False)
if not manifest_url_root: if not manifest_url_root:
offline = self._html_search_regex( offline = self._html_search_regex(
r'(?P<id>I\'m offline, but let\'s stay connected!)', r'(?P<id>I\'m offline, but let\'s stay connected!)',
@ -58,18 +59,23 @@ class CamModelsIE(InfoExtractor):
'Link to stream URLs was found, but we couldn\'t access it.', 'Link to stream URLs was found, but we couldn\'t access it.',
headers=self._HEADERS) headers=self._HEADERS)
try: try:
rtmp_formats = manifest['formats']['mp4-rtmp']['encodings']
formats = [] formats = []
for format in rtmp_formats: all_formats = manifest['formats']
formats.append({ for fmtName in all_formats:
'ext': 'flv', fmt = all_formats[fmtName]
'url': format.get('location'), encodings = fmt.get('encodings')
'width': format.get('videoWidth'), if not encodings:
'height': format.get('videoHeight'), continue
'vbr': format.get('videoKbps'), for encoding in encodings:
'abr': format.get('audioKbps'), formats.append({
'format_id': str(format.get('videoWidth')) 'ext': 'mp4',
}) 'url': encoding.get('location'),
'width': encoding.get('videoWidth'),
'height': encoding.get('videoHeight'),
'vbr': encoding.get('videoKbps'),
'abr': encoding.get('audioKbps'),
'format_id': fmtName + str(encoding.get('videoWidth'))
})
# If they change the JSON format, then fallback to parsing out RTMP links via regex. # If they change the JSON format, then fallback to parsing out RTMP links via regex.
except KeyError: except KeyError:
manifest_json = json.dumps(manifest) manifest_json = json.dumps(manifest)