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.

66 lines
2.3 KiB

10 years ago
11 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 (
  6. int_or_none,
  7. js_to_json,
  8. qualities,
  9. determine_ext,
  10. )
  11. class PornHdIE(InfoExtractor):
  12. _VALID_URL = r'http://(?:www\.)?pornhd\.com/(?:[a-z]{2,4}/)?videos/(?P<id>\d+)(?:/(?P<display_id>.+))?'
  13. _TEST = {
  14. 'url': 'http://www.pornhd.com/videos/1962/sierra-day-gets-his-cum-all-over-herself-hd-porn-video',
  15. 'md5': '956b8ca569f7f4d8ec563e2c41598441',
  16. 'info_dict': {
  17. 'id': '1962',
  18. 'display_id': 'sierra-day-gets-his-cum-all-over-herself-hd-porn-video',
  19. 'ext': 'mp4',
  20. 'title': 'Sierra loves doing laundry',
  21. 'description': 'md5:8ff0523848ac2b8f9b065ba781ccf294',
  22. 'thumbnail': 're:^https?://.*\.jpg',
  23. 'view_count': int,
  24. 'age_limit': 18,
  25. }
  26. }
  27. def _real_extract(self, url):
  28. mobj = re.match(self._VALID_URL, url)
  29. video_id = mobj.group('id')
  30. display_id = mobj.group('display_id')
  31. webpage = self._download_webpage(url, display_id or video_id)
  32. title = self._html_search_regex(
  33. r'<title>(.+) porn HD.+?</title>', webpage, 'title')
  34. description = self._html_search_regex(
  35. r'<div class="description">([^<]+)</div>', webpage, 'description', fatal=False)
  36. view_count = int_or_none(self._html_search_regex(
  37. r'(\d+) views\s*</span>', webpage, 'view count', fatal=False))
  38. thumbnail = self._search_regex(
  39. r"'poster'\s*:\s*'([^']+)'", webpage, 'thumbnail', fatal=False)
  40. quality = qualities(['SD', 'HD'])
  41. formats = [{
  42. 'url': source['file'],
  43. 'format_id': '%s-%s' % (source['label'], determine_ext(source['file'])),
  44. 'quality': quality(source['label']),
  45. } for source in json.loads(js_to_json(self._search_regex(
  46. r"(?s)'sources'\s*:\s*(\[.+?\])", webpage, 'sources')))]
  47. self._sort_formats(formats)
  48. return {
  49. 'id': video_id,
  50. 'display_id': display_id,
  51. 'title': title,
  52. 'description': description,
  53. 'thumbnail': thumbnail,
  54. 'view_count': view_count,
  55. 'formats': formats,
  56. 'age_limit': 18,
  57. }