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.

99 lines
3.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. _TEST = {
  11. 'url': 'http://www.vporn.com/masturbation/violet-on-her-th-birthday/497944/',
  12. 'md5': 'facf37c1b86546fa0208058546842c55',
  13. 'info_dict': {
  14. 'id': '497944',
  15. 'display_id': 'violet-on-her-th-birthday',
  16. 'ext': 'mp4',
  17. 'title': 'Violet on her 19th birthday',
  18. 'description': 'Violet dances in front of the camera which is sure to get you horny.',
  19. 'thumbnail': 're:^https?://.*\.jpg$',
  20. 'uploader': 'kileyGrope',
  21. 'categories': ['Masturbation', 'Teen'],
  22. 'duration': 393,
  23. 'age_limit': 18,
  24. }
  25. }
  26. def _real_extract(self, url):
  27. mobj = re.match(self._VALID_URL, url)
  28. video_id = mobj.group('id')
  29. display_id = mobj.group('display_id')
  30. webpage = self._download_webpage(url, display_id)
  31. title = self._html_search_regex(
  32. r'videoname\s*=\s*\'([^\']+)\'', webpage, 'title').strip()
  33. description = self._html_search_regex(
  34. r'<div class="description_txt">(.*?)</div>', webpage, 'description', fatal=False)
  35. thumbnail = self._html_search_regex(
  36. r'flashvars\.imageUrl\s*=\s*"([^"]+)"', webpage, 'description', fatal=False, default=None)
  37. if thumbnail:
  38. thumbnail = 'http://www.vporn.com' + thumbnail
  39. uploader = self._html_search_regex(
  40. r'(?s)UPLOADED BY.*?<a href="/user/[^"]+">([^<]+)</a>',
  41. webpage, 'uploader', fatal=False)
  42. categories = re.findall(r'<a href="/cat/[^"]+">([^<]+)</a>', webpage)
  43. duration = parse_duration(self._search_regex(
  44. r'duration (\d+ min \d+ sec)', webpage, 'duration', fatal=False))
  45. view_count = str_to_int(self._html_search_regex(
  46. r'<span>([\d,\.]+) VIEWS</span>', webpage, 'view count', fatal=False))
  47. like_count = str_to_int(self._html_search_regex(
  48. r'<span id="like" class="n">([\d,\.]+)</span>', webpage, 'like count', fatal=False))
  49. dislike_count = str_to_int(self._html_search_regex(
  50. r'<span id="dislike" class="n">([\d,\.]+)</span>', webpage, 'dislike count', fatal=False))
  51. comment_count = str_to_int(self._html_search_regex(
  52. r'<h4>Comments \(<b>([\d,\.]+)</b>\)</h4>', webpage, 'comment count', fatal=False))
  53. formats = []
  54. for video in re.findall(r'flashvars\.videoUrl([^=]+?)\s*=\s*"([^"]+)"', webpage):
  55. video_url = video[1]
  56. fmt = {
  57. 'url': video_url,
  58. 'format_id': video[0],
  59. }
  60. m = re.search(r'_(?P<width>\d+)x(?P<height>\d+)_(?P<vbr>\d+)k\.mp4$', video_url)
  61. if m:
  62. fmt.update({
  63. 'width': int(m.group('width')),
  64. 'height': int(m.group('height')),
  65. 'vbr': int(m.group('vbr')),
  66. })
  67. formats.append(fmt)
  68. self._sort_formats(formats)
  69. return {
  70. 'id': video_id,
  71. 'display_id': display_id,
  72. 'title': title,
  73. 'description': description,
  74. 'thumbnail': thumbnail,
  75. 'uploader': uploader,
  76. 'categories': categories,
  77. 'duration': duration,
  78. 'view_count': view_count,
  79. 'like_count': like_count,
  80. 'dislike_count': dislike_count,
  81. 'comment_count': comment_count,
  82. 'age_limit': 18,
  83. 'formats': formats,
  84. }