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