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.

60 lines
1.9 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. _TEST = {
  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. def _real_extract(self, url):
  20. video_id = self._match_id(url)
  21. webpage = self._download_webpage(url, video_id)
  22. stream_key = self._html_search_regex(
  23. r'''var\s+stream_key\s*=\s*['"](.+?)['"]''',
  24. webpage, 'stream key')
  25. formats = [{
  26. 'url': 'http://spankbang.com/_%s/%s/title/%sp__mp4' % (video_id, stream_key, height),
  27. 'ext': 'mp4',
  28. 'format_id': '%sp' % height,
  29. 'height': int(height),
  30. } for height in re.findall(r'<span[^>]+q_(\d+)p', webpage)]
  31. self._sort_formats(formats)
  32. title = self._html_search_regex(
  33. r'(?s)<h1>(.+?)</h1>', webpage, 'title')
  34. description = self._search_regex(
  35. r'class="desc"[^>]*>([^<]+)',
  36. webpage, 'description', default=None)
  37. thumbnail = self._og_search_thumbnail(webpage)
  38. uploader = self._search_regex(
  39. r'class="user"[^>]*>([^<]+)',
  40. webpage, 'uploader', fatal=False)
  41. age_limit = self._rta_search(webpage)
  42. return {
  43. 'id': video_id,
  44. 'title': title,
  45. 'description': description,
  46. 'thumbnail': thumbnail,
  47. 'uploader': uploader,
  48. 'formats': formats,
  49. 'age_limit': age_limit,
  50. }