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.

90 lines
3.1 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. ExtractorError,
  6. int_or_none,
  7. xpath_text,
  8. qualities,
  9. )
  10. class PladformIE(InfoExtractor):
  11. _VALID_URL = r'''(?x)
  12. https?://
  13. (?:
  14. (?:
  15. out\.pladform\.ru/player|
  16. static\.pladform\.ru/player\.swf
  17. )
  18. \?.*\bvideoid=|
  19. video\.pladform\.ru/catalog/video/videoid/
  20. )
  21. (?P<id>\d+)
  22. '''
  23. _TESTS = [{
  24. # http://muz-tv.ru/kinozal/view/7400/
  25. 'url': 'http://out.pladform.ru/player?pl=24822&videoid=100183293',
  26. 'md5': '61f37b575dd27f1bb2e1854777fe31f4',
  27. 'info_dict': {
  28. 'id': '100183293',
  29. 'ext': 'mp4',
  30. 'title': 'Тайны перевала Дятлова • 1 серия 2 часть',
  31. 'description': 'Документальный сериал-расследование одной из самых жутких тайн ХХ века',
  32. 'thumbnail': 're:^https?://.*\.jpg$',
  33. 'duration': 694,
  34. 'age_limit': 0,
  35. },
  36. }, {
  37. 'url': 'http://static.pladform.ru/player.swf?pl=21469&videoid=100183293&vkcid=0',
  38. 'only_matching': True,
  39. }, {
  40. 'url': 'http://video.pladform.ru/catalog/video/videoid/100183293/vkcid/0',
  41. 'only_matching': True,
  42. }]
  43. def _real_extract(self, url):
  44. video_id = self._match_id(url)
  45. video = self._download_xml(
  46. 'http://out.pladform.ru/getVideo?pl=1&videoid=%s' % video_id,
  47. video_id)
  48. if video.tag == 'error':
  49. raise ExtractorError(
  50. '%s returned error: %s' % (self.IE_NAME, video.text),
  51. expected=True)
  52. quality = qualities(('ld', 'sd', 'hd'))
  53. formats = [{
  54. 'url': src.text,
  55. 'format_id': src.get('quality'),
  56. 'quality': quality(src.get('quality')),
  57. } for src in video.findall('./src')]
  58. self._sort_formats(formats)
  59. webpage = self._download_webpage(
  60. 'http://video.pladform.ru/catalog/video/videoid/%s' % video_id,
  61. video_id)
  62. title = self._og_search_title(webpage, fatal=False) or xpath_text(
  63. video, './/title', 'title', fatal=True)
  64. description = self._search_regex(
  65. r'</h3>\s*<p>([^<]+)</p>', webpage, 'description', fatal=False)
  66. thumbnail = self._og_search_thumbnail(webpage) or xpath_text(
  67. video, './/cover', 'cover')
  68. duration = int_or_none(xpath_text(video, './/time', 'duration'))
  69. age_limit = int_or_none(xpath_text(video, './/age18', 'age limit'))
  70. return {
  71. 'id': video_id,
  72. 'title': title,
  73. 'description': description,
  74. 'thumbnail': thumbnail,
  75. 'duration': duration,
  76. 'age_limit': age_limit,
  77. 'formats': formats,
  78. }