charlierose.py 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. from .common import InfoExtractor
  2. from ..utils import remove_end
  3. class CharlieRoseIE(InfoExtractor):
  4. _VALID_URL = r'https?://(?:www\.)?charlierose\.com/(?:video|episode)(?:s|/player)/(?P<id>\d+)'
  5. _TESTS = [{
  6. 'url': 'https://charlierose.com/videos/27996',
  7. 'md5': 'fda41d49e67d4ce7c2411fd2c4702e09',
  8. 'info_dict': {
  9. 'id': '27996',
  10. 'ext': 'mp4',
  11. 'title': 'Remembering Zaha Hadid',
  12. 'thumbnail': r're:^https?://.*\.jpg\?\d+',
  13. 'description': 'We revisit past conversations with Zaha Hadid, in memory of the world renowned Iraqi architect.',
  14. 'subtitles': {
  15. 'en': [{
  16. 'ext': 'vtt',
  17. }],
  18. },
  19. },
  20. }, {
  21. 'url': 'https://charlierose.com/videos/27996',
  22. 'only_matching': True,
  23. }, {
  24. 'url': 'https://charlierose.com/episodes/30887?autoplay=true',
  25. 'only_matching': True,
  26. }]
  27. _PLAYER_BASE = 'https://charlierose.com/video/player/%s'
  28. def _real_extract(self, url):
  29. video_id = self._match_id(url)
  30. webpage = self._download_webpage(self._PLAYER_BASE % video_id, video_id)
  31. title = remove_end(self._og_search_title(webpage), ' - Charlie Rose')
  32. info_dict = self._parse_html5_media_entries(
  33. self._PLAYER_BASE % video_id, webpage, video_id,
  34. m3u8_entry_protocol='m3u8_native')[0]
  35. self._remove_duplicate_formats(info_dict['formats'])
  36. info_dict.update({
  37. 'id': video_id,
  38. 'title': title,
  39. 'thumbnail': self._og_search_thumbnail(webpage),
  40. 'description': self._og_search_description(webpage),
  41. })
  42. return info_dict