[ign] improve extraction and extract uploader_id
[youtube-dl] / youtube_dl / extractor / canal13cl.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 import re
5
6 from .common import InfoExtractor
7
8
9 class Canal13clIE(InfoExtractor):
10     _VALID_URL = r'^http://(?:www\.)?13\.cl/(?:[^/?#]+/)*(?P<id>[^/?#]+)'
11     _TEST = {
12         'url': 'http://www.13.cl/t13/nacional/el-circulo-de-hierro-de-michelle-bachelet-en-su-regreso-a-la-moneda',
13         'md5': '4cb1fa38adcad8fea88487a078831755',
14         'info_dict': {
15             'id': '1403022125',
16             'display_id': 'el-circulo-de-hierro-de-michelle-bachelet-en-su-regreso-a-la-moneda',
17             'ext': 'mp4',
18             'title': 'El "círculo de hierro" de Michelle Bachelet en su regreso a La Moneda',
19             'description': '(Foto: Agencia Uno) En nueve días más, Michelle Bachelet va a asumir por segunda vez como presidenta de la República. Entre aquellos que la acompañarán hay caras que se repiten y otras que se consolidan en su entorno de colaboradores más cercanos.',
20         }
21     }
22
23     def _real_extract(self, url):
24         mobj = re.match(self._VALID_URL, url)
25         display_id = mobj.group('id')
26
27         webpage = self._download_webpage(url, display_id)
28
29         title = self._html_search_meta(
30             'twitter:title', webpage, 'title', fatal=True)
31         description = self._html_search_meta(
32             'twitter:description', webpage, 'description')
33         url = self._html_search_regex(
34             r'articuloVideo = \"(.*?)\"', webpage, 'url')
35         real_id = self._search_regex(
36             r'[^0-9]([0-9]{7,})[^0-9]', url, 'id', default=display_id)
37         thumbnail = self._html_search_regex(
38             r'articuloImagen = \"(.*?)\"', webpage, 'thumbnail')
39
40         return {
41             'id': real_id,
42             'display_id': display_id,
43             'url': url,
44             'title': title,
45             'description': description,
46             'ext': 'mp4',
47             'thumbnail': thumbnail,
48         }