]>
Commit | Line | Data |
---|---|---|
06d07c40 | 1 | # coding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
4 | from .common import InfoExtractor | |
5 | from ..utils import ( | |
a01cfc29 | 6 | float_or_none, |
06d07c40 | 7 | int_or_none, |
8 | parse_iso8601, | |
a01cfc29 | 9 | xpath_text, |
06d07c40 | 10 | ) |
11 | ||
a01cfc29 | 12 | |
06d07c40 | 13 | class PhilharmonieDeParisIE(InfoExtractor): |
a01cfc29 | 14 | IE_DESC = 'Philharmonie de Paris' |
5886b38d | 15 | _VALID_URL = r'https?://live\.philharmoniedeparis\.fr/(?:[Cc]oncert/|misc/Playlist\.ashx\?id=)(?P<id>\d+)' |
06d07c40 | 16 | _TESTS = [{ |
17 | 'url': 'http://live.philharmoniedeparis.fr/concert/1032066.html', | |
18 | 'info_dict': { | |
19 | 'id': '1032066', | |
a01cfc29 S |
20 | 'ext': 'flv', |
21 | 'title': 'md5:d1f5585d87d041d07ce9434804bc8425', | |
22 | 'timestamp': 1428179400, | |
06d07c40 | 23 | 'upload_date': '20150404', |
a01cfc29 S |
24 | 'duration': 6592.278, |
25 | }, | |
26 | 'params': { | |
27 | # rtmp download | |
28 | 'skip_download': True, | |
06d07c40 | 29 | } |
a01cfc29 S |
30 | }, { |
31 | 'url': 'http://live.philharmoniedeparis.fr/Concert/1030324.html', | |
32 | 'only_matching': True, | |
33 | }, { | |
34 | 'url': 'http://live.philharmoniedeparis.fr/misc/Playlist.ashx?id=1030324&track=&lang=fr', | |
35 | 'only_matching': True, | |
06d07c40 | 36 | }] |
37 | ||
38 | def _real_extract(self, url): | |
39 | video_id = self._match_id(url) | |
40 | ||
a01cfc29 S |
41 | concert = self._download_xml( |
42 | 'http://live.philharmoniedeparis.fr/misc/Playlist.ashx?id=%s' % video_id, | |
43 | video_id).find('./concert') | |
06d07c40 | 44 | |
45 | formats = [] | |
46 | info_dict = { | |
47 | 'id': video_id, | |
a01cfc29 | 48 | 'title': xpath_text(concert, './titre', 'title', fatal=True), |
06d07c40 | 49 | 'formats': formats, |
50 | } | |
51 | ||
06d07c40 | 52 | fichiers = concert.find('./fichiers') |
a01cfc29 | 53 | stream = fichiers.attrib['serveurstream'] |
06d07c40 | 54 | for fichier in fichiers.findall('./fichier'): |
a01cfc29 S |
55 | info_dict['duration'] = float_or_none(fichier.get('timecodefin')) |
56 | for quality, (format_id, suffix) in enumerate([('lq', ''), ('hq', '_hd')]): | |
57 | format_url = fichier.get('url%s' % suffix) | |
58 | if not format_url: | |
59 | continue | |
60 | formats.append({ | |
61 | 'url': stream, | |
62 | 'play_path': format_url, | |
63 | 'ext': 'flv', | |
64 | 'format_id': format_id, | |
65 | 'width': int_or_none(concert.get('largeur%s' % suffix)), | |
66 | 'height': int_or_none(concert.get('hauteur%s' % suffix)), | |
67 | 'quality': quality, | |
68 | }) | |
69 | self._sort_formats(formats) | |
06d07c40 | 70 | |
a01cfc29 S |
71 | date, hour = concert.get('date'), concert.get('heure') |
72 | if date and hour: | |
73 | info_dict['timestamp'] = parse_iso8601( | |
74 | '%s-%s-%sT%s:00' % (date[0:4], date[4:6], date[6:8], hour)) | |
75 | elif date: | |
76 | info_dict['upload_date'] = date | |
06d07c40 | 77 | |
78 | return info_dict |