]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/videopress.py
2 from __future__
import unicode_literals
7 from .common
import InfoExtractor
8 from ..compat
import compat_str
20 class VideoPressIE(InfoExtractor
):
21 _VALID_URL
= r
'https?://videopress\.com/embed/(?P<id>[\da-zA-Z]+)'
23 'url': 'https://videopress.com/embed/kUJmAcSf',
24 'md5': '706956a6c875873d51010921310e4bc6',
28 'title': 'VideoPress Demo',
29 'thumbnail': r
're:^https?://.*\.jpg',
31 'timestamp': 1434983935,
32 'upload_date': '20150622',
36 # 17+, requires birth_* params
37 'url': 'https://videopress.com/embed/iH3gstfZ',
38 'only_matching': True,
42 def _extract_urls(webpage
):
44 r
'<iframe[^>]+src=["\']((?
:https?
://)?videopress\
.com
/embed
/[\da
-zA
-Z
]+)',
47 def _real_extract(self, url):
48 video_id = self._match_id(url)
50 video = self._download_json(
51 'https
://public
-api
.wordpress
.com
/rest
/v1
.1
/videos
/%s' % video_id,
53 'birth_month
': random.randint(1, 12),
54 'birth_day
': random.randint(1, 31),
55 'birth_year
': random.randint(1950, 1995),
58 title = video['title
']
62 video, lambda x: x['file_url_base
'][scheme], compat_str)
64 base_url = base_url('https
') or base_url('http
')
66 QUALITIES = ('std
', 'dvd
', 'hd
')
67 quality = qualities(QUALITIES)
70 for format_id, f in video['files
'].items():
71 if not isinstance(f, dict):
73 for ext, path in f.items():
74 if ext in ('mp4
', 'ogg
'):
76 'url
': urljoin(base_url, path),
77 'format_id
': '%s-%s' % (format_id, ext),
78 'ext
': determine_ext(path, ext),
79 'quality
': quality(format_id),
81 original_url = try_get(video, lambda x: x['original
'], compat_str)
85 'format_id
': 'original
',
86 'quality
': len(QUALITIES),
88 self._sort_formats(formats)
93 'description
': video.get('description
'),
94 'thumbnail
': video.get('poster
'),
95 'duration
': float_or_none(video.get('duration
'), 1000),
96 'timestamp
': unified_timestamp(video.get('upload_date
')),
97 'age_limit
': parse_age_limit(video.get('rating
')),