]> git.bitcoin.ninja Git - youtube-dl/blob - youtube_dl/extractor/groupon.py
[radiobremen] Fix under Python 2.6 and fix duration
[youtube-dl] / 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             },
22         }],
23         'params': {
24             'skip_download': 'HLS',
25         }
26     }
27
28     def _real_extract(self, url):
29         playlist_id = self._match_id(url)
30         webpage = self._download_webpage(url, playlist_id)
31
32         payload = self._parse_json(self._search_regex(
33             r'var\s+payload\s*=\s*(.*?);\n', webpage, 'payload'), playlist_id)
34         videos = payload['carousel'].get('dealVideos', [])
35         entries = []
36         for v in videos:
37             if v.get('provider') != 'OOYALA':
38                 self.report_warning(
39                     '%s: Unsupported video provider %s, skipping video' %
40                     (playlist_id, v.get('provider')))
41                 continue
42             entries.append(self.url_result('ooyala:%s' % v['media']))
43
44         return {
45             '_type': 'playlist',
46             'id': playlist_id,
47             'entries': entries,
48             'title': self._og_search_title(webpage),
49             'description': self._og_search_description(webpage),
50         }