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.

61 lines
1.9 KiB

  1. from __future__ import unicode_literals
  2. from .common import InfoExtractor
  3. from ..utils import int_or_none
  4. class SprutoBaseIE(InfoExtractor):
  5. def _extract_spruto(self, spruto, video_id):
  6. playlist = spruto['playlist'][0]
  7. title = playlist['title']
  8. video_id = playlist.get('videoId') or video_id
  9. thumbnail = playlist.get('posterUrl') or playlist.get('thumbnailUrl')
  10. duration = int_or_none(playlist.get('duration'))
  11. formats = [{
  12. 'url': f['url'],
  13. } for f in playlist['video']]
  14. self._sort_formats(formats)
  15. return {
  16. 'id': video_id,
  17. 'title': title,
  18. 'thumbnail': thumbnail,
  19. 'duration': duration,
  20. 'formats': formats,
  21. }
  22. class VimpleIE(SprutoBaseIE):
  23. IE_DESC = 'Vimple - one-click video hosting'
  24. _VALID_URL = r'https?://(?:player\.vimple\.(?:ru|co)/iframe|vimple\.(?:ru|co))/(?P<id>[\da-f-]{32,36})'
  25. _TESTS = [{
  26. 'url': 'http://vimple.ru/c0f6b1687dcd4000a97ebe70068039cf',
  27. 'md5': '2e750a330ed211d3fd41821c6ad9a279',
  28. 'info_dict': {
  29. 'id': 'c0f6b168-7dcd-4000-a97e-be70068039cf',
  30. 'ext': 'mp4',
  31. 'title': 'Sunset',
  32. 'duration': 20,
  33. 'thumbnail': r're:https?://.*?\.jpg',
  34. },
  35. }, {
  36. 'url': 'http://player.vimple.ru/iframe/52e1beec-1314-4a83-aeac-c61562eadbf9',
  37. 'only_matching': True,
  38. }, {
  39. 'url': 'http://vimple.co/04506a053f124483b8fb05ed73899f19',
  40. 'only_matching': True,
  41. }]
  42. def _real_extract(self, url):
  43. video_id = self._match_id(url)
  44. webpage = self._download_webpage(
  45. 'http://player.vimple.ru/iframe/%s' % video_id, video_id)
  46. spruto = self._parse_json(
  47. self._search_regex(
  48. r'sprutoData\s*:\s*({.+?}),\r\n', webpage, 'spruto data'),
  49. video_id)
  50. return self._extract_spruto(spruto, video_id)