1 from .common
import InfoExtractor
14 class VideoPressIE(InfoExtractor
):
15 _ID_REGEX
= r
'[\da-zA-Z]{8}'
16 _PATH_REGEX
= r
'video(?:\.word)?press\.com/embed/'
17 _VALID_URL
= rf
'https?://{_PATH_REGEX}(?P<id>{_ID_REGEX})'
18 _EMBED_REGEX
= [rf
'<iframe[^>]+src=["\'](?P<url>(?:https?://)?{_PATH_REGEX}{_ID_REGEX})']
20 'url': 'https://videopress.com/embed/kUJmAcSf',
21 'md5': '706956a6c875873d51010921310e4bc6',
25 'title': 'VideoPress Demo',
26 'thumbnail': r
're:^https?://.*\.jpg',
28 'timestamp': 1434983935,
29 'upload_date': '20150622',
33 # 17+, requires birth_* params
34 'url': 'https://videopress.com/embed/iH3gstfZ',
35 'only_matching': True,
37 'url': 'https://video.wordpress.com/embed/kUJmAcSf',
38 'only_matching': True,
41 def _real_extract(self
, url
):
42 video_id
= self
._match
_id
(url
)
44 query
= random_birthday('birth_year', 'birth_month', 'birth_day')
45 query
['fields'] = 'description,duration,file_url_base,files,height,original,poster,rating,title,upload_date,width'
46 video
= self
._download
_json
(
47 f
'https://public-api.wordpress.com/rest/v1.1/videos/{video_id}',
48 video_id
, query
=query
)
50 title
= video
['title']
52 file_url_base
= video
.get('file_url_base') or {}
53 base_url
= file_url_base
.get('https') or file_url_base
.get('http')
55 QUALITIES
= ('std', 'dvd', 'hd')
56 quality
= qualities(QUALITIES
)
59 for format_id
, f
in (video
.get('files') or {}).items():
60 if not isinstance(f
, dict):
62 for ext
, path
in f
.items():
63 if ext
in ('mp4', 'ogg'):
65 'url': urljoin(base_url
, path
),
66 'format_id': f
'{format_id}-{ext}',
67 'ext': determine_ext(path
, ext
),
68 'quality': quality(format_id
),
70 original_url
= video
.get('original')
74 'format_id': 'original',
75 'quality': len(QUALITIES
),
76 'width': int_or_none(video
.get('width')),
77 'height': int_or_none(video
.get('height')),
83 'description': video
.get('description'),
84 'thumbnail': video
.get('poster'),
85 'duration': float_or_none(video
.get('duration'), 1000),
86 'timestamp': unified_timestamp(video
.get('upload_date')),
87 'age_limit': parse_age_limit(video
.get('rating')),