processed comments on commit 5650b0d, fixed feedback from flake8

This commit is contained in:
Steven Gosseling 2016-02-27 18:06:38 +01:00
parent 5650b0d582
commit 0b6645fdb5

View File

@ -2,14 +2,9 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import re import re
import itertools
import hashlib
from .common import InfoExtractor from .common import InfoExtractor
from ..utils import (
int_or_none,
unified_strdate,
)
class CloserToTruthIE(InfoExtractor): class CloserToTruthIE(InfoExtractor):
_VALID_URL = r'http?://(?:www\.)?closertotruth\.com/series/\S+#video-(?P<id>\w+)' _VALID_URL = r'http?://(?:www\.)?closertotruth\.com/series/\S+#video-(?P<id>\w+)'
@ -17,45 +12,27 @@ class CloserToTruthIE(InfoExtractor):
'url': 'http://closertotruth.com/series/solutions-the-mind-body-problem#video-3688', 'url': 'http://closertotruth.com/series/solutions-the-mind-body-problem#video-3688',
'md5': '2aa5b8971633d86fe32152827846a5b4', 'md5': '2aa5b8971633d86fe32152827846a5b4',
'info_dict': { 'info_dict': {
'id': '3688', 'id': '0_zh2b6eqr',
'ext': 'mov', 'ext': 'mov',
'title': 'Solutions to the Mind-Body Problem? - Dean W.Zimmerman ' 'title': 'ZimDe-010-S',
} 'upload_date': '20140307',
},{ 'timestamp': 1394236392,
'url': 'http://closertotruth.com/series/solutions-the-mind-body-problem#video-4048', 'uploader_id': 'CTTXML'
'md5': 'a3882bb6e453720d8a7a3983f58abd04',
'info_dict': {
'id': '4048',
'ext': 'mov',
'title': 'Solutions to the Mind-Body Problem? - John Searle '
} }
}] }]
def _real_extract(self, url): def _real_extract(self, url):
video_id = self._match_id(url) video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id) webpage = self._download_webpage(url, video_id)
#compose title for video
video_title = self._search_regex(r'<title>(.+) \|.+</title>', webpage, 'video title') video_title = self._search_regex(r'<title>(.+) \|.+</title>', webpage, 'video title')
entry_id = self._search_regex(r'<a href="\S+" id="video-'+video_id+'" data-kaltura="(\w+)">.+<span.+<\/a>', webpage, "video entry_id") entry_id = self._search_regex(r'<a href="\S+" id="video-' + video_id + '" data-kaltura="(\w+)">.+<span.+<\/a>', webpage, "video entry_id")
interviewee_name = re.sub(r'(<[^>]+>)', '',self._search_regex(r'<a href="\S+" id="video-'+video_id+'" data-kaltura="\w+">(.+)<span.+<\/a>', webpage, "video interviewee_name")) interviewee_name = re.sub(r'(<[^>]+>)', '', self._search_regex(r'<a href="\S+" id="video-' + video_id + '" data-kaltura="\w+">(.+)<span.+<\/a>', webpage, "video interviewee_name"))
video_title = video_title + ' - ' + interviewee_name video_title = video_title + ' - ' + interviewee_name
#extract the partner id for kaltura.com # extract the partner id for kaltura.com
p_id = self._search_regex(r'<script src="http://cdnapi\.kaltura\.com/p/(?P<p>\w+)/sp/\w+/\S+/partner_id/\w+"></script>', webpage, "kaltura partner_id") p_id = self._search_regex(r'<script src="http://cdnapi\.kaltura\.com/p/(?P<p>\w+)/sp/\w+/\S+/partner_id/\w+"></script>', webpage, "kaltura partner_id")
#request video url at kaltura API return self.url_result('kaltura:%s:%s' % (p_id, entry_id), 'Kaltura', entry_id, video_title)
#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'<media url="(\S+)"', api_response, "video url")
return {
'url': video_url,
'id': video_id,
'title': video_title,
}