spankbang.py 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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|[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 - dillion harper masturbates on a bed free adult movies.',
  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. def _real_extract(self, url):
  29. video_id = self._match_id(url)
  30. webpage = self._download_webpage(url, video_id)
  31. if re.search(r'<[^>]+\bid=["\']video_removed', webpage):
  32. raise ExtractorError(
  33. 'Video %s is not available' % video_id, expected=True)
  34. stream_key = self._html_search_regex(
  35. r'''var\s+stream_key\s*=\s*['"](.+?)['"]''',
  36. webpage, 'stream key')
  37. formats = [{
  38. 'url': 'http://spankbang.com/_%s/%s/title/%sp__mp4' % (video_id, stream_key, height),
  39. 'ext': 'mp4',
  40. 'format_id': '%sp' % height,
  41. 'height': int(height),
  42. } for height in re.findall(r'<(?:span|li|p)[^>]+[qb]_(\d+)p', webpage)]
  43. self._check_formats(formats, video_id)
  44. self._sort_formats(formats)
  45. title = self._html_search_regex(
  46. r'(?s)<h1[^>]*>(.+?)</h1>', webpage, 'title')
  47. description = self._og_search_description(webpage)
  48. thumbnail = self._og_search_thumbnail(webpage)
  49. uploader = self._search_regex(
  50. r'class="user"[^>]*><img[^>]+>([^<]+)',
  51. webpage, 'uploader', default=None)
  52. age_limit = self._rta_search(webpage)
  53. return {
  54. 'id': video_id,
  55. 'title': title,
  56. 'description': description,
  57. 'thumbnail': thumbnail,
  58. 'uploader': uploader,
  59. 'formats': formats,
  60. 'age_limit': age_limit,
  61. }