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.

52 lines
1.7 KiB

  1. from __future__ import unicode_literals
  2. from .common import InfoExtractor
  3. from ..compat import compat_urlparse
  4. from ..utils import qualities
  5. class TheSceneIE(InfoExtractor):
  6. _VALID_URL = r'https://thescene\.com/watch/[^/]+/(?P<id>[^/#?]+)'
  7. _TEST = {
  8. 'url': 'https://thescene.com/watch/vogue/narciso-rodriguez-spring-2013-ready-to-wear',
  9. 'info_dict': {
  10. 'id': '520e8faac2b4c00e3c6e5f43',
  11. 'ext': 'mp4',
  12. 'title': 'Narciso Rodriguez: Spring 2013 Ready-to-Wear',
  13. 'display_id': 'narciso-rodriguez-spring-2013-ready-to-wear',
  14. },
  15. }
  16. def _real_extract(self, url):
  17. display_id = self._match_id(url)
  18. webpage = self._download_webpage(url, display_id)
  19. player_url = compat_urlparse.urljoin(
  20. url,
  21. self._html_search_regex(
  22. r'id=\'js-player-script\'[^>]+src=\'(.+?)\'', webpage, 'player url'))
  23. player = self._download_webpage(player_url, display_id)
  24. info = self._parse_json(
  25. self._search_regex(
  26. r'(?m)var\s+video\s+=\s+({.+?});$', player, 'info json'),
  27. display_id)
  28. qualities_order = qualities(('low', 'high'))
  29. formats = [{
  30. 'format_id': '{0}-{1}'.format(f['type'].split('/')[0], f['quality']),
  31. 'url': f['src'],
  32. 'quality': qualities_order(f['quality']),
  33. } for f in info['sources'][0]]
  34. self._sort_formats(formats)
  35. return {
  36. 'id': info['id'],
  37. 'display_id': display_id,
  38. 'title': info['title'],
  39. 'formats': formats,
  40. 'thumbnail': info.get('poster_frame'),
  41. }