]> Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/biobiochiletv.py
Update changelog.
[youtubedl] / youtube_dl / extractor / biobiochiletv.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .common import InfoExtractor
5 from ..utils import remove_end
6
7
8 class BioBioChileTVIE(InfoExtractor):
9 _VALID_URL = r'https?://tv\.biobiochile\.cl/notas/(?:[^/]+/)+(?P<id>[^/]+)\.shtml'
10
11 _TESTS = [{
12 'url': 'http://tv.biobiochile.cl/notas/2015/10/21/sobre-camaras-y-camarillas-parlamentarias.shtml',
13 'md5': '26f51f03cf580265defefb4518faec09',
14 'info_dict': {
15 'id': 'sobre-camaras-y-camarillas-parlamentarias',
16 'ext': 'mp4',
17 'title': 'Sobre Cámaras y camarillas parlamentarias',
18 'thumbnail': 're:^https?://.*\.jpg$',
19 'uploader': 'Fernando Atria',
20 },
21 }, {
22 # different uploader layout
23 'url': 'http://tv.biobiochile.cl/notas/2016/03/18/natalia-valdebenito-repasa-a-diputado-hasbun-paso-a-la-categoria-de-hablar-brutalidades.shtml',
24 'md5': 'edc2e6b58974c46d5b047dea3c539ff3',
25 'info_dict': {
26 'id': 'natalia-valdebenito-repasa-a-diputado-hasbun-paso-a-la-categoria-de-hablar-brutalidades',
27 'ext': 'mp4',
28 'title': 'Natalia Valdebenito repasa a diputado Hasbún: Pasó a la categoría de hablar brutalidades',
29 'thumbnail': 're:^https?://.*\.jpg$',
30 'uploader': 'Piangella Obrador',
31 },
32 'params': {
33 'skip_download': True,
34 },
35 }, {
36 'url': 'http://tv.biobiochile.cl/notas/2015/10/22/ninos-transexuales-de-quien-es-la-decision.shtml',
37 'only_matching': True,
38 }, {
39 'url': 'http://tv.biobiochile.cl/notas/2015/10/21/exclusivo-hector-pinto-formador-de-chupete-revela-version-del-ex-delantero-albo.shtml',
40 'only_matching': True,
41 }]
42
43 def _real_extract(self, url):
44 video_id = self._match_id(url)
45
46 webpage = self._download_webpage(url, video_id)
47
48 title = remove_end(self._og_search_title(webpage), ' - BioBioChile TV')
49
50 file_url = self._search_regex(
51 r'loadFWPlayerVideo\([^,]+,\s*(["\'])(?P<url>.+?)\1',
52 webpage, 'file url', group='url')
53
54 base_url = self._search_regex(
55 r'file\s*:\s*(["\'])(?P<url>.+?)\1\s*\+\s*fileURL', webpage,
56 'base url', default='http://unlimited2-cl.digitalproserver.com/bbtv/',
57 group='url')
58
59 formats = self._extract_m3u8_formats(
60 '%s%s/playlist.m3u8' % (base_url, file_url), video_id, 'mp4',
61 entry_protocol='m3u8_native', m3u8_id='hls', fatal=False)
62 f = {
63 'url': '%s%s' % (base_url, file_url),
64 'format_id': 'http',
65 'protocol': 'http',
66 'preference': 1,
67 }
68 if formats:
69 f_copy = formats[-1].copy()
70 f_copy.update(f)
71 f = f_copy
72 formats.append(f)
73 self._sort_formats(formats)
74
75 thumbnail = self._og_search_thumbnail(webpage)
76 uploader = self._html_search_regex(
77 r'<a[^>]+href=["\']https?://busca\.biobiochile\.cl/author[^>]+>(.+?)</a>',
78 webpage, 'uploader', fatal=False)
79
80 return {
81 'id': video_id,
82 'title': title,
83 'thumbnail': thumbnail,
84 'uploader': uploader,
85 'formats': formats,
86 }