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.

74 lines
2.6 KiB

11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
  1. from __future__ import unicode_literals
  2. import re
  3. import json
  4. from .common import InfoExtractor
  5. from ..utils import int_or_none
  6. class PornHdIE(InfoExtractor):
  7. _VALID_URL = r'http://(?:www\.)?pornhd\.com/(?:[a-z]{2,4}/)?videos/(?P<id>\d+)'
  8. _TEST = {
  9. 'url': 'http://www.pornhd.com/videos/1962/sierra-day-gets-his-cum-all-over-herself-hd-porn-video',
  10. 'md5': '956b8ca569f7f4d8ec563e2c41598441',
  11. 'info_dict': {
  12. 'id': '1962',
  13. 'ext': 'mp4',
  14. 'title': 'Sierra loves doing laundry',
  15. 'description': 'md5:8ff0523848ac2b8f9b065ba781ccf294',
  16. 'age_limit': 18,
  17. }
  18. }
  19. def _real_extract(self, url):
  20. mobj = re.match(self._VALID_URL, url)
  21. video_id = mobj.group('id')
  22. webpage = self._download_webpage(url, video_id)
  23. title = self._html_search_regex(
  24. r'<title>(.+) porn HD.+?</title>', webpage, 'title')
  25. description = self._html_search_regex(
  26. r'<div class="description">([^<]+)</div>', webpage, 'description', fatal=False)
  27. view_count = int_or_none(self._html_search_regex(
  28. r'(\d+) views\s*</span>', webpage, 'view count', fatal=False))
  29. videos = re.findall(
  30. r'var __video([\da-zA-Z]+?)(Low|High)StreamUrl = \'(http://.+?)\?noProxy=1\'', webpage)
  31. mobj = re.search(r'flashVars = (?P<flashvars>{.+?});', webpage)
  32. if mobj:
  33. flashvars = json.loads(mobj.group('flashvars'))
  34. for key, quality in [('hashlink', 'low'), ('hd', 'high')]:
  35. redirect_url = flashvars.get(key)
  36. if redirect_url:
  37. videos.append(('flv', quality, redirect_url))
  38. thumbnail = flashvars['urlWallpaper']
  39. else:
  40. thumbnail = self._og_search_thumbnail(webpage)
  41. formats = []
  42. for format_, quality, redirect_url in videos:
  43. format_id = '%s-%s' % (format_.lower(), quality.lower())
  44. video_url = self._download_webpage(
  45. redirect_url, video_id, 'Downloading %s video link' % format_id, fatal=False)
  46. if not video_url:
  47. continue
  48. formats.append({
  49. 'url': video_url,
  50. 'ext': format_.lower(),
  51. 'format_id': format_id,
  52. 'quality': 1 if quality.lower() == 'high' else 0,
  53. })
  54. self._sort_formats(formats)
  55. return {
  56. 'id': video_id,
  57. 'title': title,
  58. 'description': description,
  59. 'thumbnail': thumbnail,
  60. 'view_count': view_count,
  61. 'formats': formats,
  62. 'age_limit': 18,
  63. }