closertotruth.py 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. class CloserToTruthIE(InfoExtractor):
  5. _VALID_URL = r'https?://(?:www\.)?closertotruth\.com/(episodes/|(series|interviews)/(?:[^#]+#video-)?(?P<id>\d+))'
  6. _TESTS = [
  7. {
  8. 'url': 'http://closertotruth.com/series/solutions-the-mind-body-problem#video-3688',
  9. 'md5': '5c548bde260a9247ddfdc07c7458ed29',
  10. 'info_dict': {
  11. 'id': '0_zof1ktre',
  12. 'ext': 'mov',
  13. 'title': 'Solutions to the Mind-Body Problem?',
  14. 'upload_date': '20140221',
  15. 'timestamp': 1392956007,
  16. 'uploader_id': 'CTTXML'
  17. }
  18. },
  19. {
  20. 'url': 'http://closertotruth.com/interviews/1725',
  21. 'md5': 'b00598fd6a38372edb976408f72c5792',
  22. 'info_dict': {
  23. 'id': '0_19qv5rn1',
  24. 'ext': 'mov',
  25. 'title': 'AyaFr-002 - Francisco J. Ayala',
  26. 'upload_date': '20140307',
  27. 'timestamp': 1394236431,
  28. 'uploader_id': 'CTTXML'
  29. }
  30. },
  31. {
  32. 'url': 'http://closertotruth.com/episodes/how-do-brains-work',
  33. 'md5': '4dd96aa0a5c296afa5c0bd24895c2f16',
  34. 'info_dict': {
  35. 'id': '0_iuxai6g6',
  36. 'ext': 'mov',
  37. 'title': 'How do Brains Work?',
  38. 'upload_date': '20140221',
  39. 'timestamp': 1392956024,
  40. 'uploader_id': 'CTTXML'
  41. }
  42. },
  43. ]
  44. def _real_extract(self, url):
  45. video_id = self._match_id(url)
  46. webpage = self._download_webpage(url, video_id)
  47. video_title = self._search_regex(r'<title>(.+) \|.+</title>', webpage, 'video title')
  48. entry_id = self._search_regex(r'<a[^>]+id="(?:video-%s|embed-kaltura)"[^>]+data-kaltura="([^"]+)' % video_id, webpage, "video entry_id")
  49. interviewee_name = self._search_regex(r'<div id="(?:node_interview_full_group_white_wrapper|node_interview_series_full_group_ajax_content)"(?:.|\n)*<h3>(.*)</h3>.+', webpage, "video interviewee_name", False)
  50. if interviewee_name:
  51. video_title = video_title + ' - ' + interviewee_name
  52. p_id = self._search_regex(r'<script[^>]+src=["\'].+?partner_id/(\d+)', webpage, "kaltura partner_id")
  53. return {
  54. '_type': 'url_transparent',
  55. 'id': entry_id,
  56. 'url': 'kaltura:%s:%s' % (p_id, entry_id),
  57. 'ie_key': 'Kaltura',
  58. 'title': video_title
  59. }