]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/npo.py
ce31694a506a99d1ae21460f0c458ef3100c1850
1 from __future__
import unicode_literals
5 from .common
import InfoExtractor
15 class NPOIE(InfoExtractor
):
17 _VALID_URL
= r
'https?://www\.npo\.nl/[^/]+/[^/]+/(?P<id>[^/?]+)'
21 'url': 'http://www.npo.nl/nieuwsuur/22-06-2014/VPWON_1220719',
22 'md5': '4b3f9c429157ec4775f2c9cb7b911016',
24 'id': 'VPWON_1220719',
27 'description': 'Dagelijks tussen tien en elf: nieuws, sport en achtergronden.',
28 'upload_date': '20140622',
32 'url': 'http://www.npo.nl/de-mega-mike-mega-thomas-show/27-02-2009/VARA_101191800',
33 'md5': 'da50a5787dbfc1603c4ad80f31c5120b',
35 'id': 'VARA_101191800',
37 'title': 'De Mega Mike & Mega Thomas show',
38 'description': 'md5:3b74c97fc9d6901d5a665aac0e5400f4',
39 'upload_date': '20090227',
44 'url': 'http://www.npo.nl/tegenlicht/25-02-2013/VPWON_1169289',
45 'md5': 'f8065e4e5a7824068ed3c7e783178f2c',
47 'id': 'VPWON_1169289',
49 'title': 'Tegenlicht',
50 'description': 'md5:d6476bceb17a8c103c76c3b708f05dd1',
51 'upload_date': '20130225',
57 def _real_extract(self
, url
):
58 mobj
= re
.match(self
._VALID
_URL
, url
)
59 video_id
= mobj
.group('id')
60 return self
._get
_info
(video_id
)
62 def _get_info(self
, video_id
):
63 metadata
= self
._download
_json
(
64 'http://e.omroep.nl/metadata/aflevering/%s' % video_id
,
66 # We have to remove the javascript callback
67 transform_source
=strip_jsonp
,
69 token_page
= self
._download
_webpage
(
70 'http://ida.omroep.nl/npoplayer/i.js',
72 note
='Downloading token'
74 token
= self
._search
_regex
(r
'npoplayer\.token = "(.+?)"', token_page
, 'token')
77 quality
= qualities(['adaptive', 'wmv_sb', 'h264_sb', 'wmv_bb', 'h264_bb', 'wvc1_std', 'h264_std'])
78 for format_id
in metadata
['pubopties']:
79 format_info
= self
._download
_json
(
80 'http://ida.omroep.nl/odi/?prid=%s&puboptions=%s&adaptive=yes&token=%s' % (video_id
, format_id
, token
),
81 video_id
, 'Downloading %s JSON' % format_id
)
82 if format_info
.get('error_code', 0) or format_info
.get('errorcode', 0):
84 streams
= format_info
.get('streams')
86 video_info
= self
._download
_json
(
87 streams
[0] + '&type=json',
88 video_id
, 'Downloading %s stream JSON' % format_id
)
90 video_info
= format_info
91 video_url
= video_info
.get('url')
94 if format_id
== 'adaptive':
95 formats
.extend(self
._extract
_m
3u8_formats
(video_url
, video_id
))
99 'format_id': format_id
,
100 'quality': quality(format_id
),
102 self
._sort
_formats
(formats
)
106 'title': metadata
['titel'],
107 'description': metadata
['info'],
108 'thumbnail': metadata
.get('images', [{'url': None}])[-1]['url'],
109 'upload_date': unified_strdate(metadata
.get('gidsdatum')),
110 'duration': parse_duration(metadata
.get('tijdsduur')),
115 class TegenlichtVproIE(NPOIE
):
116 IE_NAME
= 'tegenlicht.vpro.nl'
117 _VALID_URL
= r
'https?://tegenlicht\.vpro\.nl/afleveringen/.*?'
121 'url': 'http://tegenlicht.vpro.nl/afleveringen/2012-2013/de-toekomst-komt-uit-afrika.html',
122 'md5': 'f8065e4e5a7824068ed3c7e783178f2c',
124 'id': 'VPWON_1169289',
126 'title': 'Tegenlicht',
127 'description': 'md5:d6476bceb17a8c103c76c3b708f05dd1',
128 'upload_date': '20130225',
133 def _real_extract(self
, url
):
134 name
= url_basename(url
)
135 webpage
= self
._download
_webpage
(url
, name
)
136 urn
= self
._html
_search
_meta
('mediaurn', webpage
)
137 info_page
= self
._download
_json
(
138 'http://rs.vpro.nl/v2/api/media/%s.json' % urn
, name
)
139 return self
._get
_info
(info_page
['mid'])