]>
Commit | Line | Data |
---|---|---|
2bd875ed S |
1 | from .common import InfoExtractor |
2 | from ..utils import ( | |
3 | unified_strdate, | |
4 | update_url_query, | |
5 | urlencode_postdata, | |
6 | ) | |
7 | ||
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 | ||
24 | def _real_extract(self, url): | |
25 | video_id = self._match_id(url) | |
26 | ||
27 | # Sets csrftoken cookie | |
28 | self._download_webpage(url, video_id) | |
29 | ||
30 | MEDICI_URL = 'http://www.medici.tv/' | |
31 | ||
32 | data = self._download_json( | |
33 | MEDICI_URL, video_id, | |
34 | data=urlencode_postdata({ | |
35 | 'json': 'true', | |
36 | 'page': '/%s' % video_id, | |
37 | 'timezone_offset': -420, | |
38 | }), headers={ | |
39 | 'X-CSRFToken': self._get_cookies(url)['csrftoken'].value, | |
40 | 'X-Requested-With': 'XMLHttpRequest', | |
41 | 'Referer': MEDICI_URL, | |
42 | 'Content-Type': 'application/x-www-form-urlencoded', | |
43 | }) | |
44 | ||
45 | video = data['video']['videos']['video1'] | |
46 | ||
47 | title = video.get('nom') or data['title'] | |
48 | ||
49 | video_id = video.get('id') or video_id | |
50 | formats = self._extract_f4m_formats( | |
51 | update_url_query(video['url_akamai'], { | |
52 | 'hdcore': '3.1.0', | |
53 | 'plugin=aasp': '3.1.0.43.124', | |
54 | }), video_id, f4m_id='hds') | |
55 | ||
56 | description = data.get('meta_description') | |
57 | thumbnail = video.get('url_thumbnail') or data.get('main_image') | |
58 | upload_date = unified_strdate(data['video'].get('date')) | |
59 | ||
60 | return { | |
61 | 'id': video_id, | |
62 | 'title': title, | |
63 | 'description': description, | |
64 | 'thumbnail': thumbnail, | |
65 | 'upload_date': upload_date, | |
66 | 'formats': formats, | |
67 | } |