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.

56 lines
1.8 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import (
  6. int_or_none,
  7. parse_duration,
  8. )
  9. class HornBunnyIE(InfoExtractor):
  10. _VALID_URL = r'http?://(?:www\.)?hornbunny\.com/videos/(?P<title_dash>[a-z-]+)-(?P<id>\d+)\.html'
  11. _TEST = {
  12. 'url': 'http://hornbunny.com/videos/panty-slut-jerk-off-instruction-5227.html',
  13. 'md5': '95e40865aedd08eff60272b704852ad7',
  14. 'info_dict': {
  15. 'id': '5227',
  16. 'ext': 'flv',
  17. 'title': 'panty slut jerk off instruction',
  18. 'duration': 550,
  19. 'age_limit': 18,
  20. }
  21. }
  22. def _real_extract(self, url):
  23. mobj = re.match(self._VALID_URL, url)
  24. video_id = mobj.group('id')
  25. webpage = self._download_webpage(
  26. url, video_id, note='Downloading initial webpage')
  27. title = self._html_search_regex(
  28. r'class="title">(.*?)</h2>', webpage, 'title')
  29. redirect_url = self._html_search_regex(
  30. r'pg&settings=(.*?)\|0"\);', webpage, 'title')
  31. webpage2 = self._download_webpage(redirect_url, video_id)
  32. video_url = self._html_search_regex(
  33. r'flvMask:(.*?);', webpage2, 'video_url')
  34. duration = parse_duration(self._search_regex(
  35. r'<strong>Runtime:</strong>\s*([0-9:]+)</div>',
  36. webpage, 'duration', fatal=False))
  37. view_count = int_or_none(self._search_regex(
  38. r'<strong>Views:</strong>\s*(\d+)</div>',
  39. webpage, 'view count', fatal=False))
  40. return {
  41. 'id': video_id,
  42. 'url': video_url,
  43. 'title': title,
  44. 'ext': 'flv',
  45. 'duration': duration,
  46. 'view_count': view_count,
  47. 'age_limit': 18,
  48. }