You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
2.0 KiB

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