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.

125 lines
4.7 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. parse_duration,
  6. str_to_int,
  7. )
  8. class VpornIE(InfoExtractor):
  9. _VALID_URL = r'https?://(?:www\.)?vporn\.com/[^/]+/(?P<display_id>[^/]+)/(?P<id>\d+)'
  10. _TESTS = [
  11. {
  12. 'url': 'http://www.vporn.com/masturbation/violet-on-her-th-birthday/497944/',
  13. 'md5': 'facf37c1b86546fa0208058546842c55',
  14. 'info_dict': {
  15. 'id': '497944',
  16. 'display_id': 'violet-on-her-th-birthday',
  17. 'ext': 'mp4',
  18. 'title': 'Violet on her 19th birthday',
  19. 'description': 'Violet dances in front of the camera which is sure to get you horny.',
  20. 'thumbnail': 're:^https?://.*\.jpg$',
  21. 'uploader': 'kileyGrope',
  22. 'categories': ['Masturbation', 'Teen'],
  23. 'duration': 393,
  24. 'age_limit': 18,
  25. 'view_count': int,
  26. 'like_count': int,
  27. 'dislike_count': int,
  28. 'comment_count': int,
  29. }
  30. },
  31. {
  32. 'url': 'http://www.vporn.com/female/hana-shower/523564/',
  33. 'md5': 'ced35a4656198a1664cf2cda1575a25f',
  34. 'info_dict': {
  35. 'id': '523564',
  36. 'display_id': 'hana-shower',
  37. 'ext': 'mp4',
  38. 'title': 'Hana Shower',
  39. 'description': 'Hana showers at the bathroom.',
  40. 'thumbnail': 're:^https?://.*\.jpg$',
  41. 'uploader': 'Hmmmmm',
  42. 'categories': ['Big Boobs', 'Erotic', 'Teen', 'Female'],
  43. 'duration': 588,
  44. 'age_limit': 18,
  45. 'view_count': int,
  46. 'like_count': int,
  47. 'dislike_count': int,
  48. 'comment_count': int,
  49. }
  50. },
  51. ]
  52. def _real_extract(self, url):
  53. mobj = re.match(self._VALID_URL, url)
  54. video_id = mobj.group('id')
  55. display_id = mobj.group('display_id')
  56. webpage = self._download_webpage(url, display_id)
  57. title = self._html_search_regex(
  58. r'videoname\s*=\s*\'([^\']+)\'', webpage, 'title').strip()
  59. description = self._html_search_regex(
  60. r'<div class="description_txt">(.*?)</div>', webpage, 'description', fatal=False)
  61. thumbnail = self._html_search_regex(
  62. r'flashvars\.imageUrl\s*=\s*"([^"]+)"', webpage, 'description', fatal=False, default=None)
  63. if thumbnail:
  64. thumbnail = 'http://www.vporn.com' + thumbnail
  65. uploader = self._html_search_regex(
  66. r'(?s)UPLOADED BY.*?<a href="/user/[^"]+">([^<]+)</a>',
  67. webpage, 'uploader', fatal=False)
  68. categories = re.findall(r'<a href="/cat/[^"]+">([^<]+)</a>', webpage)
  69. duration = parse_duration(self._search_regex(
  70. r'duration (\d+ min \d+ sec)', webpage, 'duration', fatal=False))
  71. view_count = str_to_int(self._html_search_regex(
  72. r'<span>([\d,\.]+) VIEWS</span>', webpage, 'view count', fatal=False))
  73. like_count = str_to_int(self._html_search_regex(
  74. r'<span id="like" class="n">([\d,\.]+)</span>', webpage, 'like count', fatal=False))
  75. dislike_count = str_to_int(self._html_search_regex(
  76. r'<span id="dislike" class="n">([\d,\.]+)</span>', webpage, 'dislike count', fatal=False))
  77. comment_count = str_to_int(self._html_search_regex(
  78. r'<h4>Comments \(<b>([\d,\.]+)</b>\)</h4>', webpage, 'comment count', fatal=False))
  79. formats = []
  80. for video in re.findall(r'flashvars\.videoUrl([^=]+?)\s*=\s*"(https?://[^"]+)"', webpage):
  81. video_url = video[1]
  82. fmt = {
  83. 'url': video_url,
  84. 'format_id': video[0],
  85. }
  86. m = re.search(r'_(?P<width>\d+)x(?P<height>\d+)_(?P<vbr>\d+)k\.mp4$', video_url)
  87. if m:
  88. fmt.update({
  89. 'width': int(m.group('width')),
  90. 'height': int(m.group('height')),
  91. 'vbr': int(m.group('vbr')),
  92. })
  93. formats.append(fmt)
  94. self._sort_formats(formats)
  95. return {
  96. 'id': video_id,
  97. 'display_id': display_id,
  98. 'title': title,
  99. 'description': description,
  100. 'thumbnail': thumbnail,
  101. 'uploader': uploader,
  102. 'categories': categories,
  103. 'duration': duration,
  104. 'view_count': view_count,
  105. 'like_count': like_count,
  106. 'dislike_count': dislike_count,
  107. 'comment_count': comment_count,
  108. 'age_limit': 18,
  109. 'formats': formats,
  110. }