[ie/wistia] Support password-protected videos (#11100)
[yt-dlp3.git] / yt_dlp / extractor / groupon.py
bloba05fab1f14b774e4ba85554cfdeeefb964e860d1
1 from .common import InfoExtractor
4 class GrouponIE(InfoExtractor):
5 _VALID_URL = r'https?://(?:www\.)?groupon\.com/deals/(?P<id>[^/?#&]+)'
7 _TEST = {
8 'url': 'https://www.groupon.com/deals/bikram-yoga-huntington-beach-2#ooid=tubGNycTo_9Uxg82uESj4i61EYX8nyuf',
9 'info_dict': {
10 'id': 'bikram-yoga-huntington-beach-2',
11 'title': '$49 for 10 Yoga Classes or One Month of Unlimited Classes at Bikram Yoga Huntington Beach ($180 Value)',
12 'description': 'Studio kept at 105 degrees and 40% humidity with anti-microbial and anti-slip Flotex flooring; certified instructors',
14 'playlist': [{
15 'md5': '42428ce8a00585f9bc36e49226eae7a1',
16 'info_dict': {
17 'id': 'fk6OhWpXgIQ',
18 'ext': 'mp4',
19 'title': 'Bikram Yoga Huntington Beach | Orange County !tubGNycTo@9Uxg82uESj4i61EYX8nyuf',
20 'description': 'md5:d41d8cd98f00b204e9800998ecf8427e',
21 'duration': 45,
22 'upload_date': '20160405',
23 'uploader_id': 'groupon',
24 'uploader': 'Groupon',
26 'add_ie': ['Youtube'],
27 }],
28 'params': {
29 'skip_download': True,
33 _PROVIDERS = {
34 'youtube': ('%s', 'Youtube'),
37 def _real_extract(self, url):
38 playlist_id = self._match_id(url)
39 webpage = self._download_webpage(url, playlist_id)
41 payload = self._parse_json(self._search_regex(
42 r'(?:var\s+|window\.)payload\s*=\s*(.*?);\n', webpage, 'payload'), playlist_id)
43 videos = payload['carousel'].get('dealVideos', [])
44 entries = []
45 for v in videos:
46 provider = v.get('provider')
47 video_id = v.get('media') or v.get('id') or v.get('baseURL')
48 if not provider or not video_id:
49 continue
50 url_pattern, ie_key = self._PROVIDERS.get(provider.lower())
51 if not url_pattern:
52 self.report_warning(
53 f'{playlist_id}: Unsupported video provider {provider}, skipping video')
54 continue
55 entries.append(self.url_result(url_pattern % video_id, ie_key))
57 return {
58 '_type': 'playlist',
59 'id': playlist_id,
60 'entries': entries,
61 'title': self._og_search_title(webpage),
62 'description': self._og_search_description(webpage),