]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/vgtv.py
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
7 from .xstream
import XstreamIE
14 class VGTVIE(XstreamIE
):
15 IE_DESC
= 'VGTV, BTTV, FTV, Aftenposten and Aftonbladet'
20 'aftenbladet.no/tv': 'satv',
21 'fvn.no/fvntv': 'fvntv',
22 'aftenposten.no/webtv': 'aptv',
23 'ap.vgtv.no/webtv': 'aptv',
26 _APP_NAME_TO_VENDOR
= {
35 (?:https?://(?:www\.)?
48 ''' % ('|'.join(_HOST_TO_APPNAME
.keys()), '|'.join(_APP_NAME_TO_VENDOR
.keys()))
53 'url': 'http://www.vgtv.no/#!/video/84196/hevnen-er-soet-episode-10-abu',
54 'md5': 'b8be7a234cebb840c0d512c78013e02f',
58 'title': 'Hevnen er søt: Episode 10 - Abu',
59 'description': 'md5:e25e4badb5f544b04341e14abdc72234',
60 'thumbnail': 're:^https?://.*\.jpg',
62 'timestamp': 1404626400,
63 'upload_date': '20140706',
69 'url': 'http://www.vgtv.no/#!/live/100764/opptak-vgtv-foelger-em-kvalifiseringen',
73 'title': 'OPPTAK: VGTV følger EM-kvalifiseringen',
74 'description': 'md5:3772d9c0dc2dff92a886b60039a7d4d3',
75 'thumbnail': 're:^https?://.*\.jpg',
77 'timestamp': 1410113864,
78 'upload_date': '20140907',
83 'skip_download': True,
85 'skip': 'Video is no longer available',
89 'url': 'http://www.vgtv.no/#!/live/113063/direkte-v75-fra-solvalla',
93 'title': 'V75 fra Solvalla 30.05.15',
94 'description': 'md5:b3743425765355855f88e096acc93231',
95 'thumbnail': 're:^https?://.*\.jpg',
97 'timestamp': 1432975582,
98 'upload_date': '20150530',
103 'skip_download': True,
107 'url': 'http://www.aftenposten.no/webtv/#!/video/21039/trailer-sweatshop-i-can-t-take-any-more',
108 'md5': 'fd828cd29774a729bf4d4425fe192972',
112 'title': 'TRAILER: «SWEATSHOP» - I can´t take any more',
113 'description': 'md5:21891f2b0dd7ec2f78d84a50e54f8238',
115 'timestamp': 1417002452,
116 'upload_date': '20141126',
121 'skip_download': True,
125 'url': 'http://www.bt.no/tv/#!/video/100250/norling-dette-er-forskjellen-paa-1-divisjon-og-eliteserien',
126 'only_matching': True,
129 'url': 'http://ap.vgtv.no/webtv#!/video/111084/de-nye-bysyklene-lettere-bedre-gir-stoerre-hjul-og-feste-til-mobil',
130 'only_matching': True,
134 def _real_extract(self
, url
):
135 mobj
= re
.match(self
._VALID
_URL
, url
)
136 video_id
= mobj
.group('id')
137 host
= mobj
.group('host')
138 appname
= self
._HOST
_TO
_APPNAME
[host
] if host
else mobj
.group('appname')
139 vendor
= self
._APP
_NAME
_TO
_VENDOR
[appname
]
141 data
= self
._download
_json
(
142 'http://svp.vg.no/svp/api/v1/%s/assets/%s?appName=%s-website'
143 % (vendor
, video_id
, appname
),
144 video_id
, 'Downloading media JSON')
146 if data
.get('status') == 'inactive':
147 raise ExtractorError(
148 'Video %s is no longer available' % video_id
, expected
=True)
153 if len(video_id
) == 5:
154 if appname
== 'bttv':
155 info
= self
._extract
_video
_info
('btno', video_id
)
157 streams
= data
['streamUrls']
158 stream_type
= data
.get('streamType')
162 hls_url
= streams
.get('hls')
164 formats
.extend(self
._extract
_m
3u8_formats
(
165 hls_url
, video_id
, 'mp4', m3u8_id
='hls', fatal
=False))
167 hds_url
= streams
.get('hds')
169 hdcore_sign
= 'hdcore=3.7.0'
170 f4m_formats
= self
._extract
_f
4m
_formats
(
171 hds_url
+ '?%s' % hdcore_sign
, video_id
, f4m_id
='hds', fatal
=False)
173 for entry
in f4m_formats
:
174 # URLs without the extra param induce an 404 error
175 entry
.update({'extra_param_to_segment_url': hdcore_sign
})
176 formats
.append(entry
)
178 mp4_urls
= streams
.get('pseudostreaming') or []
179 mp4_url
= streams
.get('mp4')
181 mp4_urls
.append(mp4_url
)
182 for mp4_url
in mp4_urls
:
186 mobj
= re
.search('(\d+)_(\d+)_(\d+)', mp4_url
)
188 tbr
= int(mobj
.group(3))
190 'width': int(mobj
.group(1)),
191 'height': int(mobj
.group(2)),
193 'format_id': 'mp4-%s' % tbr
,
195 formats
.append(format_info
)
197 info
['formats'].extend(formats
)
199 self
._sort
_formats
(info
['formats'])
203 'title': self
._live
_title
(data
['title']) if stream_type
== 'live' else data
['title'],
204 'description': data
['description'],
205 'thumbnail': data
['images']['main'] + '?t[]=900x506q80',
206 'timestamp': data
['published'],
207 'duration': float_or_none(data
['duration'], 1000),
208 'view_count': data
['displays'],
209 'is_live': True if stream_type
== 'live' else False,
214 class BTArticleIE(InfoExtractor
):
215 IE_NAME
= 'bt:article'
216 IE_DESC
= 'Bergens Tidende Articles'
217 _VALID_URL
= r
'https?://(?:www\.)?bt\.no/(?:[^/]+/)+(?P<id>[^/]+)-\d+\.html'
219 'url': 'http://www.bt.no/nyheter/lokalt/Kjemper-for-internatet-1788214.html',
220 'md5': '2acbe8ad129b3469d5ae51b1158878df',
224 'title': 'Alrekstad internat',
225 'description': 'md5:dc81a9056c874fedb62fc48a300dac58',
226 'thumbnail': 're:^https?://.*\.jpg',
228 'timestamp': 1289991323,
229 'upload_date': '20101117',
234 def _real_extract(self
, url
):
235 webpage
= self
._download
_webpage
(url
, self
._match
_id
(url
))
236 video_id
= self
._search
_regex
(
237 r
'<video[^>]+data-id="(\d+)"', webpage
, 'video id')
238 return self
.url_result('bttv:%s' % video_id
, 'VGTV')
241 class BTVestlendingenIE(InfoExtractor
):
242 IE_NAME
= 'bt:vestlendingen'
243 IE_DESC
= 'Bergens Tidende - Vestlendingen'
244 _VALID_URL
= r
'https?://(?:www\.)?bt\.no/spesial/vestlendingen/#!/(?P<id>\d+)'
246 'url': 'http://www.bt.no/spesial/vestlendingen/#!/86588',
247 'md5': 'd7d17e3337dc80de6d3a540aefbe441b',
251 'title': 'Otto Wollertsen',
252 'description': 'Vestlendingen Otto Fredrik Wollertsen',
253 'timestamp': 1430473209,
254 'upload_date': '20150501',
258 'url': 'http://www.bt.no/spesial/vestlendingen/#!/86255',
259 'md5': 'a2893f8632e96389f4bdf36aa9463ceb',
263 'title': 'Du må tåle å fryse og være sulten',
264 'description': 'md5:b8046f4d022d5830ddab04865791d063',
265 'upload_date': '20150321',
266 'timestamp': 1426942023,
270 def _real_extract(self
, url
):
271 return self
.url_result('bttv:%s' % self
._match
_id
(url
), 'VGTV')