krasview.py 1.9 KB

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