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.

81 lines
2.7 KiB

10 years ago
11 years ago
10 years ago
10 years ago
10 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._og_search_title(webpage)
  24. TITLE_SUFFIX = ' porn HD Video | PornHD.com '
  25. if title.endswith(TITLE_SUFFIX):
  26. title = title[:-len(TITLE_SUFFIX)]
  27. description = self._html_search_regex(
  28. r'<div class="description">([^<]+)</div>', webpage, 'description', fatal=False)
  29. view_count = int_or_none(self._html_search_regex(
  30. r'(\d+) views </span>', webpage, 'view count', fatal=False))
  31. formats = [
  32. {
  33. 'url': format_url,
  34. 'ext': format.lower(),
  35. 'format_id': '%s-%s' % (format.lower(), quality.lower()),
  36. 'quality': 1 if quality.lower() == 'high' else 0,
  37. } for format, quality, format_url in re.findall(
  38. r'var __video([\da-zA-Z]+?)(Low|High)StreamUrl = \'(http://.+?)\?noProxy=1\'', webpage)
  39. ]
  40. mobj = re.search(r'flashVars = (?P<flashvars>{.+?});', webpage)
  41. if mobj:
  42. flashvars = json.loads(mobj.group('flashvars'))
  43. formats.extend([
  44. {
  45. 'url': flashvars['hashlink'].replace('?noProxy=1', ''),
  46. 'ext': 'flv',
  47. 'format_id': 'flv-low',
  48. 'quality': 0,
  49. },
  50. {
  51. 'url': flashvars['hd'].replace('?noProxy=1', ''),
  52. 'ext': 'flv',
  53. 'format_id': 'flv-high',
  54. 'quality': 1,
  55. }
  56. ])
  57. thumbnail = flashvars['urlWallpaper']
  58. else:
  59. thumbnail = self._og_search_thumbnail(webpage)
  60. self._sort_formats(formats)
  61. return {
  62. 'id': video_id,
  63. 'title': title,
  64. 'description': description,
  65. 'thumbnail': thumbnail,
  66. 'view_count': view_count,
  67. 'formats': formats,
  68. 'age_limit': 18,
  69. }