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.

91 lines
3.1 KiB

10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
  1. # coding: 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 FiveTVIE(InfoExtractor):
  7. _VALID_URL = r'''(?x)
  8. https?://
  9. (?:www\.)?5-tv\.ru/
  10. (?:
  11. (?:[^/]+/)+(?P<id>\d+)|
  12. (?P<path>[^/?#]+)(?:[/?#])?
  13. )
  14. '''
  15. _TESTS = [{
  16. 'url': 'http://5-tv.ru/news/96814/',
  17. 'md5': 'bbff554ad415ecf5416a2f48c22d9283',
  18. 'info_dict': {
  19. 'id': '96814',
  20. 'ext': 'mp4',
  21. 'title': 'Россияне выбрали имя для общенациональной платежной системы',
  22. 'description': 'md5:a8aa13e2b7ad36789e9f77a74b6de660',
  23. 'thumbnail': r're:^https?://.*\.jpg$',
  24. 'duration': 180,
  25. },
  26. }, {
  27. 'url': 'http://5-tv.ru/video/1021729/',
  28. 'info_dict': {
  29. 'id': '1021729',
  30. 'ext': 'mp4',
  31. 'title': '3D принтер',
  32. 'description': 'md5:d76c736d29ef7ec5c0cf7d7c65ffcb41',
  33. 'thumbnail': r're:^https?://.*\.jpg$',
  34. 'duration': 180,
  35. },
  36. }, {
  37. # redirect to https://www.5-tv.ru/projects/1000095/izvestia-glavnoe/
  38. 'url': 'http://www.5-tv.ru/glavnoe/#itemDetails',
  39. 'info_dict': {
  40. 'id': 'glavnoe',
  41. 'ext': 'mp4',
  42. 'title': r're:^Итоги недели с \d+ по \d+ \w+ \d{4} года$',
  43. 'thumbnail': r're:^https?://.*\.jpg$',
  44. },
  45. 'skip': 'redirect to «Известия. Главное» project page',
  46. }, {
  47. 'url': 'http://www.5-tv.ru/glavnoe/broadcasts/508645/',
  48. 'only_matching': True,
  49. }, {
  50. 'url': 'http://5-tv.ru/films/1507502/',
  51. 'only_matching': True,
  52. }, {
  53. 'url': 'http://5-tv.ru/programs/broadcast/508713/',
  54. 'only_matching': True,
  55. }, {
  56. 'url': 'http://5-tv.ru/angel/',
  57. 'only_matching': True,
  58. }, {
  59. 'url': 'http://www.5-tv.ru/schedule/?iframe=true&width=900&height=450',
  60. 'only_matching': True,
  61. }]
  62. def _real_extract(self, url):
  63. mobj = re.match(self._VALID_URL, url)
  64. video_id = mobj.group('id') or mobj.group('path')
  65. webpage = self._download_webpage(url, video_id)
  66. video_url = self._search_regex(
  67. [r'<div[^>]+?class="(?:flow)?player[^>]+?data-href="([^"]+)"',
  68. r'<a[^>]+?href="([^"]+)"[^>]+?class="videoplayer"'],
  69. webpage, 'video url')
  70. title = self._og_search_title(webpage, default=None) or self._search_regex(
  71. r'<title>([^<]+)</title>', webpage, 'title')
  72. duration = int_or_none(self._og_search_property(
  73. 'video:duration', webpage, 'duration', default=None))
  74. return {
  75. 'id': video_id,
  76. 'url': video_url,
  77. 'title': title,
  78. 'description': self._og_search_description(webpage, default=None),
  79. 'thumbnail': self._og_search_thumbnail(webpage, default=None),
  80. 'duration': duration,
  81. }