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.

123 lines
4.4 KiB

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