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.

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