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.

60 lines
2.2 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .vimple import SprutoBaseIE
  5. class MyviIE(SprutoBaseIE):
  6. _VALID_URL = r'''(?x)
  7. https?://
  8. myvi\.(?:ru/player|tv)/
  9. (?:
  10. (?:
  11. embed/html|
  12. flash|
  13. api/Video/Get
  14. )/|
  15. content/preloader\.swf\?.*\bid=
  16. )
  17. (?P<id>[\da-zA-Z_-]+)
  18. '''
  19. _TESTS = [{
  20. 'url': 'http://myvi.ru/player/embed/html/oOy4euHA6LVwNNAjhD9_Jq5Ha2Qf0rtVMVFMAZav8wObeRTZaCATzucDQIDph8hQU0',
  21. 'md5': '571bbdfba9f9ed229dc6d34cc0f335bf',
  22. 'info_dict': {
  23. 'id': 'f16b2bbd-cde8-481c-a981-7cd48605df43',
  24. 'ext': 'mp4',
  25. 'title': 'хозяин жизни',
  26. 'thumbnail': 're:^https?://.*\.jpg$',
  27. 'duration': 25,
  28. },
  29. }, {
  30. 'url': 'http://myvi.ru/player/content/preloader.swf?id=oOy4euHA6LVwNNAjhD9_Jq5Ha2Qf0rtVMVFMAZav8wOYf1WFpPfc_bWTKGVf_Zafr0',
  31. 'only_matching': True,
  32. }, {
  33. 'url': 'http://myvi.ru/player/api/Video/Get/oOy4euHA6LVwNNAjhD9_Jq5Ha2Qf0rtVMVFMAZav8wObeRTZaCATzucDQIDph8hQU0',
  34. 'only_matching': True,
  35. }, {
  36. 'url': 'http://myvi.tv/embed/html/oTGTNWdyz4Zwy_u1nraolwZ1odenTd9WkTnRfIL9y8VOgHYqOHApE575x4_xxS9Vn0?ap=0',
  37. 'only_matching': True,
  38. }, {
  39. 'url': 'http://myvi.ru/player/flash/ocp2qZrHI-eZnHKQBK4cZV60hslH8LALnk0uBfKsB-Q4WnY26SeGoYPi8HWHxu0O30',
  40. 'only_matching': True,
  41. }]
  42. @classmethod
  43. def _extract_url(cls, webpage):
  44. mobj = re.search(
  45. r'<iframe[^>]+?src=(["\'])(?P<url>(?:https?:)?//myvi\.(?:ru/player|tv)/(?:embed/html|flash)/[^"]+)\1', webpage)
  46. if mobj:
  47. return mobj.group('url')
  48. def _real_extract(self, url):
  49. video_id = self._match_id(url)
  50. spruto = self._download_json(
  51. 'http://myvi.ru/player/api/Video/Get/%s?sig' % video_id, video_id)['sprutoData']
  52. return self._extract_spruto(spruto, video_id)