]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/vgtv.py
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
13 class VGTVIE(InfoExtractor
):
14 IE_DESC
= 'VGTV and BTTV'
23 \.no/(?:tv/)?\#!/(?:video|live)/
30 'url': 'http://www.vgtv.no/#!/video/84196/hevnen-er-soet-episode-10-abu',
31 'md5': 'b8be7a234cebb840c0d512c78013e02f',
35 'title': 'Hevnen er søt: Episode 10 - Abu',
36 'description': 'md5:e25e4badb5f544b04341e14abdc72234',
37 'thumbnail': 're:^https?://.*\.jpg',
39 'timestamp': 1404626400,
40 'upload_date': '20140706',
46 'url': 'http://www.vgtv.no/#!/live/100764/opptak-vgtv-foelger-em-kvalifiseringen',
50 'title': 'OPPTAK: VGTV følger EM-kvalifiseringen',
51 'description': 'md5:3772d9c0dc2dff92a886b60039a7d4d3',
52 'thumbnail': 're:^https?://.*\.jpg',
54 'timestamp': 1410113864,
55 'upload_date': '20140907',
60 'skip_download': True,
65 'url': 'http://www.vgtv.no/#!/live/113063/direkte-v75-fra-solvalla',
69 'title': 're:^DIREKTE: V75 fra Solvalla [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$',
70 'description': 'md5:b3743425765355855f88e096acc93231',
71 'thumbnail': 're:^https?://.*\.jpg',
73 'timestamp': 1432975582,
74 'upload_date': '20150530',
79 'skip_download': True,
83 'url': 'http://www.bt.no/tv/#!/video/100250/norling-dette-er-forskjellen-paa-1-divisjon-og-eliteserien',
84 'only_matching': True,
88 def _real_extract(self
, url
):
89 mobj
= re
.match(self
._VALID
_URL
, url
)
90 video_id
= mobj
.group('id')
91 host
= mobj
.group('host')
98 data
= self
._download
_json
(
99 'http://svp.vg.no/svp/api/v1/%s/assets/%s?appName=%s-website'
100 % (host
, video_id
, HOST_WEBSITES
[host
]),
101 video_id
, 'Downloading media JSON')
103 if data
.get('status') == 'inactive':
104 raise ExtractorError(
105 'Video %s is no longer available' % video_id
, expected
=True)
107 streams
= data
['streamUrls']
108 stream_type
= data
.get('streamType')
112 hls_url
= streams
.get('hls')
114 formats
.extend(self
._extract
_m
3u8_formats
(
115 hls_url
, video_id
, 'mp4', m3u8_id
='hls'))
117 hds_url
= streams
.get('hds')
118 # wasLive hds are always 404
119 if hds_url
and stream_type
!= 'wasLive':
120 formats
.extend(self
._extract
_f
4m
_formats
(
121 hds_url
+ '?hdcore=3.2.0&plugin=aasp-3.2.0.77.18',
122 video_id
, f4m_id
='hds'))
124 mp4_url
= streams
.get('mp4')
126 _url
= hls_url
or hds_url
127 MP4_URL_TEMPLATE
= '%s/%%s.%s' % (mp4_url
.rpartition('/')[0], mp4_url
.rpartition('.')[-1])
128 for mp4_format
in _url
.split(','):
129 m
= re
.search('(?P<width>\d+)_(?P<height>\d+)_(?P<vbr>\d+)', mp4_format
)
132 width
= int(m
.group('width'))
133 height
= int(m
.group('height'))
134 vbr
= int(m
.group('vbr'))
136 'url': MP4_URL_TEMPLATE
% mp4_format
,
137 'format_id': 'mp4-%s' % vbr
,
143 self
._sort
_formats
(formats
)
147 'title': self
._live
_title
(data
['title']),
148 'description': data
['description'],
149 'thumbnail': data
['images']['main'] + '?t[]=900x506q80',
150 'timestamp': data
['published'],
151 'duration': float_or_none(data
['duration'], 1000),
152 'view_count': data
['displays'],
154 'is_live': True if stream_type
== 'live' else False,
158 class BTArticleIE(InfoExtractor
):
159 IE_NAME
= 'bt:article'
160 IE_DESC
= 'Bergens Tidende Articles'
161 _VALID_URL
= 'http://(?:www\.)?bt\.no/(?:[^/]+/)+(?P<id>[^/]+)-\d+\.html'
163 'url': 'http://www.bt.no/nyheter/lokalt/Kjemper-for-internatet-1788214.html',
164 'md5': 'd055e8ee918ef2844745fcfd1a4175fb',
168 'title': 'Alrekstad internat',
169 'description': 'md5:dc81a9056c874fedb62fc48a300dac58',
170 'thumbnail': 're:^https?://.*\.jpg',
172 'timestamp': 1289991323,
173 'upload_date': '20101117',
178 def _real_extract(self
, url
):
179 webpage
= self
._download
_webpage
(url
, self
._match
_id
(url
))
180 video_id
= self
._search
_regex
(
181 r
'SVP\.Player\.load\(\s*(\d+)', webpage
, 'video id')
182 return self
.url_result('vgtv:bt:%s' % video_id
, 'VGTV')
185 class BTVestlendingenIE(InfoExtractor
):
186 IE_NAME
= 'bt:vestlendingen'
187 IE_DESC
= 'Bergens Tidende - Vestlendingen'
188 _VALID_URL
= 'http://(?:www\.)?bt\.no/spesial/vestlendingen/#!/(?P<id>\d+)'
190 'url': 'http://www.bt.no/spesial/vestlendingen/#!/86588',
191 'md5': 'd7d17e3337dc80de6d3a540aefbe441b',
195 'title': 'Otto Wollertsen',
196 'description': 'Vestlendingen Otto Fredrik Wollertsen',
197 'timestamp': 1430473209,
198 'upload_date': '20150501',
202 def _real_extract(self
, url
):
203 return self
.url_result('xstream:btno:%s' % self
._match
_id
(url
), 'Xstream')