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.

59 lines
1.9 KiB

  1. # encoding: utf-8
  2. from __future__ import unicode_literals
  3. import json
  4. import re
  5. from .common import InfoExtractor
  6. from ..utils import (
  7. int_or_none,
  8. unescapeHTML,
  9. )
  10. class KrasViewIE(InfoExtractor):
  11. IE_DESC = 'Красвью'
  12. _VALID_URL = r'https?://krasview\.ru/video/(?P<id>\d+)'
  13. _TEST = {
  14. 'url': 'http://krasview.ru/video/512228',
  15. 'md5': '3b91003cf85fc5db277870c8ebd98eae',
  16. 'info_dict': {
  17. 'id': '512228',
  18. 'ext': 'mp4',
  19. 'title': 'Снег, лёд, заносы',
  20. 'description': 'Снято в городе Нягань, в Ханты-Мансийском автономном округе.',
  21. 'duration': 27,
  22. 'thumbnail': 're:^https?://.*\.jpg',
  23. },
  24. }
  25. def _real_extract(self, url):
  26. mobj = re.match(self._VALID_URL, url)
  27. video_id = mobj.group('id')
  28. webpage = self._download_webpage(url, video_id)
  29. flashvars = json.loads(self._search_regex(
  30. r'flashvars\s*:\s*({.+?})\s*}\);', webpage, 'flashvars'))
  31. video_url = flashvars['url']
  32. title = unescapeHTML(flashvars['title'])
  33. description = unescapeHTML(flashvars.get('subtitle') or self._og_search_description(webpage, default=None))
  34. thumbnail = flashvars['image']
  35. duration = int(flashvars['duration'])
  36. filesize = int(flashvars['size'])
  37. width = int_or_none(self._og_search_property('video:width', webpage, 'video width'))
  38. height = int_or_none(self._og_search_property('video:height', webpage, 'video height'))
  39. return {
  40. 'id': video_id,
  41. 'url': video_url,
  42. 'title': title,
  43. 'description': description,
  44. 'thumbnail': thumbnail,
  45. 'duration': duration,
  46. 'filesize': filesize,
  47. 'width': width,
  48. 'height': height,
  49. }