logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

twentyfourvideo.py (4756B)


  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import (
  6. parse_iso8601,
  7. int_or_none,
  8. xpath_attr,
  9. xpath_element,
  10. )
  11. class TwentyFourVideoIE(InfoExtractor):
  12. IE_NAME = '24video'
  13. _VALID_URL = r'''(?x)
  14. https?://
  15. (?P<host>
  16. (?:(?:www|porno?)\.)?24video\.
  17. (?:net|me|xxx|sexy?|tube|adult|site|vip)
  18. )/
  19. (?:
  20. video/(?:(?:view|xml)/)?|
  21. player/new24_play\.swf\?id=
  22. )
  23. (?P<id>\d+)
  24. '''
  25. _TESTS = [{
  26. 'url': 'http://www.24video.net/video/view/1044982',
  27. 'md5': 'e09fc0901d9eaeedac872f154931deeb',
  28. 'info_dict': {
  29. 'id': '1044982',
  30. 'ext': 'mp4',
  31. 'title': 'Эротика каменного века',
  32. 'description': 'Как смотрели порно в каменном веке.',
  33. 'thumbnail': r're:^https?://.*\.jpg$',
  34. 'uploader': 'SUPERTELO',
  35. 'duration': 31,
  36. 'timestamp': 1275937857,
  37. 'upload_date': '20100607',
  38. 'age_limit': 18,
  39. 'like_count': int,
  40. 'dislike_count': int,
  41. },
  42. }, {
  43. 'url': 'http://www.24video.net/player/new24_play.swf?id=1044982',
  44. 'only_matching': True,
  45. }, {
  46. 'url': 'http://www.24video.me/video/view/1044982',
  47. 'only_matching': True,
  48. }, {
  49. 'url': 'http://www.24video.tube/video/view/2363750',
  50. 'only_matching': True,
  51. }, {
  52. 'url': 'https://www.24video.site/video/view/2640421',
  53. 'only_matching': True,
  54. }, {
  55. 'url': 'https://porno.24video.net/video/2640421-vsya-takaya-gibkaya-i-v-masle',
  56. 'only_matching': True,
  57. }, {
  58. 'url': 'https://www.24video.vip/video/view/1044982',
  59. 'only_matching': True,
  60. }, {
  61. 'url': 'https://porn.24video.net/video/2640421-vsya-takay',
  62. 'only_matching': True,
  63. }]
  64. def _real_extract(self, url):
  65. mobj = re.match(self._VALID_URL, url)
  66. video_id = mobj.group('id')
  67. host = mobj.group('host')
  68. webpage = self._download_webpage(
  69. 'http://%s/video/view/%s' % (host, video_id), video_id)
  70. title = self._og_search_title(webpage)
  71. description = self._html_search_regex(
  72. r'<(p|span)[^>]+itemprop="description"[^>]*>(?P<description>[^<]+)</\1>',
  73. webpage, 'description', fatal=False, group='description')
  74. thumbnail = self._og_search_thumbnail(webpage)
  75. duration = int_or_none(self._og_search_property(
  76. 'duration', webpage, 'duration', fatal=False))
  77. timestamp = parse_iso8601(self._search_regex(
  78. r'<time[^>]+\bdatetime="([^"]+)"[^>]+itemprop="uploadDate"',
  79. webpage, 'upload date', fatal=False))
  80. uploader = self._html_search_regex(
  81. r'class="video-uploaded"[^>]*>\s*<a href="/jsecUser/movies/[^"]+"[^>]*>([^<]+)</a>',
  82. webpage, 'uploader', fatal=False)
  83. view_count = int_or_none(self._html_search_regex(
  84. r'<span class="video-views">(\d+) просмотр',
  85. webpage, 'view count', fatal=False))
  86. comment_count = int_or_none(self._html_search_regex(
  87. r'<a[^>]+href="#tab-comments"[^>]*>(\d+) комментари',
  88. webpage, 'comment count', default=None))
  89. # Sets some cookies
  90. self._download_xml(
  91. r'http://%s/video/xml/%s?mode=init' % (host, video_id),
  92. video_id, 'Downloading init XML')
  93. video_xml = self._download_xml(
  94. 'http://%s/video/xml/%s?mode=play' % (host, video_id),
  95. video_id, 'Downloading video XML')
  96. video = xpath_element(video_xml, './/video', 'video', fatal=True)
  97. formats = [{
  98. 'url': xpath_attr(video, '', 'url', 'video URL', fatal=True),
  99. }]
  100. like_count = int_or_none(video.get('ratingPlus'))
  101. dislike_count = int_or_none(video.get('ratingMinus'))
  102. age_limit = 18 if video.get('adult') == 'true' else 0
  103. return {
  104. 'id': video_id,
  105. 'title': title,
  106. 'description': description,
  107. 'thumbnail': thumbnail,
  108. 'uploader': uploader,
  109. 'duration': duration,
  110. 'timestamp': timestamp,
  111. 'view_count': view_count,
  112. 'comment_count': comment_count,
  113. 'like_count': like_count,
  114. 'dislike_count': dislike_count,
  115. 'age_limit': age_limit,
  116. 'formats': formats,
  117. }