]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/ustudio.py
1 from __future__
import unicode_literals
4 from .common
import InfoExtractor
12 class UstudioIE(InfoExtractor
):
14 _VALID_URL
= r
'https?://(?:(?:www|v1)\.)?ustudio\.com/video/(?P<id>[^/]+)/(?P<display_id>[^/?#&]+)'
16 'url': 'http://ustudio.com/video/Uxu2my9bgSph/san_francisco_golden_gate_bridge',
17 'md5': '58bbfca62125378742df01fc2abbdef6',
20 'display_id': 'san_francisco_golden_gate_bridge',
22 'title': 'San Francisco: Golden Gate Bridge',
23 'description': 'md5:23925500697f2c6d4830e387ba51a9be',
24 'thumbnail': r
're:^https?://.*\.jpg$',
25 'upload_date': '20111107',
26 'uploader': 'Tony Farley',
30 def _real_extract(self
, url
):
31 video_id
, display_id
= self
._match
_valid
_url
(url
).groups()
33 config
= self
._download
_xml
(
34 'http://v1.ustudio.com/embed/%s/ustudio/config.xml' % video_id
,
39 'url': unescapeHTML(item
.attrib
['url']),
40 'width': int_or_none(item
.get('width')),
41 'height': int_or_none(item
.get('height')),
42 } for item
in config
.findall('./qualities/quality/%s' % kind
) if item
.get('url')]
44 formats
= extract('video')
45 self
._sort
_formats
(formats
)
47 webpage
= self
._download
_webpage
(url
, display_id
)
49 title
= self
._og
_search
_title
(webpage
)
50 upload_date
= unified_strdate(self
._search
_regex
(
51 r
'(?s)Uploaded by\s*.+?\s*on\s*<span>([^<]+)</span>',
52 webpage
, 'upload date', fatal
=False))
53 uploader
= self
._search
_regex
(
54 r
'Uploaded by\s*<a[^>]*>([^<]+)<',
55 webpage
, 'uploader', fatal
=False)
59 'display_id': display_id
,
61 'description': self
._og
_search
_description
(webpage
),
62 'thumbnails': extract('image'),
63 'upload_date': upload_date
,
69 class UstudioEmbedIE(InfoExtractor
):
70 IE_NAME
= 'ustudio:embed'
71 _VALID_URL
= r
'https?://(?:(?:app|embed)\.)?ustudio\.com/embed/(?P<uid>[^/]+)/(?P<id>[^/]+)'
73 'url': 'http://app.ustudio.com/embed/DeN7VdYRDKhP/Uw7G1kMCe65T',
74 'md5': '47c0be52a09b23a7f40de9469cec58f4',
78 'title': '5 Things IT Should Know About Video',
79 'description': 'md5:93d32650884b500115e158c5677d25ad',
80 'uploader_id': 'DeN7VdYRDKhP',
84 def _real_extract(self
, url
):
85 uploader_id
, video_id
= self
._match
_valid
_url
(url
).groups()
86 video_data
= self
._download
_json
(
87 'http://app.ustudio.com/embed/%s/%s/config.json' % (uploader_id
, video_id
),
88 video_id
)['videos'][0]
89 title
= video_data
['name']
92 for ext
, qualities
in video_data
.get('transcodes', {}).items():
93 for quality
in qualities
:
94 quality_url
= quality
.get('url')
97 height
= int_or_none(quality
.get('height'))
99 'format_id': '%s-%dp' % (ext
, height
) if height
else ext
,
101 'width': int_or_none(quality
.get('width')),
104 self
._sort
_formats
(formats
)
107 for image
in video_data
.get('images', []):
108 image_url
= image
.get('url')
118 'description': video_data
.get('description'),
119 'duration': int_or_none(video_data
.get('duration')),
120 'uploader_id': uploader_id
,
121 'tags': video_data
.get('keywords'),
122 'thumbnails': thumbnails
,