[tele13] skip test
[youtube-dl] / youtube_dl / extractor / tele13.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 import re
5
6 from .common import InfoExtractor
7 from ..utils import js_to_json
8
9
10 class Tele13IE(InfoExtractor):
11     _VALID_URL = r'^http://(?:www\.)?t13\.cl/videos(?:/[^/]+)+/(?P<id>[\w-]+)'
12     _TESTS = [
13         {
14             'url': 'http://www.t13.cl/videos/actualidad/el-circulo-de-hierro-de-michelle-bachelet-en-su-regreso-a-la-moneda',
15             'md5': '4cb1fa38adcad8fea88487a078831755',
16             'info_dict': {
17                 'id': 'el-circulo-de-hierro-de-michelle-bachelet-en-su-regreso-a-la-moneda',
18                 'ext': 'mp4',
19                 'title': 'El cĂ­rculo de hierro de Michelle Bachelet en su regreso a La Moneda',
20             },
21             'params': {
22                 # HTTP Error 404: Not Found
23                 'skip_download': True,
24             },
25         },
26         {
27             'url': 'http://www.t13.cl/videos/mundo/tendencias/video-captan-misteriosa-bola-fuego-cielos-bangkok',
28             'md5': '65d1ae54812c96f4b345dd21d3bb1adc',
29             'info_dict': {
30                 'id': 'rOoKv2OMpOw',
31                 'ext': 'mp4',
32                 'title': 'Shooting star seen on 7-Sep-2015',
33                 'description': 'md5:a1cd2e74f6ee6851552c9cf5851d6b06',
34                 'uploader': 'Porjai Jaturongkhakun',
35                 'upload_date': '20150906',
36                 'uploader_id': 'UCnLY_3ezwNcDSC_Wc6suZxw',
37             },
38             'add_ie': ['Youtube'],
39         }
40     ]
41
42     def _real_extract(self, url):
43         display_id = self._match_id(url)
44
45         webpage = self._download_webpage(url, display_id)
46
47         setup_js = self._parse_json(
48             js_to_json(
49                 self._search_regex(
50                     r"jwplayer\('player-vivo'\).setup\((\{.*?\})\)",
51                     webpage,
52                     'setup code',
53                     flags=re.DOTALL
54                 ).replace('\n//', '')
55             ),
56             display_id
57         )
58         title = setup_js['title']
59         thumbnail = setup_js.get('image') or setup_js['playlist'][0].get('image')
60         description = self._html_search_meta(
61             'description', webpage, 'description')
62
63         formats = []
64         for f in setup_js['playlist'][0]['sources']:
65             format_url = f['file']
66             if format_url != '':
67                 if '.m3u8' in format_url:
68                     formats.extend(self._extract_m3u8_formats(format_url, display_id))
69                 else:
70                     if 'youtube.com' in format_url:
71                         return self.url_result(format_url, 'Youtube')
72                     else:
73                         formats.append({'url': format_url, 'format_id': f.get('label')})
74
75         return {
76             'id': display_id,
77             'title': title,
78             'description': description,
79             'thumbnail': thumbnail,
80             'formats': formats,
81         }