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.

65 lines
2.1 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. class SpankBangIE(InfoExtractor):
  5. _VALID_URL = r'https?://(?:(?:www|[a-z]{2})\.)?spankbang\.com/(?P<id>[\da-z]+)/video'
  6. _TESTS = [{
  7. 'url': 'http://spankbang.com/3vvn/video/fantasy+solo',
  8. 'md5': '1cc433e1d6aa14bc376535b8679302f7',
  9. 'info_dict': {
  10. 'id': '3vvn',
  11. 'ext': 'mp4',
  12. 'title': 'fantasy solo',
  13. 'description': 'dillion harper masturbates on a bed',
  14. 'thumbnail': 're:^https?://.*\.jpg$',
  15. 'uploader': 'silly2587',
  16. 'age_limit': 18,
  17. }
  18. }, {
  19. # 480p only
  20. 'url': 'http://spankbang.com/1vt0/video/solvane+gangbang',
  21. 'only_matching': True,
  22. }]
  23. def _real_extract(self, url):
  24. video_id = self._match_id(url)
  25. webpage = self._download_webpage(url, video_id)
  26. stream_key = self._html_search_regex(
  27. r'''var\s+stream_key\s*=\s*['"](.+?)['"]''',
  28. webpage, 'stream key')
  29. formats = [{
  30. 'url': 'http://spankbang.com/_%s/%s/title/%sp__mp4' % (video_id, stream_key, height),
  31. 'ext': 'mp4',
  32. 'format_id': '%sp' % height,
  33. 'height': int(height),
  34. } for height in re.findall(r'<(?:span|li|p)[^>]+[qb]_(\d+)p', webpage)]
  35. self._check_formats(formats, video_id)
  36. self._sort_formats(formats)
  37. title = self._html_search_regex(
  38. r'(?s)<h1[^>]*>(.+?)</h1>', webpage, 'title')
  39. description = self._search_regex(
  40. r'class="desc"[^>]*>([^<]+)',
  41. webpage, 'description', default=None)
  42. thumbnail = self._og_search_thumbnail(webpage)
  43. uploader = self._search_regex(
  44. r'class="user"[^>]*>([^<]+)',
  45. webpage, 'uploader', fatal=False)
  46. age_limit = self._rta_search(webpage)
  47. return {
  48. 'id': video_id,
  49. 'title': title,
  50. 'description': description,
  51. 'thumbnail': thumbnail,
  52. 'uploader': uploader,
  53. 'formats': formats,
  54. 'age_limit': age_limit,
  55. }