You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
2.6 KiB

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