]>
Commit | Line | Data |
---|---|---|
8b55cadc | 1 | # coding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
8b55cadc | 4 | from .common import InfoExtractor |
6882c087 | 5 | from .youtube import YoutubeIE |
6 | from ..utils import ( | |
7 | js_to_json, | |
8 | qualities, | |
9 | determine_ext, | |
10 | ) | |
8b55cadc | 11 | |
12 | ||
13 | class Tele13IE(InfoExtractor): | |
5886b38d | 14 | _VALID_URL = r'^https?://(?:www\.)?t13\.cl/videos(?:/[^/]+)+/(?P<id>[\w-]+)' |
8b55cadc | 15 | _TESTS = [ |
16 | { | |
17 | 'url': 'http://www.t13.cl/videos/actualidad/el-circulo-de-hierro-de-michelle-bachelet-en-su-regreso-a-la-moneda', | |
18 | 'md5': '4cb1fa38adcad8fea88487a078831755', | |
19 | 'info_dict': { | |
20 | 'id': 'el-circulo-de-hierro-de-michelle-bachelet-en-su-regreso-a-la-moneda', | |
21 | 'ext': 'mp4', | |
436416af | 22 | 'title': 'El círculo de hierro de Michelle Bachelet en su regreso a La Moneda', |
23 | }, | |
24 | 'params': { | |
25 | # HTTP Error 404: Not Found | |
26 | 'skip_download': True, | |
27 | }, | |
8b55cadc | 28 | }, |
29 | { | |
30 | 'url': 'http://www.t13.cl/videos/mundo/tendencias/video-captan-misteriosa-bola-fuego-cielos-bangkok', | |
6882c087 | 31 | 'md5': '867adf6a3b3fef932c68a71d70b70946', |
8b55cadc | 32 | 'info_dict': { |
33 | 'id': 'rOoKv2OMpOw', | |
34 | 'ext': 'mp4', | |
35 | 'title': 'Shooting star seen on 7-Sep-2015', | |
6882c087 | 36 | 'description': 'md5:7292ff2a34b2f673da77da222ae77e1e', |
8b55cadc | 37 | 'uploader': 'Porjai Jaturongkhakun', |
38 | 'upload_date': '20150906', | |
39 | 'uploader_id': 'UCnLY_3ezwNcDSC_Wc6suZxw', | |
40 | }, | |
41 | 'add_ie': ['Youtube'], | |
42 | } | |
43 | ] | |
44 | ||
45 | def _real_extract(self, url): | |
46 | display_id = self._match_id(url) | |
8b55cadc | 47 | webpage = self._download_webpage(url, display_id) |
48 | ||
98d7c0f4 | 49 | setup_js = self._search_regex( |
50 | r"(?s)jwplayer\('player-vivo'\).setup\((\{.*?\})\)", | |
51 | webpage, 'setup code') | |
52 | sources = self._parse_json(self._search_regex( | |
53 | r'sources\s*:\s*(\[[^\]]+\])', setup_js, 'sources'), | |
54 | display_id, js_to_json) | |
8b55cadc | 55 | |
6882c087 | 56 | preference = qualities(['Móvil', 'SD', 'HD']) |
8b55cadc | 57 | formats = [] |
6882c087 | 58 | urls = [] |
59 | for f in sources: | |
8b55cadc | 60 | format_url = f['file'] |
6882c087 | 61 | if format_url and format_url not in urls: |
62 | ext = determine_ext(format_url) | |
63 | if ext == 'm3u8': | |
98d7c0f4 | 64 | formats.extend(self._extract_m3u8_formats( |
65 | format_url, display_id, 'mp4', 'm3u8_native', | |
66 | m3u8_id='hls', fatal=False)) | |
6882c087 | 67 | elif YoutubeIE.suitable(format_url): |
68 | return self.url_result(format_url, 'Youtube') | |
8b55cadc | 69 | else: |
6882c087 | 70 | formats.append({ |
71 | 'url': format_url, | |
72 | 'format_id': f.get('label'), | |
73 | 'preference': preference(f.get('label')), | |
74 | 'ext': ext, | |
75 | }) | |
76 | urls.append(format_url) | |
77 | self._sort_formats(formats) | |
8b55cadc | 78 | |
79 | return { | |
80 | 'id': display_id, | |
98d7c0f4 | 81 | 'title': self._search_regex( |
82 | r'title\s*:\s*"([^"]+)"', setup_js, 'title'), | |
83 | 'description': self._html_search_meta( | |
84 | 'description', webpage, 'description'), | |
85 | 'thumbnail': self._search_regex( | |
86 | r'image\s*:\s*"([^"]+)"', setup_js, 'thumbnail', default=None), | |
8b55cadc | 87 | 'formats': formats, |
88 | } |