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.

68 lines
2.1 KiB

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