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.

79 lines
2.9 KiB

10 years ago
  1. # encoding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..utils import int_or_none
  5. class FirstTVIE(InfoExtractor):
  6. IE_NAME = '1tv'
  7. IE_DESC = 'Первый канал'
  8. _VALID_URL = r'http://(?:www\.)?1tv\.ru/(?:[^/]+/)+(?P<id>.+)'
  9. _TESTS = [{
  10. 'url': 'http://www.1tv.ru/videoarchive/73390',
  11. 'md5': '777f525feeec4806130f4f764bc18a4f',
  12. 'info_dict': {
  13. 'id': '73390',
  14. 'ext': 'mp4',
  15. 'title': 'Олимпийские канатные дороги',
  16. 'description': 'md5:d41d8cd98f00b204e9800998ecf8427e',
  17. 'thumbnail': 're:^https?://.*\.(?:jpg|JPG)$',
  18. 'duration': 149,
  19. 'like_count': int,
  20. 'dislike_count': int,
  21. },
  22. 'skip': 'Only works from Russia',
  23. }, {
  24. 'url': 'http://www.1tv.ru/prj/inprivate/vypusk/35930',
  25. 'md5': 'a1b6b60d530ebcf8daacf4565762bbaf',
  26. 'info_dict': {
  27. 'id': '35930',
  28. 'ext': 'mp4',
  29. 'title': 'Наедине со всеми. Людмила Сенчина',
  30. 'description': 'md5:89553aed1d641416001fe8d450f06cb9',
  31. 'thumbnail': 're:^https?://.*\.(?:jpg|JPG)$',
  32. 'duration': 2694,
  33. },
  34. 'skip': 'Only works from Russia',
  35. }]
  36. def _real_extract(self, url):
  37. video_id = self._match_id(url)
  38. webpage = self._download_webpage(url, video_id, 'Downloading page')
  39. video_url = self._html_search_regex(
  40. r'''(?s)(?:jwplayer\('flashvideoportal_1'\)\.setup\({|var\s+playlistObj\s*=).*?'file'\s*:\s*'([^']+)'.*?}\);''',
  41. webpage, 'video URL')
  42. title = self._html_search_regex(
  43. [r'<div class="tv_translation">\s*<h1><a href="[^"]+">([^<]*)</a>',
  44. r"'title'\s*:\s*'([^']+)'"], webpage, 'title')
  45. description = self._html_search_regex(
  46. r'<div class="descr">\s*<div>&nbsp;</div>\s*<p>([^<]*)</p></div>',
  47. webpage, 'description', default=None) or self._html_search_meta(
  48. 'description', webpage, 'description')
  49. thumbnail = self._og_search_thumbnail(webpage)
  50. duration = self._og_search_property(
  51. 'video:duration', webpage,
  52. 'video duration', fatal=False)
  53. like_count = self._html_search_regex(
  54. r'title="Понравилось".*?/></label> \[(\d+)\]',
  55. webpage, 'like count', default=None)
  56. dislike_count = self._html_search_regex(
  57. r'title="Не понравилось".*?/></label> \[(\d+)\]',
  58. webpage, 'dislike count', default=None)
  59. return {
  60. 'id': video_id,
  61. 'url': video_url,
  62. 'thumbnail': thumbnail,
  63. 'title': title,
  64. 'description': description,
  65. 'duration': int_or_none(duration),
  66. 'like_count': int_or_none(like_count),
  67. 'dislike_count': int_or_none(dislike_count),
  68. }