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.

88 lines
2.9 KiB

9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 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. http://
  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': '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': 're:^https?://.*\.jpg$',
  34. 'duration': 180,
  35. },
  36. }, {
  37. 'url': 'http://www.5-tv.ru/glavnoe/#itemDetails',
  38. 'info_dict': {
  39. 'id': 'glavnoe',
  40. 'ext': 'mp4',
  41. 'title': 'Итоги недели с 8 по 14 июня 2015 года',
  42. 'thumbnail': 're:^https?://.*\.jpg$',
  43. },
  44. }, {
  45. 'url': 'http://www.5-tv.ru/glavnoe/broadcasts/508645/',
  46. 'only_matching': True,
  47. }, {
  48. 'url': 'http://5-tv.ru/films/1507502/',
  49. 'only_matching': True,
  50. }, {
  51. 'url': 'http://5-tv.ru/programs/broadcast/508713/',
  52. 'only_matching': True,
  53. }, {
  54. 'url': 'http://5-tv.ru/angel/',
  55. 'only_matching': True,
  56. }, {
  57. 'url': 'http://www.5-tv.ru/schedule/?iframe=true&width=900&height=450',
  58. 'only_matching': True,
  59. }]
  60. def _real_extract(self, url):
  61. mobj = re.match(self._VALID_URL, url)
  62. video_id = mobj.group('id') or mobj.group('path')
  63. webpage = self._download_webpage(url, video_id)
  64. video_url = self._search_regex(
  65. r'<a[^>]+?href="([^"]+)"[^>]+?class="videoplayer"',
  66. webpage, 'video url')
  67. title = self._og_search_title(webpage, default=None) or self._search_regex(
  68. r'<title>([^<]+)</title>', webpage, 'title')
  69. duration = int_or_none(self._og_search_property(
  70. 'video:duration', webpage, 'duration', default=None))
  71. return {
  72. 'id': video_id,
  73. 'url': video_url,
  74. 'title': title,
  75. 'description': self._og_search_description(webpage, default=None),
  76. 'thumbnail': self._og_search_thumbnail(webpage, default=None),
  77. 'duration': duration,
  78. }