aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorremitamine <remitamine@gmail.com>2015-10-31 04:02:49 +0100
committerSergey M․ <dstftw@gmail.com>2015-11-01 00:56:16 +0600
commit80dcee5cd5cbe623a53e0c582e3e3ae170c63e8d (patch)
treecd2d720a0a8be7ca091a2a87a797fa3c0683905a
parent30eecc6a044d4070d0e8ea4a6e0637867f0d3a28 (diff)
[eitb] fix info extraction
-rw-r--r--youtube_dl/extractor/eitb.py65
1 files changed, 44 insertions, 21 deletions
diff --git a/youtube_dl/extractor/eitb.py b/youtube_dl/extractor/eitb.py
index 2cba82532..fc8f15544 100644
--- a/youtube_dl/extractor/eitb.py
+++ b/youtube_dl/extractor/eitb.py
@@ -1,39 +1,62 @@
# encoding: utf-8
from __future__ import unicode_literals
-import re
-
from .common import InfoExtractor
-from .brightcove import BrightcoveIE
-from ..utils import ExtractorError
+from ..compat import compat_urllib_request
+from ..utils import (
+ int_or_none,
+ unified_strdate,
+)
class EitbIE(InfoExtractor):
IE_NAME = 'eitb.tv'
- _VALID_URL = r'https?://www\.eitb\.tv/(eu/bideoa|es/video)/[^/]+/(?P<playlist_id>\d+)/(?P<chapter_id>\d+)'
+ _VALID_URL = r'https?://www\.eitb\.tv/(eu/bideoa|es/video)/[^/]+/\d+/(?P<id>\d+)'
_TEST = {
- 'add_ie': ['Brightcove'],
- 'url': 'http://www.eitb.tv/es/video/60-minutos-60-minutos-2013-2014/2677100210001/2743577154001/lasa-y-zabala-30-anos/',
+ 'url': 'http://www.eitb.tv/es/video/60-minutos-60-minutos-2013-2014/4104995148001/4090227752001/lasa-y-zabala-30-anos/',
'md5': 'edf4436247185adee3ea18ce64c47998',
'info_dict': {
- 'id': '2743577154001',
+ 'id': '4090227752001',
'ext': 'mp4',
'title': '60 minutos (Lasa y Zabala, 30 años)',
- # All videos from eitb has this description in the brightcove info
- 'description': '.',
- 'uploader': 'Euskal Telebista',
+ 'description': '',
+ 'duration': 3996760,
+ 'upload_date': '20131014',
},
}
def _real_extract(self, url):
- mobj = re.match(self._VALID_URL, url)
- chapter_id = mobj.group('chapter_id')
- webpage = self._download_webpage(url, chapter_id)
- bc_url = BrightcoveIE._extract_brightcove_url(webpage)
- if bc_url is None:
- raise ExtractorError('Could not extract the Brightcove url')
- # The BrightcoveExperience object doesn't contain the video id, we set
- # it manually
- bc_url += '&%40videoPlayer={0}'.format(chapter_id)
- return self.url_result(bc_url, BrightcoveIE.ie_key())
+ video_id = self._match_id(url)
+ video_data = self._download_json('http://mam.eitb.eus/mam/REST/ServiceMultiweb/Video/MULTIWEBTV/%s/' % video_id, video_id)['web_media'][0]
+
+ formats = []
+ for rendition in video_data['RENDITIONS']:
+ formats.append({
+ 'url': rendition['PMD_URL'],
+ 'width': int_or_none(rendition.get('FRAME_WIDTH')),
+ 'height': int_or_none(rendition.get('FRAME_HEIGHT')),
+ 'tbr': int_or_none(rendition.get('ENCODING_RATE')),
+ })
+
+ # TODO: parse f4m manifest
+ request = compat_urllib_request.Request(
+ 'http://mam.eitb.eus/mam/REST/ServiceMultiweb/DomainRestrictedSecurity/TokenAuth/',
+ headers={'Referer': url})
+ token_data = self._download_json(request, video_id, fatal=False)
+ if token_data:
+ m3u8_formats = self._extract_m3u8_formats('%s?hdnts=%s' % (video_data['HLS_SURL'], token_data['token']), video_id, m3u8_id='hls', fatal=False)
+ if m3u8_formats:
+ formats.extend(m3u8_formats)
+
+ self._sort_formats(formats)
+
+ return {
+ 'id': video_id,
+ 'title': video_data['NAME_ES'],
+ 'description': video_data.get('SHORT_DESC_ES'),
+ 'thumbnail': video_data.get('STILL_URL'),
+ 'duration': int_or_none(video_data.get('LENGTH')),
+ 'upload_date': unified_strdate(video_data.get('BROADCST_DATE')),
+ 'formats': formats,
+ }