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.

69 lines
2.5 KiB

  1. # encoding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..compat import compat_str
  5. from ..utils import (
  6. int_or_none,
  7. parse_duration,
  8. parse_iso8601,
  9. )
  10. class ComCarCoffIE(InfoExtractor):
  11. _VALID_URL = r'http://(?:www\.)?comediansincarsgettingcoffee\.com/(?P<id>[a-z0-9\-]*)'
  12. _TESTS = [{
  13. 'url': 'http://comediansincarsgettingcoffee.com/miranda-sings-happy-thanksgiving-miranda/',
  14. 'info_dict': {
  15. 'id': '2494164',
  16. 'ext': 'mp4',
  17. 'upload_date': '20141127',
  18. 'timestamp': 1417107600,
  19. 'duration': 1232,
  20. 'title': 'Happy Thanksgiving Miranda',
  21. 'description': 'Jerry Seinfeld and his special guest Miranda Sings cruise around town in search of coffee, complaining and apologizing along the way.',
  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. display_id = full_data['activeVideo']['video']
  37. video_data = full_data.get('videos', {}).get(display_id) or full_data['singleshots'][display_id]
  38. video_id = compat_str(video_data['mediaId'])
  39. thumbnails = [{
  40. 'url': video_data['images']['thumb'],
  41. }, {
  42. 'url': video_data['images']['poster'],
  43. }]
  44. timestamp = int_or_none(video_data.get('pubDateTime')) or parse_iso8601(
  45. video_data.get('pubDate'))
  46. duration = int_or_none(video_data.get('durationSeconds')) or parse_duration(
  47. video_data.get('duration'))
  48. return {
  49. '_type': 'url_transparent',
  50. 'url': 'crackle:%s' % video_id,
  51. 'id': video_id,
  52. 'display_id': display_id,
  53. 'title': video_data['title'],
  54. 'description': video_data.get('description'),
  55. 'timestamp': timestamp,
  56. 'duration': duration,
  57. 'thumbnails': thumbnails,
  58. 'season_number': int_or_none(video_data.get('season')),
  59. 'episode_number': int_or_none(video_data.get('episode')),
  60. 'webpage_url': 'http://comediansincarsgettingcoffee.com/%s' % (video_data.get('urlSlug', video_data.get('slug'))),
  61. }