You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
2.2 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. int_or_none,
  6. unified_strdate,
  7. )
  8. class UstudioIE(InfoExtractor):
  9. _VALID_URL = r'https?://(?:(?:www|v1)\.)?ustudio\.com/video/(?P<id>[^/]+)/(?P<display_id>[^/?#&]+)'
  10. _TEST = {
  11. 'url': 'http://ustudio.com/video/Uxu2my9bgSph/san_francisco_golden_gate_bridge',
  12. 'md5': '58bbfca62125378742df01fc2abbdef6',
  13. 'info_dict': {
  14. 'id': 'Uxu2my9bgSph',
  15. 'display_id': 'san_francisco_golden_gate_bridge',
  16. 'ext': 'mp4',
  17. 'title': 'San Francisco: Golden Gate Bridge',
  18. 'description': 'md5:23925500697f2c6d4830e387ba51a9be',
  19. 'thumbnail': 're:^https?://.*\.jpg$',
  20. 'upload_date': '20111107',
  21. 'uploader': 'Tony Farley',
  22. }
  23. }
  24. def _real_extract(self, url):
  25. mobj = re.match(self._VALID_URL, url)
  26. video_id = mobj.group('id')
  27. display_id = mobj.group('display_id')
  28. config = self._download_xml(
  29. 'http://v1.ustudio.com/embed/%s/ustudio/config.xml' % video_id,
  30. display_id)
  31. def extract(kind):
  32. return [{
  33. 'url': item.attrib['url'],
  34. 'width': int_or_none(item.get('width')),
  35. 'height': int_or_none(item.get('height')),
  36. } for item in config.findall('./qualities/quality/%s' % kind) if item.get('url')]
  37. formats = extract('video')
  38. self._sort_formats(formats)
  39. webpage = self._download_webpage(url, display_id)
  40. title = self._og_search_title(webpage)
  41. upload_date = unified_strdate(self._search_regex(
  42. r'(?s)Uploaded by\s*.+?\s*on\s*<span>([^<]+)</span>',
  43. webpage, 'upload date', fatal=False))
  44. uploader = self._search_regex(
  45. r'Uploaded by\s*<a[^>]*>([^<]+)<',
  46. webpage, 'uploader', fatal=False)
  47. return {
  48. 'id': video_id,
  49. 'display_id': display_id,
  50. 'title': title,
  51. 'description': self._og_search_description(webpage),
  52. 'thumbnails': extract('image'),
  53. 'upload_date': upload_date,
  54. 'uploader': uploader,
  55. 'formats': formats,
  56. }