]> Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/elpais.py
debian/copyright: Fix lintian's dep5-copyright-license-name-not-unique.
[youtubedl] / youtube_dl / extractor / elpais.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .common import InfoExtractor
5 from ..utils import unified_strdate
6
7
8 class ElPaisIE(InfoExtractor):
9 _VALID_URL = r'https?://(?:[^.]+\.)?elpais\.com/.*/(?P<id>[^/#?]+)\.html(?:$|[?#])'
10 IE_DESC = 'El País'
11
12 _TEST = {
13 'url': 'http://blogs.elpais.com/la-voz-de-inaki/2014/02/tiempo-nuevo-recetas-viejas.html',
14 'md5': '98406f301f19562170ec071b83433d55',
15 'info_dict': {
16 'id': 'tiempo-nuevo-recetas-viejas',
17 'ext': 'mp4',
18 'title': 'Tiempo nuevo, recetas viejas',
19 'description': 'De lunes a viernes, a partir de las ocho de la mañana, Iñaki Gabilondo nos cuenta su visión de la actualidad nacional e internacional.',
20 'upload_date': '20140206',
21 }
22 }
23
24 def _real_extract(self, url):
25 video_id = self._match_id(url)
26 webpage = self._download_webpage(url, video_id)
27
28 prefix = self._html_search_regex(
29 r'var url_cache = "([^"]+)";', webpage, 'URL prefix')
30 video_suffix = self._search_regex(
31 r"URLMediaFile = url_cache \+ '([^']+)'", webpage, 'video URL')
32 video_url = prefix + video_suffix
33 thumbnail_suffix = self._search_regex(
34 r"URLMediaStill = url_cache \+ '([^']+)'", webpage, 'thumbnail URL',
35 fatal=False)
36 thumbnail = (
37 None if thumbnail_suffix is None
38 else prefix + thumbnail_suffix)
39 title = self._html_search_regex(
40 '<h2 class="entry-header entry-title.*?>(.*?)</h2>',
41 webpage, 'title')
42 date_str = self._search_regex(
43 r'<p class="date-header date-int updated"\s+title="([^"]+)">',
44 webpage, 'upload date', fatal=False)
45 upload_date = (None if date_str is None else unified_strdate(date_str))
46
47 return {
48 'id': video_id,
49 'url': video_url,
50 'title': title,
51 'description': self._og_search_description(webpage),
52 'thumbnail': thumbnail,
53 'upload_date': upload_date,
54 }