logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

groupon.py (2599B)


  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. 'md5': '42428ce8a00585f9bc36e49226eae7a1',
  14. 'info_dict': {
  15. 'id': 'fk6OhWpXgIQ',
  16. 'ext': 'mp4',
  17. 'title': 'Bikram Yoga Huntington Beach | Orange County !tubGNycTo@9Uxg82uESj4i61EYX8nyuf',
  18. 'description': 'md5:d41d8cd98f00b204e9800998ecf8427e',
  19. 'duration': 45,
  20. 'upload_date': '20160405',
  21. 'uploader_id': 'groupon',
  22. 'uploader': 'Groupon',
  23. },
  24. 'add_ie': ['Youtube'],
  25. }],
  26. 'params': {
  27. 'skip_download': True,
  28. },
  29. }
  30. _PROVIDERS = {
  31. 'ooyala': ('ooyala:%s', 'Ooyala'),
  32. 'youtube': ('%s', 'Youtube'),
  33. }
  34. def _real_extract(self, url):
  35. playlist_id = self._match_id(url)
  36. webpage = self._download_webpage(url, playlist_id)
  37. payload = self._parse_json(self._search_regex(
  38. r'(?:var\s+|window\.)payload\s*=\s*(.*?);\n', webpage, 'payload'), playlist_id)
  39. videos = payload['carousel'].get('dealVideos', [])
  40. entries = []
  41. for v in videos:
  42. provider = v.get('provider')
  43. video_id = v.get('media') or v.get('id') or v.get('baseURL')
  44. if not provider or not video_id:
  45. continue
  46. url_pattern, ie_key = self._PROVIDERS.get(provider.lower())
  47. if not url_pattern:
  48. self.report_warning(
  49. '%s: Unsupported video provider %s, skipping video' %
  50. (playlist_id, provider))
  51. continue
  52. entries.append(self.url_result(url_pattern % video_id, ie_key))
  53. return {
  54. '_type': 'playlist',
  55. 'id': playlist_id,
  56. 'entries': entries,
  57. 'title': self._og_search_title(webpage),
  58. 'description': self._og_search_description(webpage),
  59. }