[ustudio] add support ustudio app/embed urls
This commit is contained in:
parent
b9e7bc55da
commit
99d79b8692
@ -6,10 +6,12 @@ from .common import InfoExtractor
|
|||||||
from ..utils import (
|
from ..utils import (
|
||||||
int_or_none,
|
int_or_none,
|
||||||
unified_strdate,
|
unified_strdate,
|
||||||
|
unescapeHTML,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class UstudioIE(InfoExtractor):
|
class UstudioIE(InfoExtractor):
|
||||||
|
IE_NAME = 'ustudio'
|
||||||
_VALID_URL = r'https?://(?:(?:www|v1)\.)?ustudio\.com/video/(?P<id>[^/]+)/(?P<display_id>[^/?#&]+)'
|
_VALID_URL = r'https?://(?:(?:www|v1)\.)?ustudio\.com/video/(?P<id>[^/]+)/(?P<display_id>[^/?#&]+)'
|
||||||
_TEST = {
|
_TEST = {
|
||||||
'url': 'http://ustudio.com/video/Uxu2my9bgSph/san_francisco_golden_gate_bridge',
|
'url': 'http://ustudio.com/video/Uxu2my9bgSph/san_francisco_golden_gate_bridge',
|
||||||
@ -27,9 +29,7 @@ class UstudioIE(InfoExtractor):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
mobj = re.match(self._VALID_URL, url)
|
video_id, display_id = re.match(self._VALID_URL, url).groups()
|
||||||
video_id = mobj.group('id')
|
|
||||||
display_id = mobj.group('display_id')
|
|
||||||
|
|
||||||
config = self._download_xml(
|
config = self._download_xml(
|
||||||
'http://v1.ustudio.com/embed/%s/ustudio/config.xml' % video_id,
|
'http://v1.ustudio.com/embed/%s/ustudio/config.xml' % video_id,
|
||||||
@ -37,7 +37,7 @@ class UstudioIE(InfoExtractor):
|
|||||||
|
|
||||||
def extract(kind):
|
def extract(kind):
|
||||||
return [{
|
return [{
|
||||||
'url': item.attrib['url'],
|
'url': unescapeHTML(item.attrib['url']),
|
||||||
'width': int_or_none(item.get('width')),
|
'width': int_or_none(item.get('width')),
|
||||||
'height': int_or_none(item.get('height')),
|
'height': int_or_none(item.get('height')),
|
||||||
} for item in config.findall('./qualities/quality/%s' % kind) if item.get('url')]
|
} for item in config.findall('./qualities/quality/%s' % kind) if item.get('url')]
|
||||||
@ -65,3 +65,61 @@ class UstudioIE(InfoExtractor):
|
|||||||
'uploader': uploader,
|
'uploader': uploader,
|
||||||
'formats': formats,
|
'formats': formats,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class UstudioEmbedIE(InfoExtractor):
|
||||||
|
IE_NAME = 'ustudio:embed'
|
||||||
|
_VALID_URL = r'https?://(?:(?:app|embed)\.)?ustudio\.com/embed/(?P<uid>[^/]+)/(?P<id>[^/]+)'
|
||||||
|
_TEST = {
|
||||||
|
'url': 'http://app.ustudio.com/embed/DeN7VdYRDKhP/Uw7G1kMCe65T',
|
||||||
|
'md5': '47c0be52a09b23a7f40de9469cec58f4',
|
||||||
|
'info_dict': {
|
||||||
|
'id': 'Uw7G1kMCe65T',
|
||||||
|
'ext': 'mp4',
|
||||||
|
'title': '5 Things IT Should Know About Video',
|
||||||
|
'description': 'md5:93d32650884b500115e158c5677d25ad',
|
||||||
|
'uploader_id': 'DeN7VdYRDKhP',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def _real_extract(self, url):
|
||||||
|
uploader_id, video_id = re.match(self._VALID_URL, url).groups()
|
||||||
|
video_data = self._download_json(
|
||||||
|
'http://app.ustudio.com/embed/%s/%s/config.json' % (uploader_id, video_id),
|
||||||
|
video_id)['videos'][0]
|
||||||
|
title = video_data['name']
|
||||||
|
|
||||||
|
formats = []
|
||||||
|
for ext, qualities in video_data.get('transcodes', {}).items():
|
||||||
|
for quality in qualities:
|
||||||
|
quality_url = quality.get('url')
|
||||||
|
if not quality_url:
|
||||||
|
continue
|
||||||
|
height = int_or_none(quality.get('height'))
|
||||||
|
formats.append({
|
||||||
|
'format_id': '%s-%dp' % (ext, height) if height else ext,
|
||||||
|
'url': quality_url,
|
||||||
|
'width': int_or_none(quality.get('width')),
|
||||||
|
'height': height,
|
||||||
|
})
|
||||||
|
self._sort_formats(formats)
|
||||||
|
|
||||||
|
thumbnails = []
|
||||||
|
for image in video_data.get('images', []):
|
||||||
|
image_url = image.get('url')
|
||||||
|
if not image_url:
|
||||||
|
continue
|
||||||
|
thumbnails.append({
|
||||||
|
'url': image_url,
|
||||||
|
})
|
||||||
|
|
||||||
|
return {
|
||||||
|
'id': video_id,
|
||||||
|
'title': title,
|
||||||
|
'description': video_data.get('description'),
|
||||||
|
'duration': int_or_none(video_data.get('duration')),
|
||||||
|
'uploader_id': uploader_id,
|
||||||
|
'tags': video_data.get('keywords'),
|
||||||
|
'thumbnails': thumbnails,
|
||||||
|
'formats': formats,
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user