from __future__ import unicode_literals import re from .common import InfoExtractor from ..utils import ( compat_parse_qs, compat_urlparse, determine_ext, unified_strdate, ) class WDRIE(InfoExtractor): _PLAYER_REGEX = '-(?:video|audio)player(?:_size-[LMS])?' _VALID_URL = r'(?Phttps?://www\d?\.(?:wdr\d?|funkhauseuropa)\.de/)(?P.+?)(?P%s)?\.html' % _PLAYER_REGEX _TESTS = [ { 'url': 'http://www1.wdr.de/mediathek/video/sendungen/servicezeit/videoservicezeit560-videoplayer_size-L.html', 'info_dict': { 'id': 'mdb-362427', 'ext': 'flv', 'title': 'Servicezeit', 'description': 'md5:c8f43e5e815eeb54d0b96df2fba906cb', 'upload_date': '20140310', }, 'params': { 'skip_download': True, }, }, { 'url': 'http://www1.wdr.de/themen/av/videomargaspiegelisttot101-videoplayer.html', 'info_dict': { 'id': 'mdb-363194', 'ext': 'flv', 'title': 'Marga Spiegel ist tot', 'description': 'md5:2309992a6716c347891c045be50992e4', 'upload_date': '20140311', }, 'params': { 'skip_download': True, }, }, { 'url': 'http://www1.wdr.de/themen/kultur/audioerlebtegeschichtenmargaspiegel100-audioplayer.html', 'md5': '83e9e8fefad36f357278759870805898', 'info_dict': { 'id': 'mdb-194332', 'ext': 'mp3', 'title': 'Erlebte Geschichten: Marga Spiegel (29.11.2009)', 'description': 'md5:2309992a6716c347891c045be50992e4', 'upload_date': '20091129', }, }, { 'url': 'http://www.funkhauseuropa.de/av/audiogrenzenlosleckerbaklava101-audioplayer.html', 'md5': 'cfff440d4ee64114083ac44676df5d15', 'info_dict': { 'id': 'mdb-363068', 'ext': 'mp3', 'title': 'Grenzenlos lecker - Baklava', 'description': 'md5:7b29e97e10dfb6e265238b32fa35b23a', 'upload_date': '20140311', }, }, ] def _real_extract(self, url): mobj = re.match(self._VALID_URL, url) page_url = mobj.group('url') page_id = mobj.group('id') webpage = self._download_webpage(url, page_id) if mobj.group('player') is None: entries = [ self.url_result(page_url + href, 'WDR') for href in re.findall(r'

Sendedatum:\s*([0-9\.]+)

', webpage, 'air date') title_str = self._html_search_regex( r'

(.*?)

', webpage, 'title') title = '%s - %s' % (title_date, title_str) upload_date = unified_strdate( self._html_search_meta('dc.date', webpage)) fields = compat_parse_qs(param_code) video_url = fields['firstVideo'][0] thumbnail = compat_urlparse.urljoin(url, fields['startPicture'][0]) formats = [{ 'format_id': 'rtmp', 'url': video_url, }] jscode = self._download_webpage( 'http://www.wdrmaus.de/codebase/js/extended-medien.min.js', video_id, fatal=False, note='Downloading URL translation table', errnote='Could not download URL translation table') if jscode: for m in re.finditer( r"stream:\s*'dslSrc=(?P[^']+)',\s*download:\s*'(?P
[^']+)'\s*\}", jscode): if video_url.startswith(m.group('stream')): http_url = video_url.replace( m.group('stream'), m.group('dl')) formats.append({ 'format_id': 'http', 'url': http_url, }) break self._sort_formats(formats) return { 'id': video_id, 'title': title, 'formats': formats, 'thumbnail': thumbnail, 'upload_date': upload_date, } # TODO test _1