porn91.py 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. from .common import InfoExtractor
  2. from ..utils import (
  3. parse_duration,
  4. int_or_none,
  5. ExtractorError,
  6. )
  7. class Porn91IE(InfoExtractor):
  8. IE_NAME = '91porn'
  9. _VALID_URL = r'(?:https?://)(?:www\.|)91porn\.com/.+?\?viewkey=(?P<id>[\w\d]+)'
  10. _TEST = {
  11. 'url': 'http://91porn.com/view_video.php?viewkey=7e42283b4f5ab36da134',
  12. 'md5': '7fcdb5349354f40d41689bd0fa8db05a',
  13. 'info_dict': {
  14. 'id': '7e42283b4f5ab36da134',
  15. 'title': '18岁大一漂亮学妹,水嫩性感,再爽一次!',
  16. 'ext': 'mp4',
  17. 'duration': 431,
  18. 'age_limit': 18,
  19. }
  20. }
  21. def _real_extract(self, url):
  22. video_id = self._match_id(url)
  23. self._set_cookie('91porn.com', 'language', 'cn_CN')
  24. webpage = self._download_webpage(
  25. 'http://91porn.com/view_video.php?viewkey=%s' % video_id, video_id)
  26. if '作为游客,你每天只可观看10个视频' in webpage:
  27. raise ExtractorError('91 Porn says: Daily limit 10 videos exceeded', expected=True)
  28. title = self._search_regex(
  29. r'<div id="viewvideo-title">([^<]+)</div>', webpage, 'title')
  30. title = title.replace('\n', '')
  31. video_link_url = self._search_regex(
  32. r'<textarea[^>]+id=["\']fm-video_link[^>]+>([^<]+)</textarea>',
  33. webpage, 'video link')
  34. videopage = self._download_webpage(video_link_url, video_id)
  35. info_dict = self._parse_html5_media_entries(url, videopage, video_id)[0]
  36. duration = parse_duration(self._search_regex(
  37. r'时长:\s*</span>\s*(\d+:\d+)', webpage, 'duration', fatal=False))
  38. comment_count = int_or_none(self._search_regex(
  39. r'留言:\s*</span>\s*(\d+)', webpage, 'comment count', fatal=False))
  40. info_dict.update({
  41. 'id': video_id,
  42. 'title': title,
  43. 'duration': duration,
  44. 'comment_count': comment_count,
  45. 'age_limit': self._rta_search(webpage),
  46. })
  47. return info_dict