mirror of https://github.com/yt-dlp/yt-dlp
[ustudio] Improve (Closes #8574)
parent
9195ef745a
commit
20108c6b90
@ -1,58 +1,67 @@
|
|||||||
# coding: utf-8
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
import re
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import int_or_none
|
from ..utils import (
|
||||||
|
int_or_none,
|
||||||
|
unified_strdate,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
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'http://(?:www\.|v1\.)?ustudio.com/video/(?P<id>[\w\d]+)/.+'
|
_TEST = {
|
||||||
_TESTS = [
|
|
||||||
{
|
|
||||||
'url': 'http://ustudio.com/video/Uxu2my9bgSph/san_francisco_golden_gate_bridge',
|
'url': 'http://ustudio.com/video/Uxu2my9bgSph/san_francisco_golden_gate_bridge',
|
||||||
'md5': '58bbfca62125378742df01fc2abbdef6',
|
'md5': '58bbfca62125378742df01fc2abbdef6',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': 'Uxu2my9bgSph',
|
'id': 'Uxu2my9bgSph',
|
||||||
|
'display_id': 'san_francisco_golden_gate_bridge',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': 'San Francisco: Golden Gate Bridge',
|
'title': 'San Francisco: Golden Gate Bridge',
|
||||||
'thumbnail': 're:^https?://.*\.jpg$',
|
|
||||||
'description': 'md5:23925500697f2c6d4830e387ba51a9be',
|
'description': 'md5:23925500697f2c6d4830e387ba51a9be',
|
||||||
|
'thumbnail': 're:^https?://.*\.jpg$',
|
||||||
|
'upload_date': '20111107',
|
||||||
'uploader': 'Tony Farley',
|
'uploader': 'Tony Farley',
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
]
|
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
video_id = self._match_id(url)
|
mobj = re.match(self._VALID_URL, url)
|
||||||
|
video_id = mobj.group('id')
|
||||||
webpage = self._download_webpage(url, video_id)
|
display_id = mobj.group('display_id')
|
||||||
|
|
||||||
doc = self._download_xml(
|
config = self._download_xml(
|
||||||
'http://v1.ustudio.com/embed/{0}/ustudio/config.xml'.format(
|
'http://v1.ustudio.com/embed/%s/ustudio/config.xml' % video_id,
|
||||||
video_id),
|
display_id)
|
||||||
video_id,
|
|
||||||
note='Downloading video info',
|
def extract(kind):
|
||||||
errnote='Failed to download video info')
|
return [{
|
||||||
|
'url': item.attrib['url'],
|
||||||
formats = [
|
'width': int_or_none(item.get('width')),
|
||||||
{
|
'height': int_or_none(item.get('height')),
|
||||||
'url': quality.attrib['url'],
|
} for item in config.findall('./qualities/quality/%s' % kind) if item.get('url')]
|
||||||
'width': int_or_none(quality.attrib.get('width')),
|
|
||||||
'height': int_or_none(quality.attrib.get('height')),
|
formats = extract('video')
|
||||||
} for quality in doc.findall('./qualities/quality/video')
|
|
||||||
]
|
|
||||||
self._sort_formats(formats)
|
self._sort_formats(formats)
|
||||||
|
|
||||||
|
webpage = self._download_webpage(url, display_id)
|
||||||
|
|
||||||
|
title = self._og_search_title(webpage)
|
||||||
|
upload_date = unified_strdate(self._search_regex(
|
||||||
|
r'(?s)Uploaded by\s*.+?\s*on\s*<span>([^<]+)</span>',
|
||||||
|
webpage, 'upload date', fatal=False))
|
||||||
|
uploader = self._search_regex(
|
||||||
|
r'Uploaded by\s*<a[^>]*>([^<]+)<',
|
||||||
|
webpage, 'uploader', fatal=False)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
'title': self._og_search_title(webpage),
|
'display_id': display_id,
|
||||||
'thumbnail': self._og_search_thumbnail(webpage),
|
'title': title,
|
||||||
'formats': formats,
|
|
||||||
'description': self._og_search_description(webpage),
|
'description': self._og_search_description(webpage),
|
||||||
'uploader': self._html_search_regex(
|
'thumbnails': extract('image'),
|
||||||
r'<a href=".*/user/.+">(.+)</a> on',
|
'upload_date': upload_date,
|
||||||
webpage,
|
'uploader': uploader,
|
||||||
'uploader',
|
'formats': formats,
|
||||||
fatal=False),
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue