logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

charlierose.py (1833B)


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