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.

71 lines
2.4 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. )
  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'<title>(.+) porn HD.+?</title>', webpage, 'title')
  33. description = self._html_search_regex(
  34. r'<div class="description">([^<]+)</div>', webpage, 'description', fatal=False)
  35. view_count = int_or_none(self._html_search_regex(
  36. r'(\d+) views\s*</span>', webpage, 'view count', fatal=False))
  37. thumbnail = self._search_regex(
  38. r"'poster'\s*:\s*'([^']+)'", webpage, 'thumbnail', fatal=False)
  39. quality = qualities(['sd', 'hd'])
  40. sources = json.loads(js_to_json(self._search_regex(
  41. r"(?s)'sources'\s*:\s*(\{.+?\})\s*\}[;,)]",
  42. webpage, 'sources')))
  43. formats = []
  44. for qname, video_url in sources.items():
  45. if not video_url:
  46. continue
  47. formats.append({
  48. 'url': video_url,
  49. 'format_id': qname,
  50. 'quality': quality(qname),
  51. })
  52. self._sort_formats(formats)
  53. return {
  54. 'id': video_id,
  55. 'display_id': display_id,
  56. 'title': title,
  57. 'description': description,
  58. 'thumbnail': thumbnail,
  59. 'view_count': view_count,
  60. 'formats': formats,
  61. 'age_limit': 18,
  62. }