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',
25 _APP_NAME_TO_VENDOR
= {
34 (?:https?://(?:www\.)?
47 ''' % ('|'.join(_HOST_TO_APPNAME
.keys()), '|'.join(_APP_NAME_TO_VENDOR
.keys()))
52 'url': 'http://www.vgtv.no/#!/video/84196/hevnen-er-soet-episode-10-abu',
53 'md5': 'b8be7a234cebb840c0d512c78013e02f',
57 'title': 'Hevnen er søt: Episode 10 - Abu',
58 'description': 'md5:e25e4badb5f544b04341e14abdc72234',
59 'thumbnail': 're:^https?://.*\.jpg',
61 'timestamp': 1404626400,
62 'upload_date': '20140706',
68 'url': 'http://www.vgtv.no/#!/live/100764/opptak-vgtv-foelger-em-kvalifiseringen',
72 'title': 'OPPTAK: VGTV følger EM-kvalifiseringen',
73 'description': 'md5:3772d9c0dc2dff92a886b60039a7d4d3',
74 'thumbnail': 're:^https?://.*\.jpg',
76 'timestamp': 1410113864,
77 'upload_date': '20140907',
82 'skip_download': True,
84 'skip': 'Video is no longer available',
88 'url': 'http://www.vgtv.no/#!/live/113063/direkte-v75-fra-solvalla',
89 'md5': '458f4841239dab414343b50e5af8869c',
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 'url': 'http://www.aftenposten.no/webtv/#!/video/21039/trailer-sweatshop-i-can-t-take-any-more',
104 'md5': 'fd828cd29774a729bf4d4425fe192972',
108 'title': 'TRAILER: «SWEATSHOP» - I can´t take any more',
109 'description': 'md5:21891f2b0dd7ec2f78d84a50e54f8238',
111 'timestamp': 1417002452,
112 'upload_date': '20141126',
117 'url': 'http://www.bt.no/tv/#!/video/100250/norling-dette-er-forskjellen-paa-1-divisjon-og-eliteserien',
118 'only_matching': True,
122 def _real_extract(self
, url
):
123 mobj
= re
.match(self
._VALID
_URL
, url
)
124 video_id
= mobj
.group('id')
125 host
= mobj
.group('host')
126 appname
= self
._HOST
_TO
_APPNAME
[host
] if host
else mobj
.group('appname')
127 vendor
= self
._APP
_NAME
_TO
_VENDOR
[appname
]
129 data
= self
._download
_json
(
130 'http://svp.vg.no/svp/api/v1/%s/assets/%s?appName=%s-website'
131 % (vendor
, video_id
, appname
),
132 video_id
, 'Downloading media JSON')
134 if data
.get('status') == 'inactive':
135 raise ExtractorError(
136 'Video %s is no longer available' % video_id
, expected
=True)
141 if len(video_id
) == 5:
142 if appname
== 'bttv':
143 info
= self
._extract
_video
_info
('btno', video_id
)
144 elif appname
== 'aptv':
145 info
= self
._extract
_video
_info
('ap', video_id
)
147 streams
= data
['streamUrls']
148 stream_type
= data
.get('streamType')
152 hls_url
= streams
.get('hls')
154 formats
.extend(self
._extract
_m
3u8_formats
(
155 hls_url
, video_id
, 'mp4', m3u8_id
='hls', fatal
=False))
157 hds_url
= streams
.get('hds')
159 hdcore_sign
= 'hdcore=3.7.0'
160 f4m_formats
= self
._extract
_f
4m
_formats
(
161 hds_url
+ '?%s' % hdcore_sign
, video_id
, f4m_id
='hds', fatal
=False)
163 for entry
in f4m_formats
:
164 # URLs without the extra param induce an 404 error
165 entry
.update({'extra_param_to_segment_url': hdcore_sign}
)
166 formats
.append(entry
)
168 mp4_urls
= streams
.get('pseudostreaming') or []
169 mp4_url
= streams
.get('mp4')
171 mp4_urls
.append(mp4_url
)
172 for mp4_url
in mp4_urls
:
176 mobj
= re
.search('(\d+)_(\d+)_(\d+)', mp4_url
)
178 tbr
= int(mobj
.group(3))
180 'width': int(mobj
.group(1)),
181 'height': int(mobj
.group(2)),
183 'format_id': 'mp4-%s' % tbr
,
185 formats
.append(format_info
)
187 info
['formats'].extend(formats
)
189 self
._sort
_formats
(info
['formats'])
193 'title': self
._live
_title
(data
['title']) if stream_type
== 'live' else data
['title'],
194 'description': data
['description'],
195 'thumbnail': data
['images']['main'] + '?t[]=900x506q80',
196 'timestamp': data
['published'],
197 'duration': float_or_none(data
['duration'], 1000),
198 'view_count': data
['displays'],
199 'is_live': True if stream_type
== 'live' else False,
204 class BTArticleIE(InfoExtractor
):
205 IE_NAME
= 'bt:article'
206 IE_DESC
= 'Bergens Tidende Articles'
207 _VALID_URL
= 'http://(?:www\.)?bt\.no/(?:[^/]+/)+(?P<id>[^/]+)-\d+\.html'
209 'url': 'http://www.bt.no/nyheter/lokalt/Kjemper-for-internatet-1788214.html',
210 'md5': '2acbe8ad129b3469d5ae51b1158878df',
214 'title': 'Alrekstad internat',
215 'description': 'md5:dc81a9056c874fedb62fc48a300dac58',
216 'thumbnail': 're:^https?://.*\.jpg',
218 'timestamp': 1289991323,
219 'upload_date': '20101117',
224 def _real_extract(self
, url
):
225 webpage
= self
._download
_webpage
(url
, self
._match
_id
(url
))
226 video_id
= self
._search
_regex
(
227 r
'<video[^>]+data-id="(\d+)"', webpage
, 'video id')
228 return self
.url_result('bttv:%s' % video_id
, 'VGTV')
231 class BTVestlendingenIE(InfoExtractor
):
232 IE_NAME
= 'bt:vestlendingen'
233 IE_DESC
= 'Bergens Tidende - Vestlendingen'
234 _VALID_URL
= 'http://(?:www\.)?bt\.no/spesial/vestlendingen/#!/(?P<id>\d+)'
236 'url': 'http://www.bt.no/spesial/vestlendingen/#!/86588',
237 'md5': 'd7d17e3337dc80de6d3a540aefbe441b',
241 'title': 'Otto Wollertsen',
242 'description': 'Vestlendingen Otto Fredrik Wollertsen',
243 'timestamp': 1430473209,
244 'upload_date': '20150501',
248 'url': 'http://www.bt.no/spesial/vestlendingen/#!/86255',
249 'md5': 'a2893f8632e96389f4bdf36aa9463ceb',
253 'title': 'Du må tåle å fryse og være sulten',
254 'description': 'md5:b8046f4d022d5830ddab04865791d063',
255 'upload_date': '20150321',
256 'timestamp': 1426942023,
260 def _real_extract(self
, url
):
261 return self
.url_result('bttv:%s' % self
._match
_id
(url
), 'VGTV')