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.

58 lines
1.8 KiB

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