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
2.3 KiB

  1. # encoding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import int_or_none
  6. class FirstTVIE(InfoExtractor):
  7. IE_NAME = 'firsttv'
  8. IE_DESC = 'Видеоархив - Первый канал'
  9. _VALID_URL = r'http://(?:www\.)?1tv\.ru/videoarchive/(?P<id>\d+)'
  10. _TEST = {
  11. 'url': 'http://www.1tv.ru/videoarchive/73390',
  12. 'md5': '3de6390cf0cca4a5eae1d1d83895e5ad',
  13. 'info_dict': {
  14. 'id': '73390',
  15. 'ext': 'mp4',
  16. 'title': 'Олимпийские канатные дороги',
  17. 'description': 'md5:cc730d2bf4215463e37fff6a1e277b13',
  18. 'thumbnail': 'http://img1.1tv.ru/imgsize640x360/PR20140210114657.JPG',
  19. 'duration': 149,
  20. },
  21. 'skip': 'Only works from Russia',
  22. }
  23. def _real_extract(self, url):
  24. mobj = re.match(self._VALID_URL, url)
  25. video_id = mobj.group('id')
  26. webpage = self._download_webpage(url, video_id, 'Downloading page')
  27. video_url = self._html_search_regex(
  28. r'''(?s)jwplayer\('flashvideoportal_1'\)\.setup\({.*?'file': '([^']+)'.*?}\);''', webpage, 'video URL')
  29. title = self._html_search_regex(
  30. r'<div class="tv_translation">\s*<h1><a href="[^"]+">([^<]*)</a>', webpage, 'title')
  31. description = self._html_search_regex(
  32. r'<div class="descr">\s*<div>&nbsp;</div>\s*<p>([^<]*)</p></div>', webpage, 'description', fatal=False)
  33. thumbnail = self._og_search_thumbnail(webpage)
  34. duration = self._og_search_property('video:duration', webpage, 'video duration', fatal=False)
  35. like_count = self._html_search_regex(r'title="Понравилось".*?/></label> \[(\d+)\]',
  36. webpage, 'like count', fatal=False)
  37. dislike_count = self._html_search_regex(r'title="Не понравилось".*?/></label> \[(\d+)\]',
  38. webpage, 'dislike count', fatal=False)
  39. return {
  40. 'id': video_id,
  41. 'url': video_url,
  42. 'thumbnail': thumbnail,
  43. 'title': title,
  44. 'description': description,
  45. 'duration': int_or_none(duration),
  46. 'like_count': int_or_none(like_count),
  47. 'dislike_count': int_or_none(dislike_count),
  48. }