mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2025-02-06 18:20:02 +00:00
Move JWPlayer JSON array handling to IQM2
Out of @yan12125's concern that the presumption that JWPlayer data as an array representing multiple formats rather than a playlist might be specific to IQM2, move this code from jwplatform.py to iqm2.py. JWPlatformBase now reverts to throwing a TypeError if it gets an array. Now IQM2 redefines the _extract_jwplayer_data() method as well, but it continues to leverage JWPlatformBase for _parse_jwplayer_data(), which is the bulk of the work.
This commit is contained in:
parent
cb2e9ec69e
commit
02f4d4e44f
@ -1,12 +1,12 @@
|
||||
# coding: utf-8
|
||||
from __future__ import unicode_literals
|
||||
from ..utils import smuggle_url
|
||||
|
||||
import re
|
||||
|
||||
from .common import InfoExtractor
|
||||
from ..compat import compat_urlparse
|
||||
from .jwplatform import JWPlatformBaseIE
|
||||
from ..utils import js_to_json
|
||||
|
||||
# IQM2 aka Accela is a municipal meeting management platform that
|
||||
# (among other things) stores livestreamed video from municipal
|
||||
@ -63,6 +63,18 @@ class IQM2IE(JWPlatformBaseIE):
|
||||
if mobj:
|
||||
return mobj.group('options')
|
||||
|
||||
def _extract_jwplayer_data(self, webpage, video_id, *args, **kwargs):
|
||||
jwplayer_data = self._parse_json(
|
||||
self._find_jwplayer_data(webpage), video_id,
|
||||
transform_source=js_to_json)
|
||||
|
||||
assert(isinstance(jwplayer_data, list))
|
||||
jwplayer_data = {'sources': jwplayer_data }
|
||||
jwplayer_data['tracks'] = jwplayer_data['sources'][0].get('tracks')
|
||||
|
||||
return self._parse_jwplayer_data(
|
||||
jwplayer_data, video_id, *args, **kwargs)
|
||||
|
||||
def _real_extract(self, url):
|
||||
parent_id = self._match_id(url)
|
||||
webpage = self._download_webpage(url, parent_id)
|
||||
|
@ -50,11 +50,7 @@ class JWPlatformBaseIE(InfoExtractor):
|
||||
# JWPlayer backward compatibility: flattened sources
|
||||
# https://github.com/jwplayer/jwplayer/blob/v7.4.3/src/js/playlist/item.js#L29-L35
|
||||
if 'sources' not in video_data:
|
||||
if isinstance(video_data, list):
|
||||
video_data = {'sources': video_data }
|
||||
video_data['tracks'] = video_data['sources'][0].get('tracks')
|
||||
else:
|
||||
video_data['sources'] = [video_data]
|
||||
video_data['sources'] = [video_data]
|
||||
|
||||
this_video_id = video_id or video_data['mediaid']
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user