]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/ustudio.py
[uStudio] Add new extractor
[yt-dlp.git] / youtube_dl / extractor / ustudio.py
CommitLineData
9195ef74 1# coding: utf-8
2from __future__ import unicode_literals
3
4from .common import InfoExtractor
5from ..utils import int_or_none
6
7
8class UstudioIE(InfoExtractor):
9 IE_NAME = 'uStudio'
10 _VALID_URL = r'http://(?:www\.|v1\.)?ustudio.com/video/(?P<id>[\w\d]+)/.+'
11 _TESTS = [
12 {
13 'url': 'http://ustudio.com/video/Uxu2my9bgSph/san_francisco_golden_gate_bridge',
14 'md5': '58bbfca62125378742df01fc2abbdef6',
15 'info_dict': {
16 'id': 'Uxu2my9bgSph',
17 'ext': 'mp4',
18 'title': 'San Francisco: Golden Gate Bridge',
19 'thumbnail': 're:^https?://.*\.jpg$',
20 'description': 'md5:23925500697f2c6d4830e387ba51a9be',
21 'uploader': 'Tony Farley',
22 }
23 },
24 ]
25
26 def _real_extract(self, url):
27 video_id = self._match_id(url)
28
29 webpage = self._download_webpage(url, video_id)
30
31 doc = self._download_xml(
32 'http://v1.ustudio.com/embed/{0}/ustudio/config.xml'.format(
33 video_id),
34 video_id,
35 note='Downloading video info',
36 errnote='Failed to download video info')
37
38 formats = [
39 {
40 'url': quality.attrib['url'],
41 'width': int_or_none(quality.attrib.get('width')),
42 'height': int_or_none(quality.attrib.get('height')),
43 } for quality in doc.findall('./qualities/quality/video')
44 ]
45 self._sort_formats(formats)
46
47 return {
48 'id': video_id,
49 'title': self._og_search_title(webpage),
50 'thumbnail': self._og_search_thumbnail(webpage),
51 'formats': formats,
52 'description': self._og_search_description(webpage),
53 'uploader': self._html_search_regex(
54 r'<a href=".*/user/.+">(.+)</a> on',
55 webpage,
56 'uploader',
57 fatal=False),
58 }