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.

72 lines
2.4 KiB

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 (
  6. int_or_none,
  7. js_to_json,
  8. qualities,
  9. )
  10. class PornHdIE(InfoExtractor):
  11. _VALID_URL = r'http://(?:www\.)?pornhd\.com/(?:[a-z]{2,4}/)?videos/(?P<id>\d+)(?:/(?P<display_id>.+))?'
  12. _TEST = {
  13. 'url': 'http://www.pornhd.com/videos/1962/sierra-day-gets-his-cum-all-over-herself-hd-porn-video',
  14. 'md5': '956b8ca569f7f4d8ec563e2c41598441',
  15. 'info_dict': {
  16. 'id': '1962',
  17. 'display_id': 'sierra-day-gets-his-cum-all-over-herself-hd-porn-video',
  18. 'ext': 'mp4',
  19. 'title': 'Sierra loves doing laundry',
  20. 'description': 'md5:8ff0523848ac2b8f9b065ba781ccf294',
  21. 'thumbnail': 're:^https?://.*\.jpg',
  22. 'view_count': int,
  23. 'age_limit': 18,
  24. }
  25. }
  26. def _real_extract(self, url):
  27. mobj = re.match(self._VALID_URL, url)
  28. video_id = mobj.group('id')
  29. display_id = mobj.group('display_id')
  30. webpage = self._download_webpage(url, display_id or video_id)
  31. title = self._html_search_regex(
  32. [r'<span[^>]+class=["\']video-name["\'][^>]*>([^<]+)',
  33. r'<title>(.+?) - .*?[Pp]ornHD.*?</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. sources = json.loads(js_to_json(self._search_regex(
  42. r"(?s)'sources'\s*:\s*(\{.+?\})\s*\}[;,)]",
  43. webpage, 'sources')))
  44. formats = []
  45. for qname, video_url in sources.items():
  46. if not video_url:
  47. continue
  48. formats.append({
  49. 'url': video_url,
  50. 'format_id': qname,
  51. 'quality': quality(qname),
  52. })
  53. self._sort_formats(formats)
  54. return {
  55. 'id': video_id,
  56. 'display_id': display_id,
  57. 'title': title,
  58. 'description': description,
  59. 'thumbnail': thumbnail,
  60. 'view_count': view_count,
  61. 'formats': formats,
  62. 'age_limit': 18,
  63. }