]>
jfr.im git - yt-dlp.git/blob - youtube_dlc/extractor/videopress.py
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
7 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 query = random_birthday('birth_year
', 'birth_month
', 'birth_day
')
51 video = self._download_json(
52 'https
://public
-api
.wordpress
.com
/rest
/v1
.1
/videos
/%s' % video_id,
53 video_id, query=query)
55 title = video['title
']
59 video, lambda x: x['file_url_base
'][scheme], compat_str)
61 base_url = base_url('https
') or base_url('http
')
63 QUALITIES = ('std
', 'dvd
', 'hd
')
64 quality = qualities(QUALITIES)
67 for format_id, f in video['files
'].items():
68 if not isinstance(f, dict):
70 for ext, path in f.items():
71 if ext in ('mp4
', 'ogg
'):
73 'url
': urljoin(base_url, path),
74 'format_id
': '%s-%s' % (format_id, ext),
75 'ext
': determine_ext(path, ext),
76 'quality
': quality(format_id),
78 original_url = try_get(video, lambda x: x['original
'], compat_str)
82 'format_id
': 'original
',
83 'quality
': len(QUALITIES),
85 self._sort_formats(formats)
90 'description
': video.get('description
'),
91 'thumbnail
': video.get('poster
'),
92 'duration
': float_or_none(video.get('duration
'), 1000),
93 'timestamp
': unified_timestamp(video.get('upload_date
')),
94 'age_limit
': parse_age_limit(video.get('rating
')),