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.

70 lines
2.2 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. unified_strdate,
  6. update_url_query,
  7. urlencode_postdata,
  8. )
  9. class MediciIE(InfoExtractor):
  10. _VALID_URL = r'https?://(?:www\.)?medici\.tv/#!/(?P<id>[^?#&]+)'
  11. _TEST = {
  12. 'url': 'http://www.medici.tv/#!/daniel-harding-frans-helmerson-verbier-festival-music-camp',
  13. 'md5': '004c21bb0a57248085b6ff3fec72719d',
  14. 'info_dict': {
  15. 'id': '3059',
  16. 'ext': 'flv',
  17. 'title': 'Daniel Harding conducts the Verbier Festival Music Camp \u2013 With Frans Helmerson',
  18. 'description': 'md5:322a1e952bafb725174fd8c1a8212f58',
  19. 'thumbnail': r're:^https?://.*\.jpg$',
  20. 'upload_date': '20170408',
  21. },
  22. }
  23. def _real_extract(self, url):
  24. video_id = self._match_id(url)
  25. # Sets csrftoken cookie
  26. self._download_webpage(url, video_id)
  27. MEDICI_URL = 'http://www.medici.tv/'
  28. data = self._download_json(
  29. MEDICI_URL, video_id,
  30. data=urlencode_postdata({
  31. 'json': 'true',
  32. 'page': '/%s' % video_id,
  33. 'timezone_offset': -420,
  34. }), headers={
  35. 'X-CSRFToken': self._get_cookies(url)['csrftoken'].value,
  36. 'X-Requested-With': 'XMLHttpRequest',
  37. 'Referer': MEDICI_URL,
  38. 'Content-Type': 'application/x-www-form-urlencoded',
  39. })
  40. video = data['video']['videos']['video1']
  41. title = video.get('nom') or data['title']
  42. video_id = video.get('id') or video_id
  43. formats = self._extract_f4m_formats(
  44. update_url_query(video['url_akamai'], {
  45. 'hdcore': '3.1.0',
  46. 'plugin=aasp': '3.1.0.43.124',
  47. }), video_id, f4m_id='hds')
  48. description = data.get('meta_description')
  49. thumbnail = video.get('url_thumbnail') or data.get('main_image')
  50. upload_date = unified_strdate(data['video'].get('date'))
  51. return {
  52. 'id': video_id,
  53. 'title': title,
  54. 'description': description,
  55. 'thumbnail': thumbnail,
  56. 'upload_date': upload_date,
  57. 'formats': formats,
  58. }