]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/videopress.py
3c5e27a9dcfed9a71844c490180e91293492fa8f
3 from .common
import InfoExtractor
16 class VideoPressIE(InfoExtractor
):
17 _ID_REGEX
= r
'[\da-zA-Z]{8}'
18 _PATH_REGEX
= r
'video(?:\.word)?press\.com/embed/'
19 _VALID_URL
= r
'https?://%s(?P<id>%s)' % (_PATH_REGEX
, _ID_REGEX
)
21 'url': 'https://videopress.com/embed/kUJmAcSf',
22 'md5': '706956a6c875873d51010921310e4bc6',
26 'title': 'VideoPress Demo',
27 'thumbnail': r
're:^https?://.*\.jpg',
29 'timestamp': 1434983935,
30 'upload_date': '20150622',
34 # 17+, requires birth_* params
35 'url': 'https://videopress.com/embed/iH3gstfZ',
36 'only_matching': True,
38 'url': 'https://video.wordpress.com/embed/kUJmAcSf',
39 'only_matching': True,
43 def _extract_urls(webpage
):
45 r
'<iframe[^>]+src=["\']((?
:https?
://)?
%s%s)' % (VideoPressIE._PATH_REGEX, VideoPressIE._ID_REGEX),
48 def _real_extract(self, url):
49 video_id = self._match_id(url)
51 query = random_birthday('birth_year
', 'birth_month
', 'birth_day
')
52 query['fields
'] = 'description
,duration
,file_url_base
,files
,height
,original
,poster
,rating
,title
,upload_date
,width
'
53 video = self._download_json(
54 'https
://public
-api
.wordpress
.com
/rest
/v1
.1
/videos
/%s' % video_id,
55 video_id, query=query)
57 title = video['title
']
59 file_url_base = video.get('file_url_base
') or {}
60 base_url = file_url_base.get('https
') or file_url_base.get('http
')
62 QUALITIES = ('std
', 'dvd
', 'hd
')
63 quality = qualities(QUALITIES)
66 for format_id, f in (video.get('files
') or {}).items():
67 if not isinstance(f, dict):
69 for ext, path in f.items():
70 if ext in ('mp4
', 'ogg
'):
72 'url
': urljoin(base_url, path),
73 'format_id
': '%s-%s' % (format_id, ext),
74 'ext
': determine_ext(path, ext),
75 'quality
': quality(format_id),
77 original_url = video.get('original
')
81 'format_id
': 'original
',
82 'quality
': len(QUALITIES),
83 'width
': int_or_none(video.get('width
')),
84 'height
': int_or_none(video.get('height
')),
86 self._sort_formats(formats)
91 'description
': video.get('description
'),
92 'thumbnail
': video.get('poster
'),
93 'duration
': float_or_none(video.get('duration
'), 1000),
94 'timestamp
': unified_timestamp(video.get('upload_date
')),
95 'age_limit
': parse_age_limit(video.get('rating
')),