mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-27 01:31:25 +01:00
Compare commits
2 Commits
ca727e78ad
...
263303c5e3
Author | SHA1 | Date | |
---|---|---|---|
|
263303c5e3 | ||
|
8c23e06dcd |
|
@ -1,10 +1,7 @@
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ._extractors import BrightcoveNewIE
|
from .brightcove import BrightcoveNewIE
|
||||||
|
|
||||||
from ..utils import (
|
from ..utils import ExtractorError, traverse_obj
|
||||||
ExtractorError,
|
|
||||||
traverse_obj,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class News9IE(InfoExtractor):
|
class News9IE(InfoExtractor):
|
||||||
|
@ -59,17 +56,11 @@ class News9IE(InfoExtractor):
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
article_id = self._match_id(url)
|
article_id = self._match_id(url)
|
||||||
webpage = self._download_webpage(url, article_id)
|
webpage = self._download_webpage(url, article_id)
|
||||||
initial_state = self._search_json(r'var\s__INITIAL_STATE__\s*=', webpage, 'initial state', article_id)
|
initial_state = self._search_json(r'var\s+__INITIAL_STATE__\s*=', webpage, 'initial state', article_id)
|
||||||
|
video_id = traverse_obj(
|
||||||
info = traverse_obj(initial_state, {
|
initial_state, ('videoIndex', 'currentVideo', 'brightcoveId'),
|
||||||
'video_id': ('videoIndex', 'currentVideo', 'brightcoveId'),
|
('article', ..., 'media', lambda _, v: v['type'] == 'video', 'urn'), get_all=False)
|
||||||
'account': ('videoIndex', 'config', 'account'),
|
account = traverse_obj(initial_state, ('videoIndex', 'config', (None, 'video'), 'account'), get_all=False)
|
||||||
}) or traverse_obj(initial_state, {
|
|
||||||
'video_id': ('article', ..., 'media', lambda _, v: v['type'] == 'video', 'urn'),
|
|
||||||
'account': ('videoIndex', 'config', 'video', 'account')}, get_all=False)
|
|
||||||
|
|
||||||
video_id = info.get('video_id')
|
|
||||||
account = info.get('account')
|
|
||||||
|
|
||||||
if not video_id or not account:
|
if not video_id or not account:
|
||||||
raise ExtractorError('Unable to get the required video data')
|
raise ExtractorError('Unable to get the required video data')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user