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.

117 lines
4.1 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. }
  27. },
  28. {
  29. 'url': 'http://www.vporn.com/female/hana-shower/523564/',
  30. 'md5': 'ced35a4656198a1664cf2cda1575a25f',
  31. 'info_dict': {
  32. 'id': '523564',
  33. 'display_id': 'hana-shower',
  34. 'ext': 'mp4',
  35. 'title': 'Hana Shower',
  36. 'description': 'Hana showers at the bathroom.',
  37. 'thumbnail': 're:^https?://.*\.jpg$',
  38. 'uploader': 'Hmmmmm',
  39. 'categories': ['Big Boobs', 'Erotic', 'Teen', 'Female'],
  40. 'duration': 588,
  41. 'age_limit': 18,
  42. 'view_count': int,
  43. }
  44. },
  45. ]
  46. def _real_extract(self, url):
  47. mobj = re.match(self._VALID_URL, url)
  48. video_id = mobj.group('id')
  49. display_id = mobj.group('display_id')
  50. webpage = self._download_webpage(url, display_id)
  51. title = self._html_search_regex(
  52. r'videoname\s*=\s*\'([^\']+)\'', webpage, 'title').strip()
  53. description = self._html_search_regex(
  54. r'class="(?:descr|description_txt)">(.*?)</div>',
  55. webpage, 'description', fatal=False)
  56. thumbnail = self._html_search_regex(
  57. r'flashvars\.imageUrl\s*=\s*"([^"]+)"', webpage, 'description', fatal=False, default=None)
  58. if thumbnail:
  59. thumbnail = 'http://www.vporn.com' + thumbnail
  60. uploader = self._html_search_regex(
  61. r'(?s)Uploaded by:.*?<a href="/user/[^"]+"[^>]*>(.+?)</a>',
  62. webpage, 'uploader', fatal=False)
  63. categories = re.findall(r'<a href="/cat/[^"]+"[^>]*>([^<]+)</a>', webpage)
  64. duration = parse_duration(self._search_regex(
  65. r'Runtime:\s*</span>\s*(\d+ min \d+ sec)',
  66. webpage, 'duration', fatal=False))
  67. view_count = str_to_int(self._search_regex(
  68. r'class="views">([\d,\.]+) [Vv]iews<',
  69. webpage, 'view count', fatal=False))
  70. comment_count = str_to_int(self._html_search_regex(
  71. r"'Comments \(([\d,\.]+)\)'",
  72. webpage, 'comment count', default=None))
  73. formats = []
  74. for video in re.findall(r'flashvars\.videoUrl([^=]+?)\s*=\s*"(https?://[^"]+)"', webpage):
  75. video_url = video[1]
  76. fmt = {
  77. 'url': video_url,
  78. 'format_id': video[0],
  79. }
  80. m = re.search(r'_(?P<width>\d+)x(?P<height>\d+)_(?P<vbr>\d+)k\.mp4$', video_url)
  81. if m:
  82. fmt.update({
  83. 'width': int(m.group('width')),
  84. 'height': int(m.group('height')),
  85. 'vbr': int(m.group('vbr')),
  86. })
  87. formats.append(fmt)
  88. self._sort_formats(formats)
  89. return {
  90. 'id': video_id,
  91. 'display_id': display_id,
  92. 'title': title,
  93. 'description': description,
  94. 'thumbnail': thumbnail,
  95. 'uploader': uploader,
  96. 'categories': categories,
  97. 'duration': duration,
  98. 'view_count': view_count,
  99. 'comment_count': comment_count,
  100. 'age_limit': 18,
  101. 'formats': formats,
  102. }