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.

67 lines
2.5 KiB

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