]>
Commit | Line | Data |
---|---|---|
911344e5 | 1 | from .common import InfoExtractor |
ed6fb8b8 | 2 | from ..utils import ( |
82e91d20 | 3 | extract_attributes, |
ed6fb8b8 | 4 | float_or_none, |
82e91d20 RA |
5 | get_element_by_class, |
6 | strip_or_none, | |
7 | unified_timestamp, | |
ed6fb8b8 | 8 | ) |
911344e5 S |
9 | |
10 | ||
11 | class VRTIE(InfoExtractor): | |
82e91d20 RA |
12 | IE_DESC = 'VRT NWS, Flanders News, Flandern Info and Sporza' |
13 | _VALID_URL = r'https?://(?:www\.)?(?P<site>vrt\.be/vrtnws|sporza\.be)/[a-z]{2}/\d{4}/\d{2}/\d{2}/(?P<id>[^/?&#]+)' | |
14 | _TESTS = [{ | |
15 | 'url': 'https://www.vrt.be/vrtnws/nl/2019/05/15/beelden-van-binnenkant-notre-dame-een-maand-na-de-brand/', | |
16 | 'md5': 'e1663accf5cf13f375f3cd0d10476669', | |
17 | 'info_dict': { | |
18 | 'id': 'pbs-pub-7855fc7b-1448-49bc-b073-316cb60caa71$vid-2ca50305-c38a-4762-9890-65cbd098b7bd', | |
19 | 'ext': 'mp4', | |
20 | 'title': 'Beelden van binnenkant Notre-Dame, één maand na de brand', | |
21 | 'description': 'Op maandagavond 15 april ging een deel van het dakgebinte van de Parijse kathedraal in vlammen op.', | |
22 | 'timestamp': 1557924660, | |
23 | 'upload_date': '20190515', | |
24 | 'duration': 31.2, | |
911344e5 | 25 | }, |
82e91d20 RA |
26 | }, { |
27 | 'url': 'https://sporza.be/nl/2019/05/15/de-belgian-cats-zijn-klaar-voor-het-ek/', | |
28 | 'md5': '910bba927566e9ab992278f647eb4b75', | |
29 | 'info_dict': { | |
30 | 'id': 'pbs-pub-f2c86a46-8138-413a-a4b9-a0015a16ce2c$vid-1f112b31-e58e-4379-908d-aca6d80f8818', | |
31 | 'ext': 'mp4', | |
32 | 'title': 'De Belgian Cats zijn klaar voor het EK mét Ann Wauters', | |
33 | 'timestamp': 1557923760, | |
34 | 'upload_date': '20190515', | |
35 | 'duration': 115.17, | |
911344e5 | 36 | }, |
82e91d20 RA |
37 | }, { |
38 | 'url': 'https://www.vrt.be/vrtnws/en/2019/05/15/belgium_s-eurovision-entry-falls-at-the-first-hurdle/', | |
39 | 'only_matching': True, | |
40 | }, { | |
41 | 'url': 'https://www.vrt.be/vrtnws/de/2019/05/15/aus-fuer-eliott-im-halbfinale-des-eurosongfestivals/', | |
42 | 'only_matching': True, | |
43 | }] | |
44 | _CLIENT_MAP = { | |
45 | 'vrt.be/vrtnws': 'vrtnieuws', | |
46 | 'sporza.be': 'sporza', | |
47 | } | |
911344e5 S |
48 | |
49 | def _real_extract(self, url): | |
5ad28e7f | 50 | site, display_id = self._match_valid_url(url).groups() |
82e91d20 RA |
51 | webpage = self._download_webpage(url, display_id) |
52 | attrs = extract_attributes(self._search_regex( | |
3829f90a | 53 | r'(<[^>]+class="vrtvideo( [^"]*)?"[^>]*>)', webpage, 'vrt video')) |
82e91d20 | 54 | |
4de30076 JT |
55 | asset_id = attrs['data-video-id'] |
56 | publication_id = attrs.get('data-publication-id') | |
82e91d20 RA |
57 | if publication_id: |
58 | asset_id = publication_id + '$' + asset_id | |
4de30076 | 59 | client = attrs.get('data-client-code') or self._CLIENT_MAP[site] |
82e91d20 RA |
60 | |
61 | title = strip_or_none(get_element_by_class( | |
62 | 'vrt-title', webpage) or self._html_search_meta( | |
63 | ['og:title', 'twitter:title', 'name'], webpage)) | |
64 | description = self._html_search_meta( | |
65 | ['og:description', 'twitter:description', 'description'], webpage) | |
66 | if description == '…': | |
67 | description = None | |
68 | timestamp = unified_timestamp(self._html_search_meta( | |
69 | 'article:published_time', webpage)) | |
911344e5 S |
70 | |
71 | return { | |
82e91d20 RA |
72 | '_type': 'url_transparent', |
73 | 'id': asset_id, | |
74 | 'display_id': display_id, | |
911344e5 S |
75 | 'title': title, |
76 | 'description': description, | |
82e91d20 | 77 | 'thumbnail': attrs.get('data-posterimage'), |
911344e5 | 78 | 'timestamp': timestamp, |
82e91d20 RA |
79 | 'duration': float_or_none(attrs.get('data-duration'), 1000), |
80 | 'url': 'https://mediazone.vrt.be/api/v1/%s/assets/%s' % (client, asset_id), | |
81 | 'ie_key': 'Canvas', | |
5f6a1245 | 82 | } |