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.

96 lines
3.2 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. parse_resolution,
  8. str_to_int,
  9. )
  10. class SpankBangIE(InfoExtractor):
  11. _VALID_URL = r'https?://(?:(?:www|m|[a-z]{2})\.)?spankbang\.com/(?P<id>[\da-z]+)/video'
  12. _TESTS = [{
  13. 'url': 'http://spankbang.com/3vvn/video/fantasy+solo',
  14. 'md5': '1cc433e1d6aa14bc376535b8679302f7',
  15. 'info_dict': {
  16. 'id': '3vvn',
  17. 'ext': 'mp4',
  18. 'title': 'fantasy solo',
  19. 'description': 'dillion harper masturbates on a bed',
  20. 'thumbnail': r're:^https?://.*\.jpg$',
  21. 'uploader': 'silly2587',
  22. 'age_limit': 18,
  23. }
  24. }, {
  25. # 480p only
  26. 'url': 'http://spankbang.com/1vt0/video/solvane+gangbang',
  27. 'only_matching': True,
  28. }, {
  29. # no uploader
  30. 'url': 'http://spankbang.com/lklg/video/sex+with+anyone+wedding+edition+2',
  31. 'only_matching': True,
  32. }, {
  33. # mobile page
  34. 'url': 'http://m.spankbang.com/1o2de/video/can+t+remember+her+name',
  35. 'only_matching': True,
  36. }, {
  37. # 4k
  38. 'url': 'https://spankbang.com/1vwqx/video/jade+kush+solo+4k',
  39. 'only_matching': True,
  40. }]
  41. def _real_extract(self, url):
  42. video_id = self._match_id(url)
  43. webpage = self._download_webpage(url, video_id, headers={
  44. 'Cookie': 'country=US'
  45. })
  46. if re.search(r'<[^>]+\bid=["\']video_removed', webpage):
  47. raise ExtractorError(
  48. 'Video %s is not available' % video_id, expected=True)
  49. formats = []
  50. for mobj in re.finditer(
  51. r'stream_url_(?P<id>[^\s=]+)\s*=\s*(["\'])(?P<url>(?:(?!\2).)+)\2',
  52. webpage):
  53. format_id, format_url = mobj.group('id', 'url')
  54. f = parse_resolution(format_id)
  55. f.update({
  56. 'url': format_url,
  57. 'format_id': format_id,
  58. })
  59. formats.append(f)
  60. self._sort_formats(formats)
  61. title = self._html_search_regex(
  62. r'(?s)<h1[^>]*>(.+?)</h1>', webpage, 'title')
  63. description = self._search_regex(
  64. r'<div[^>]+\bclass=["\']bottom[^>]+>\s*<p>[^<]*</p>\s*<p>([^<]+)',
  65. webpage, 'description', fatal=False)
  66. thumbnail = self._og_search_thumbnail(webpage)
  67. uploader = self._search_regex(
  68. r'class="user"[^>]*><img[^>]+>([^<]+)',
  69. webpage, 'uploader', default=None)
  70. duration = parse_duration(self._search_regex(
  71. r'<div[^>]+\bclass=["\']right_side[^>]+>\s*<span>([^<]+)',
  72. webpage, 'duration', fatal=False))
  73. view_count = str_to_int(self._search_regex(
  74. r'([\d,.]+)\s+plays', webpage, 'view count', fatal=False))
  75. age_limit = self._rta_search(webpage)
  76. return {
  77. 'id': video_id,
  78. 'title': title,
  79. 'description': description,
  80. 'thumbnail': thumbnail,
  81. 'uploader': uploader,
  82. 'duration': duration,
  83. 'view_count': view_count,
  84. 'formats': formats,
  85. 'age_limit': age_limit,
  86. }