1 from .common
import InfoExtractor
9 class HSEShowBaseInfoExtractor(InfoExtractor
):
10 _GEO_COUNTRIES
= ['DE']
12 def _extract_redux_data(self
, url
, video_id
):
13 webpage
= self
._download
_webpage
(url
, video_id
)
14 redux
= self
._html
_search
_regex
(
15 r
'window\.__REDUX_DATA__\s*=\s*({.*});?', webpage
, 'redux data')
16 return self
._parse
_json
(redux
.replace('\n', ''), video_id
)
18 def _extract_formats_and_subtitles(self
, sources
, video_id
):
20 raise ExtractorError('No video found', expected
=True, video_id
=video_id
)
21 formats
, subtitles
= [], {}
23 if src
['mimetype'] != 'application/x-mpegURL':
25 fmts
, subs
= self
._extract
_m
3u8_formats
_and
_subtitles
(src
['url'], video_id
, ext
='mp4')
27 subtitles
= self
._merge
_subtitles
(subtitles
, subs
)
28 return formats
, subtitles
31 class HSEShowIE(HSEShowBaseInfoExtractor
):
32 _VALID_URL
= r
'https?://(?:www\.)?hse\.de/dpl/c/tv-shows/(?P<id>[0-9]+)'
34 'url': 'https://www.hse.de/dpl/c/tv-shows/505350',
38 'title': 'Pfeffinger Mode & Accessoires',
39 'timestamp': 1638810000,
40 'upload_date': '20211206',
42 'uploader': 'Arina Pirayesh',
44 'params': {'skip_download': 'm3u8'},
47 def _real_extract(self
, url
):
48 video_id
= self
._match
_id
(url
)
49 json_data
= self
._extract
_redux
_data
(url
, video_id
)
50 formats
, subtitles
= self
._extract
_formats
_and
_subtitles
(
51 traverse_obj(json_data
, ('tvShowPage', 'tvShowVideo', 'sources')), video_id
)
53 show
= traverse_obj(json_data
, ('tvShowPage', 'tvShow')) or {}
56 'title': show
.get('title') or video_id
,
58 'timestamp': unified_timestamp(f
'{show.get("date")} {show.get("hour")}:00'),
59 'thumbnail': traverse_obj(json_data
, ('tvShowVideo', 'poster')),
60 'channel': self
._search
_regex
(
61 r
'tvShow \| ([A-Z0-9]+)_', show
.get('actionFieldText') or '', video_id
, fatal
=False),
62 'uploader': show
.get('presenter'),
63 'subtitles': subtitles
,
67 class HSEProductIE(HSEShowBaseInfoExtractor
):
68 _VALID_URL
= r
'https?://(?:www\.)?hse\.de/dpl/p/product/(?P<id>[0-9]+)'
70 'url': 'https://www.hse.de/dpl/p/product/408630',
74 'title': 'Hose im Ponte-Mix',
75 'uploader': 'Judith Williams',
77 'params': {'skip_download': 'm3u8'},
80 def _real_extract(self
, url
):
81 video_id
= self
._match
_id
(url
)
82 json_data
= self
._extract
_redux
_data
(url
, video_id
)
83 video
= traverse_obj(json_data
, ('productContent', 'productContent', 'videos', 0)) or {}
84 formats
, subtitles
= self
._extract
_formats
_and
_subtitles
(video
.get('sources'), video_id
)
88 'title': traverse_obj(json_data
, ('productDetail', 'product', 'name', 'short')) or video_id
,
90 'subtitles': subtitles
,
91 'thumbnail': video
.get('poster'),
92 'uploader': traverse_obj(json_data
, ('productDetail', 'product', 'brand', 'brandName')),