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.

109 lines
3.8 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. parse_iso8601,
  6. int_or_none,
  7. )
  8. class TwentyFourVideoIE(InfoExtractor):
  9. IE_NAME = '24video'
  10. _VALID_URL = r'https?://(?:www\.)?24video\.net/(?:video/(?:view|xml)/|player/new24_play\.swf\?id=)(?P<id>\d+)'
  11. _TESTS = [
  12. {
  13. 'url': 'http://www.24video.net/video/view/1044982',
  14. 'md5': 'd041af8b5b4246ea466226a0d6693345',
  15. 'info_dict': {
  16. 'id': '1044982',
  17. 'ext': 'mp4',
  18. 'title': 'Эротика каменного века',
  19. 'description': 'Как смотрели порно в каменном веке.',
  20. 'thumbnail': 're:^https?://.*\.jpg$',
  21. 'uploader': 'SUPERTELO',
  22. 'duration': 31,
  23. 'timestamp': 1275937857,
  24. 'upload_date': '20100607',
  25. 'age_limit': 18,
  26. 'like_count': int,
  27. 'dislike_count': int,
  28. },
  29. },
  30. {
  31. 'url': 'http://www.24video.net/player/new24_play.swf?id=1044982',
  32. 'only_matching': True,
  33. }
  34. ]
  35. def _real_extract(self, url):
  36. video_id = self._match_id(url)
  37. webpage = self._download_webpage(
  38. 'http://www.24video.net/video/view/%s' % video_id, video_id)
  39. title = self._og_search_title(webpage)
  40. description = self._html_search_regex(
  41. r'<span itemprop="description">([^<]+)</span>', webpage, 'description', fatal=False)
  42. thumbnail = self._og_search_thumbnail(webpage)
  43. duration = int_or_none(self._og_search_property(
  44. 'duration', webpage, 'duration', fatal=False))
  45. timestamp = parse_iso8601(self._search_regex(
  46. r'<time id="video-timeago" datetime="([^"]+)" itemprop="uploadDate">',
  47. webpage, 'upload date'))
  48. uploader = self._html_search_regex(
  49. r'class="video-uploaded"[^>]*>\s*<a href="/jsecUser/movies/[^"]+"[^>]*>([^<]+)</a>',
  50. webpage, 'uploader', fatal=False)
  51. view_count = int_or_none(self._html_search_regex(
  52. r'<span class="video-views">(\d+) просмотр',
  53. webpage, 'view count', fatal=False))
  54. comment_count = int_or_none(self._html_search_regex(
  55. r'<div class="comments-title" id="comments-count">(\d+) комментари',
  56. webpage, 'comment count', fatal=False))
  57. formats = []
  58. pc_video = self._download_xml(
  59. 'http://www.24video.net/video/xml/%s?mode=play' % video_id,
  60. video_id, 'Downloading PC video URL').find('.//video')
  61. formats.append({
  62. 'url': pc_video.attrib['url'],
  63. 'format_id': 'pc',
  64. 'quality': 1,
  65. })
  66. like_count = int_or_none(pc_video.get('ratingPlus'))
  67. dislike_count = int_or_none(pc_video.get('ratingMinus'))
  68. age_limit = 18 if pc_video.get('adult') == 'true' else 0
  69. mobile_video = self._download_xml(
  70. 'http://www.24video.net/video/xml/%s' % video_id,
  71. video_id, 'Downloading mobile video URL').find('.//video')
  72. formats.append({
  73. 'url': mobile_video.attrib['url'],
  74. 'format_id': 'mobile',
  75. 'quality': 0,
  76. })
  77. self._sort_formats(formats)
  78. return {
  79. 'id': video_id,
  80. 'title': title,
  81. 'description': description,
  82. 'thumbnail': thumbnail,
  83. 'uploader': uploader,
  84. 'duration': duration,
  85. 'timestamp': timestamp,
  86. 'view_count': view_count,
  87. 'comment_count': comment_count,
  88. 'like_count': like_count,
  89. 'dislike_count': dislike_count,
  90. 'age_limit': age_limit,
  91. 'formats': formats,
  92. }