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.

44 lines
1.6 KiB

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