twentyfourvideo.py 3.8 KB

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