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.

76 lines
2.6 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import ExtractorError
  5. class SpankBangIE(InfoExtractor):
  6. _VALID_URL = r'https?://(?:(?:www|m|[a-z]{2})\.)?spankbang\.com/(?P<id>[\da-z]+)/video'
  7. _TESTS = [{
  8. 'url': 'http://spankbang.com/3vvn/video/fantasy+solo',
  9. 'md5': '1cc433e1d6aa14bc376535b8679302f7',
  10. 'info_dict': {
  11. 'id': '3vvn',
  12. 'ext': 'mp4',
  13. 'title': 'fantasy solo',
  14. 'description': 'Watch fantasy solo free HD porn video - 05 minutes - Babe,Masturbation,Solo,Toy - dillion harper masturbates on a bed free adult movies sexy clips.',
  15. 'thumbnail': r're:^https?://.*\.jpg$',
  16. 'uploader': 'silly2587',
  17. 'age_limit': 18,
  18. }
  19. }, {
  20. # 480p only
  21. 'url': 'http://spankbang.com/1vt0/video/solvane+gangbang',
  22. 'only_matching': True,
  23. }, {
  24. # no uploader
  25. 'url': 'http://spankbang.com/lklg/video/sex+with+anyone+wedding+edition+2',
  26. 'only_matching': True,
  27. }, {
  28. # mobile page
  29. 'url': 'http://m.spankbang.com/1o2de/video/can+t+remember+her+name',
  30. 'only_matching': True,
  31. }]
  32. def _real_extract(self, url):
  33. video_id = self._match_id(url)
  34. webpage = self._download_webpage(url, video_id)
  35. if re.search(r'<[^>]+\bid=["\']video_removed', webpage):
  36. raise ExtractorError(
  37. 'Video %s is not available' % video_id, expected=True)
  38. stream_key = self._html_search_regex(
  39. r'''var\s+stream_key\s*=\s*['"](.+?)['"]''',
  40. webpage, 'stream key')
  41. formats = [{
  42. 'url': 'http://spankbang.com/_%s/%s/title/%sp__mp4' % (video_id, stream_key, height),
  43. 'ext': 'mp4',
  44. 'format_id': '%sp' % height,
  45. 'height': int(height),
  46. } for height in re.findall(r'<(?:span|li|p)[^>]+[qb]_(\d+)p', webpage)]
  47. self._check_formats(formats, video_id)
  48. self._sort_formats(formats)
  49. title = self._html_search_regex(
  50. r'(?s)<h1[^>]*>(.+?)</h1>', webpage, 'title')
  51. description = self._og_search_description(webpage)
  52. thumbnail = self._og_search_thumbnail(webpage)
  53. uploader = self._search_regex(
  54. r'class="user"[^>]*><img[^>]+>([^<]+)',
  55. webpage, 'uploader', default=None)
  56. age_limit = self._rta_search(webpage)
  57. return {
  58. 'id': video_id,
  59. 'title': title,
  60. 'description': description,
  61. 'thumbnail': thumbnail,
  62. 'uploader': uploader,
  63. 'formats': formats,
  64. 'age_limit': age_limit,
  65. }