2 from .common
import InfoExtractor
10 class HSEShowBaseInfoExtractor(InfoExtractor
):
11 _GEO_COUNTRIES
= ['DE']
13 def _extract_redux_data(self
, url
, video_id
):
14 webpage
= self
._download
_webpage
(url
, video_id
)
15 redux
= self
._html
_search
_regex
(
16 r
'window\.__REDUX_DATA__\s*=\s*({.*});?', webpage
, 'redux data')
17 return self
._parse
_json
(redux
.replace('\n', ''), video_id
)
19 def _extract_formats_and_subtitles(self
, sources
, video_id
):
21 raise ExtractorError('No video found', expected
=True, video_id
=video_id
)
22 formats
, subtitles
= [], {}
24 if src
['mimetype'] != 'application/x-mpegURL':
26 fmts
, subs
= self
._extract
_m
3u8_formats
_and
_subtitles
(src
['url'], video_id
, ext
='mp4')
28 subtitles
= self
._merge
_subtitles
(subtitles
, subs
)
29 self
._sort
_formats
(formats
)
30 return formats
, subtitles
33 class HSEShowIE(HSEShowBaseInfoExtractor
):
34 _VALID_URL
= r
'https?://(?:www\.)?hse\.de/dpl/c/tv-shows/(?P<id>[0-9]+)'
36 'url': 'https://www.hse.de/dpl/c/tv-shows/505350',
40 'title': 'Pfeffinger Mode & Accessoires',
41 'timestamp': 1638810000,
42 'upload_date': '20211206',
44 'uploader': 'Arina Pirayesh'
46 'params': {'skip_download': 'm3u8'}
,
49 def _real_extract(self
, url
):
50 video_id
= self
._match
_id
(url
)
51 json_data
= self
._extract
_redux
_data
(url
, video_id
)
52 formats
, subtitles
= self
._extract
_formats
_and
_subtitles
(
53 traverse_obj(json_data
, ('tvShowPage', 'tvShowVideo', 'sources')), video_id
)
55 show
= traverse_obj(json_data
, ('tvShowPage', 'tvShow')) or {}
58 'title': show
.get('title') or video_id
,
60 'timestamp': unified_timestamp(f
'{show.get("date")} {show.get("hour")}:00'),
61 'thumbnail': traverse_obj(json_data
, ('tvShowVideo', 'poster')),
62 'channel': self
._search
_regex
(
63 r
'tvShow \| ([A-Z0-9]+)_', show
.get('actionFieldText') or '', video_id
, fatal
=False),
64 'uploader': show
.get('presenter'),
65 'subtitles': subtitles
,
69 class HSEProductIE(HSEShowBaseInfoExtractor
):
70 _VALID_URL
= r
'https?://(?:www\.)?hse\.de/dpl/p/product/(?P<id>[0-9]+)'
72 'url': 'https://www.hse.de/dpl/p/product/408630',
76 'title': 'Hose im Ponte-Mix',
77 'uploader': 'Judith Williams'
79 'params': {'skip_download': 'm3u8'}
,
82 def _real_extract(self
, url
):
83 video_id
= self
._match
_id
(url
)
84 json_data
= self
._extract
_redux
_data
(url
, video_id
)
85 video
= traverse_obj(json_data
, ('productContent', 'productContent', 'videos', 0)) or {}
86 formats
, subtitles
= self
._extract
_formats
_and
_subtitles
(video
.get('sources'), video_id
)
90 'title': traverse_obj(json_data
, ('productDetail', 'product', 'name', 'short')) or video_id
,
92 'subtitles': subtitles
,
93 'thumbnail': video
.get('poster'),
94 'uploader': traverse_obj(json_data
, ('productDetail', 'product', 'brand', 'brandName')),