]>
Commit | Line | Data |
---|---|---|
1 | from .common import InfoExtractor | |
2 | from ..utils import strip_jsonp, unified_strdate | |
3 | ||
4 | ||
5 | class ElPaisIE(InfoExtractor): | |
6 | _VALID_URL = r'https?://(?:[^.]+\.)?elpais\.com/.*/(?P<id>[^/#?]+)\.html(?:$|[?#])' | |
7 | IE_DESC = 'El País' | |
8 | ||
9 | _TESTS = [{ | |
10 | 'url': 'http://blogs.elpais.com/la-voz-de-inaki/2014/02/tiempo-nuevo-recetas-viejas.html', | |
11 | 'md5': '98406f301f19562170ec071b83433d55', | |
12 | 'info_dict': { | |
13 | 'id': 'tiempo-nuevo-recetas-viejas', | |
14 | 'ext': 'mp4', | |
15 | 'title': 'Tiempo nuevo, recetas viejas', | |
16 | '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.', | |
17 | 'upload_date': '20140206', | |
18 | }, | |
19 | }, { | |
20 | 'url': 'http://elcomidista.elpais.com/elcomidista/2016/02/24/articulo/1456340311_668921.html#?id_externo_nwl=newsletter_diaria20160303t', | |
21 | 'md5': '3bd5b09509f3519d7d9e763179b013de', | |
22 | 'info_dict': { | |
23 | 'id': '1456340311_668921', | |
24 | 'ext': 'mp4', | |
25 | 'title': 'Cómo hacer el mejor café con cafetera italiana', | |
26 | '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.', | |
27 | 'upload_date': '20160303', | |
28 | }, | |
29 | }, { | |
30 | 'url': 'http://elpais.com/elpais/2017/01/26/ciencia/1485456786_417876.html', | |
31 | 'md5': '9c79923a118a067e1a45789e1e0b0f9c', | |
32 | 'info_dict': { | |
33 | 'id': '1485456786_417876', | |
34 | 'ext': 'mp4', | |
35 | 'title': 'Hallado un barco de la antigua Roma que naufragó en Baleares hace 1.800 años', | |
36 | 'description': 'La nave portaba cientos de ánforas y se hundió cerca de la isla de Cabrera por razones desconocidas', | |
37 | 'upload_date': '20170127', | |
38 | }, | |
39 | }, { | |
40 | 'url': 'http://epv.elpais.com/epv/2017/02/14/programa_la_voz_de_inaki/1487062137_075943.html', | |
41 | 'info_dict': { | |
42 | 'id': '1487062137_075943', | |
43 | 'ext': 'mp4', | |
44 | 'title': 'Disyuntivas', | |
45 | 'description': 'md5:a0fb1485c4a6a8a917e6f93878e66218', | |
46 | 'upload_date': '20170214', | |
47 | }, | |
48 | 'params': { | |
49 | 'skip_download': True, | |
50 | }, | |
51 | }] | |
52 | ||
53 | def _real_extract(self, url): | |
54 | video_id = self._match_id(url) | |
55 | webpage = self._download_webpage(url, video_id) | |
56 | ||
57 | prefix = self._html_search_regex( | |
58 | r'var\s+url_cache\s*=\s*"([^"]+)";', webpage, 'URL prefix') | |
59 | id_multimedia = self._search_regex( | |
60 | r"id_multimedia\s*=\s*'([^']+)'", webpage, 'ID multimedia', default=None) | |
61 | if id_multimedia: | |
62 | url_info = self._download_json( | |
63 | 'http://elpais.com/vdpep/1/?pepid=' + id_multimedia, video_id, transform_source=strip_jsonp) | |
64 | video_suffix = url_info['mp4'] | |
65 | else: | |
66 | video_suffix = self._search_regex( | |
67 | r"(?:URLMediaFile|urlVideo_\d+)\s*=\s*url_cache\s*\+\s*'([^']+)'", webpage, 'video URL') | |
68 | video_url = prefix + video_suffix | |
69 | thumbnail_suffix = self._search_regex( | |
70 | r"(?:URLMediaStill|urlFotogramaFijo_\d+)\s*=\s*url_cache\s*\+\s*'([^']+)'", | |
71 | webpage, 'thumbnail URL', default=None) | |
72 | thumbnail = ( | |
73 | None if thumbnail_suffix is None | |
74 | else prefix + thumbnail_suffix) or self._og_search_thumbnail(webpage) | |
75 | title = self._html_search_regex( | |
76 | (r"tituloVideo\s*=\s*'([^']+)'", | |
77 | r'<h2 class="entry-header entry-title.*?>(.*?)</h2>', | |
78 | r'<h1[^>]+class="titulo"[^>]*>([^<]+)'), | |
79 | webpage, 'title', default=None) or self._og_search_title(webpage) | |
80 | upload_date = unified_strdate(self._search_regex( | |
81 | r'<p class="date-header date-int updated"\s+title="([^"]+)">', | |
82 | webpage, 'upload date', default=None) or self._html_search_meta( | |
83 | 'datePublished', webpage, 'timestamp')) | |
84 | ||
85 | return { | |
86 | 'id': video_id, | |
87 | 'url': video_url, | |
88 | 'title': title, | |
89 | 'description': self._og_search_description(webpage), | |
90 | 'thumbnail': thumbnail, | |
91 | 'upload_date': upload_date, | |
92 | } |