comcarcoff.py 2.1 KB

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