]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/ustudio.py
1 from .common
import InfoExtractor
9 class UstudioIE(InfoExtractor
):
11 _VALID_URL
= r
'https?://(?:(?:www|v1)\.)?ustudio\.com/video/(?P<id>[^/]+)/(?P<display_id>[^/?#&]+)'
13 'url': 'http://ustudio.com/video/Uxu2my9bgSph/san_francisco_golden_gate_bridge',
14 'md5': '58bbfca62125378742df01fc2abbdef6',
17 'display_id': 'san_francisco_golden_gate_bridge',
19 'title': 'San Francisco: Golden Gate Bridge',
20 'description': 'md5:23925500697f2c6d4830e387ba51a9be',
21 'thumbnail': r
're:^https?://.*\.jpg$',
22 'upload_date': '20111107',
23 'uploader': 'Tony Farley',
27 def _real_extract(self
, url
):
28 video_id
, display_id
= self
._match
_valid
_url
(url
).groups()
30 config
= self
._download
_xml
(
31 'http://v1.ustudio.com/embed/%s/ustudio/config.xml' % video_id
,
36 'url': unescapeHTML(item
.attrib
['url']),
37 'width': int_or_none(item
.get('width')),
38 'height': int_or_none(item
.get('height')),
39 } for item
in config
.findall('./qualities/quality/%s' % kind
) if item
.get('url')]
41 formats
= extract('video')
42 self
._sort
_formats
(formats
)
44 webpage
= self
._download
_webpage
(url
, display_id
)
46 title
= self
._og
_search
_title
(webpage
)
47 upload_date
= unified_strdate(self
._search
_regex
(
48 r
'(?s)Uploaded by\s*.+?\s*on\s*<span>([^<]+)</span>',
49 webpage
, 'upload date', fatal
=False))
50 uploader
= self
._search
_regex
(
51 r
'Uploaded by\s*<a[^>]*>([^<]+)<',
52 webpage
, 'uploader', fatal
=False)
56 'display_id': display_id
,
58 'description': self
._og
_search
_description
(webpage
),
59 'thumbnails': extract('image'),
60 'upload_date': upload_date
,
66 class UstudioEmbedIE(InfoExtractor
):
67 IE_NAME
= 'ustudio:embed'
68 _VALID_URL
= r
'https?://(?:(?:app|embed)\.)?ustudio\.com/embed/(?P<uid>[^/]+)/(?P<id>[^/]+)'
70 'url': 'http://app.ustudio.com/embed/DeN7VdYRDKhP/Uw7G1kMCe65T',
71 'md5': '47c0be52a09b23a7f40de9469cec58f4',
75 'title': '5 Things IT Should Know About Video',
76 'description': 'md5:93d32650884b500115e158c5677d25ad',
77 'uploader_id': 'DeN7VdYRDKhP',
81 def _real_extract(self
, url
):
82 uploader_id
, video_id
= self
._match
_valid
_url
(url
).groups()
83 video_data
= self
._download
_json
(
84 'http://app.ustudio.com/embed/%s/%s/config.json' % (uploader_id
, video_id
),
85 video_id
)['videos'][0]
86 title
= video_data
['name']
89 for ext
, qualities
in video_data
.get('transcodes', {}).items():
90 for quality
in qualities
:
91 quality_url
= quality
.get('url')
94 height
= int_or_none(quality
.get('height'))
96 'format_id': '%s-%dp' % (ext
, height
) if height
else ext
,
98 'width': int_or_none(quality
.get('width')),
101 self
._sort
_formats
(formats
)
104 for image
in video_data
.get('images', []):
105 image_url
= image
.get('url')
115 'description': video_data
.get('description'),
116 'duration': int_or_none(video_data
.get('duration')),
117 'uploader_id': uploader_id
,
118 'tags': video_data
.get('keywords'),
119 'thumbnails': thumbnails
,