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.

57 lines
2.2 KiB

  1. # encoding: utf-8
  2. from __future__ import unicode_literals
  3. import json
  4. from .common import InfoExtractor
  5. from ..utils import parse_iso8601
  6. class ComCarCoffIE(InfoExtractor):
  7. _VALID_URL = r'http://(?:www\.)?comediansincarsgettingcoffee\.com/(?P<id>[a-z0-9\-]*)'
  8. _TESTS = [{
  9. 'url': 'http://comediansincarsgettingcoffee.com/miranda-sings-happy-thanksgiving-miranda/',
  10. 'info_dict': {
  11. 'id': 'miranda-sings-happy-thanksgiving-miranda',
  12. 'ext': 'mp4',
  13. 'upload_date': '20141127',
  14. 'timestamp': 1417107600,
  15. 'title': 'Happy Thanksgiving Miranda',
  16. 'description': 'Jerry Seinfeld and his special guest Miranda Sings cruise around town in search of coffee, complaining and apologizing along the way.',
  17. 'thumbnail': 'http://ccc.crackle.com/images/s5e4_thumb.jpg',
  18. },
  19. 'params': {
  20. 'skip_download': 'requires ffmpeg',
  21. }
  22. }]
  23. def _real_extract(self, url):
  24. display_id = self._match_id(url)
  25. if not display_id:
  26. display_id = 'comediansincarsgettingcoffee.com'
  27. webpage = self._download_webpage(url, display_id)
  28. full_data = json.loads(self._search_regex(
  29. r'<script type="application/json" id="videoData">(?P<json>.+?)</script>',
  30. webpage, 'full data json'))
  31. video_id = full_data['activeVideo']['video']
  32. video_data = full_data.get('videos', {}).get(video_id) or full_data['singleshots'][video_id]
  33. thumbnails = [{
  34. 'url': video_data['images']['thumb'],
  35. }, {
  36. 'url': video_data['images']['poster'],
  37. }]
  38. formats = self._extract_m3u8_formats(
  39. video_data['mediaUrl'], video_id, ext='mp4')
  40. return {
  41. 'id': video_id,
  42. 'display_id': display_id,
  43. 'title': video_data['title'],
  44. 'description': video_data.get('description'),
  45. 'timestamp': parse_iso8601(video_data.get('pubDate')),
  46. 'thumbnails': thumbnails,
  47. 'formats': formats,
  48. 'webpage_url': 'http://comediansincarsgettingcoffee.com/%s' % (video_data.get('urlSlug', video_data.get('slug'))),
  49. }