comcarcoff.py 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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'https?://(?: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. webpage = self._download_webpage(url, display_id)
  25. full_data = json.loads(self._search_regex(
  26. r'<script type="application/json" id="videoData">(?P<json>.+?)</script>',
  27. webpage, 'full data json'))
  28. video_id = full_data['activeVideo']['video']
  29. video_data = full_data['videos'][video_id]
  30. thumbnails = [{
  31. 'url': video_data['images']['thumb'],
  32. }, {
  33. 'url': video_data['images']['poster'],
  34. }]
  35. formats = self._extract_m3u8_formats(
  36. video_data['mediaUrl'], video_id, ext='mp4')
  37. return {
  38. 'id': video_id,
  39. 'display_id': display_id,
  40. 'title': video_data['title'],
  41. 'description': video_data.get('description'),
  42. 'timestamp': parse_iso8601(video_data.get('pubDate')),
  43. 'thumbnails': thumbnails,
  44. 'formats': formats,
  45. }