]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/groupon.py
63c05b6a6f96dfa4437f15cd77524ab3d89e1018
[youtubedl] / youtube_dl / extractor / groupon.py
1 from __future__ import unicode_literals
2
3 from .common import InfoExtractor
4
5
6 class GrouponIE(InfoExtractor):
7 _VALID_URL = r'https?://www\.groupon\.com/deals/(?P<id>[^?#]+)'
8
9 _TEST = {
10 'url': 'https://www.groupon.com/deals/bikram-yoga-huntington-beach-2#ooid=tubGNycTo_9Uxg82uESj4i61EYX8nyuf',
11 'info_dict': {
12 'id': 'bikram-yoga-huntington-beach-2',
13 'title': '$49 for 10 Yoga Classes or One Month of Unlimited Classes at Bikram Yoga Huntington Beach ($180 Value)',
14 'description': 'Studio kept at 105 degrees and 40% humidity with anti-microbial and anti-slip Flotex flooring; certified instructors',
15 },
16 'playlist': [{
17 'info_dict': {
18 'id': 'tubGNycTo_9Uxg82uESj4i61EYX8nyuf',
19 'ext': 'mp4',
20 'title': 'Bikram Yoga Huntington Beach | Orange County',
21 'description': 'md5:d41d8cd98f00b204e9800998ecf8427e',
22 'duration': 44.961,
23 },
24 }],
25 'params': {
26 'skip_download': 'HLS',
27 }
28 }
29
30 def _real_extract(self, url):
31 playlist_id = self._match_id(url)
32 webpage = self._download_webpage(url, playlist_id)
33
34 payload = self._parse_json(self._search_regex(
35 r'var\s+payload\s*=\s*(.*?);\n', webpage, 'payload'), playlist_id)
36 videos = payload['carousel'].get('dealVideos', [])
37 entries = []
38 for v in videos:
39 if v.get('provider') != 'OOYALA':
40 self.report_warning(
41 '%s: Unsupported video provider %s, skipping video' %
42 (playlist_id, v.get('provider')))
43 continue
44 entries.append(self.url_result('ooyala:%s' % v['media']))
45
46 return {
47 '_type': 'playlist',
48 'id': playlist_id,
49 'entries': entries,
50 'title': self._og_search_title(webpage),
51 'description': self._og_search_description(webpage),
52 }