]>
Commit | Line | Data |
---|---|---|
5de90176 PH |
1 | # coding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
5de90176 PH |
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(?:$|[?#])' | |
bf3a2fe9 | 10 | IE_DESC = 'El País' |
5de90176 | 11 | |
d1b29d13 | 12 | _TESTS = [{ |
5de90176 PH |
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 | } | |
d1b29d13 S |
22 | }, { |
23 | 'url': 'http://elcomidista.elpais.com/elcomidista/2016/02/24/articulo/1456340311_668921.html#?id_externo_nwl=newsletter_diaria20160303t', | |
24 | 'md5': '3bd5b09509f3519d7d9e763179b013de', | |
25 | 'info_dict': { | |
26 | 'id': '1456340311_668921', | |
27 | 'ext': 'mp4', | |
28 | 'title': 'Cómo hacer el mejor café con cafetera italiana', | |
29 | 'description': 'Que sí, que las cápsulas son cómodas. Pero si le pides algo más a la vida, quizá deberías aprender a usar bien la cafetera italiana. No tienes más que ver este vídeo y seguir sus siete normas básicas.', | |
30 | 'upload_date': '20160303', | |
31 | } | |
32 | }] | |
5de90176 PH |
33 | |
34 | def _real_extract(self, url): | |
b8da6b9f | 35 | video_id = self._match_id(url) |
5de90176 PH |
36 | webpage = self._download_webpage(url, video_id) |
37 | ||
38 | prefix = self._html_search_regex( | |
d1b29d13 | 39 | r'var\s+url_cache\s*=\s*"([^"]+)";', webpage, 'URL prefix') |
5de90176 | 40 | video_suffix = self._search_regex( |
d1b29d13 | 41 | r"(?:URLMediaFile|urlVideo_\d+)\s*=\s*url_cache\s*\+\s*'([^']+)'", webpage, 'video URL') |
5de90176 PH |
42 | video_url = prefix + video_suffix |
43 | thumbnail_suffix = self._search_regex( | |
d1b29d13 S |
44 | r"(?:URLMediaStill|urlFotogramaFijo_\d+)\s*=\s*url_cache\s*\+\s*'([^']+)'", |
45 | webpage, 'thumbnail URL', fatal=False) | |
5de90176 PH |
46 | thumbnail = ( |
47 | None if thumbnail_suffix is None | |
48 | else prefix + thumbnail_suffix) | |
49 | title = self._html_search_regex( | |
d1b29d13 S |
50 | (r"tituloVideo\s*=\s*'([^']+)'", webpage, 'title', |
51 | r'<h2 class="entry-header entry-title.*?>(.*?)</h2>'), | |
5de90176 | 52 | webpage, 'title') |
d1b29d13 | 53 | upload_date = unified_strdate(self._search_regex( |
5de90176 | 54 | r'<p class="date-header date-int updated"\s+title="([^"]+)">', |
d1b29d13 S |
55 | webpage, 'upload date', default=None) or self._html_search_meta( |
56 | 'datePublished', webpage, 'timestamp')) | |
5de90176 PH |
57 | |
58 | return { | |
59 | 'id': video_id, | |
60 | 'url': video_url, | |
61 | 'title': title, | |
62 | 'description': self._og_search_description(webpage), | |
63 | 'thumbnail': thumbnail, | |
64 | 'upload_date': upload_date, | |
65 | } |