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.

74 lines
2.7 KiB

  1. # coding: 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'https?://(?: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. title = video_data['title']
  40. formats = self._extract_m3u8_formats(
  41. video_data['mediaUrl'], video_id, 'mp4')
  42. self._sort_formats(formats)
  43. thumbnails = [{
  44. 'url': video_data['images']['thumb'],
  45. }, {
  46. 'url': video_data['images']['poster'],
  47. }]
  48. timestamp = int_or_none(video_data.get('pubDateTime')) or parse_iso8601(
  49. video_data.get('pubDate'))
  50. duration = int_or_none(video_data.get('durationSeconds')) or parse_duration(
  51. video_data.get('duration'))
  52. return {
  53. 'id': video_id,
  54. 'display_id': display_id,
  55. 'title': title,
  56. 'description': video_data.get('description'),
  57. 'timestamp': timestamp,
  58. 'duration': duration,
  59. 'thumbnails': thumbnails,
  60. 'formats': formats,
  61. 'season_number': int_or_none(video_data.get('season')),
  62. 'episode_number': int_or_none(video_data.get('episode')),
  63. 'webpage_url': 'http://comediansincarsgettingcoffee.com/%s' % (video_data.get('urlSlug', video_data.get('slug'))),
  64. }