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.

54 lines
1.7 KiB

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