From 5650b0d582d43ab5ee88a66267dc1899ff181205 Mon Sep 17 00:00:00 2001 From: Steven Gosseling Date: Fri, 26 Feb 2016 13:31:52 +0100 Subject: [PATCH] [closertotruth] Add new extractor Removed print statement from code. Replaced two regex searches with the corret ones. Removed some unnecessary semicolumns fixed title extraction refactored everything to search_regex --- youtube_dl/extractor/__init__.py | 1 + youtube_dl/extractor/closertotruth.py | 61 +++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 youtube_dl/extractor/closertotruth.py diff --git a/youtube_dl/extractor/__init__.py b/youtube_dl/extractor/__init__.py index 1ae606f1e..8611cceb1 100644 --- a/youtube_dl/extractor/__init__.py +++ b/youtube_dl/extractor/__init__.py @@ -115,6 +115,7 @@ from .cinemassacre import CinemassacreIE from .clipfish import ClipfishIE from .cliphunter import CliphunterIE from .clipsyndicate import ClipsyndicateIE +from .closertotruth import CloserToTruthIE from .cloudy import CloudyIE from .clubic import ClubicIE from .clyp import ClypIE diff --git a/youtube_dl/extractor/closertotruth.py b/youtube_dl/extractor/closertotruth.py new file mode 100644 index 000000000..11781b0b7 --- /dev/null +++ b/youtube_dl/extractor/closertotruth.py @@ -0,0 +1,61 @@ +# coding: utf-8 +from __future__ import unicode_literals + +import re +import itertools +import hashlib + +from .common import InfoExtractor +from ..utils import ( + int_or_none, + unified_strdate, +) + +class CloserToTruthIE(InfoExtractor): + _VALID_URL = r'http?://(?:www\.)?closertotruth\.com/series/\S+#video-(?P\w+)' + _TESTS = [{ + 'url': 'http://closertotruth.com/series/solutions-the-mind-body-problem#video-3688', + 'md5': '2aa5b8971633d86fe32152827846a5b4', + 'info_dict': { + 'id': '3688', + 'ext': 'mov', + 'title': 'Solutions to the Mind-Body Problem? - Dean W.Zimmerman ' + } + },{ + 'url': 'http://closertotruth.com/series/solutions-the-mind-body-problem#video-4048', + 'md5': 'a3882bb6e453720d8a7a3983f58abd04', + 'info_dict': { + 'id': '4048', + 'ext': 'mov', + 'title': 'Solutions to the Mind-Body Problem? - John Searle ' + } + }] + + + def _real_extract(self, url): + video_id = self._match_id(url) + webpage = self._download_webpage(url, video_id) + + #compose title for video + video_title = self._search_regex(r'(.+) \|.+', webpage, 'video title') + + entry_id = self._search_regex(r'.+', webpage, "video entry_id") + interviewee_name = re.sub(r'(<[^>]+>)', '',self._search_regex(r'(.+)', webpage, "video interviewee_name")) + + video_title = video_title + ' - ' + interviewee_name + + #extract the partner id for kaltura.com + p_id = self._search_regex(r'', webpage, "kaltura partner_id") + + #request video url at kaltura API + #from: http://knowledge.kaltura.com/faq/how-retrieve-download-or-streaming-url-using-api-calls + api_request_url = 'http://www.kaltura.com/p/'+p_id+'/sp/0/playManifest/entryId/'+entry_id+'/protocol/HTTPS/flavorParamId/0/video.mp4' + api_response = self._download_webpage(api_request_url, video_id) + + video_url = self._search_regex(r'