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.5 KiB

9 years ago
9 years ago
  1. # encoding: utf-8
  2. from __future__ import unicode_literals
  3. from ..compat import compat_urllib_parse
  4. from .common import InfoExtractor
  5. from ..utils import (
  6. parse_duration,
  7. int_or_none,
  8. ExtractorError,
  9. )
  10. class Porn91IE(InfoExtractor):
  11. IE_NAME = '91porn'
  12. _VALID_URL = r'(?:https?://)(?:www\.|)91porn\.com/.+?\?viewkey=(?P<id>[\w\d]+)'
  13. _TEST = {
  14. 'url': 'http://91porn.com/view_video.php?viewkey=7e42283b4f5ab36da134',
  15. 'md5': '6df8f6d028bc8b14f5dbd73af742fb20',
  16. 'info_dict': {
  17. 'id': '7e42283b4f5ab36da134',
  18. 'title': '18岁大一漂亮学妹,水嫩性感,再爽一次!',
  19. 'ext': 'mp4',
  20. 'duration': 431,
  21. }
  22. }
  23. def _real_extract(self, url):
  24. video_id = self._match_id(url)
  25. url = 'http://91porn.com/view_video.php?viewkey=%s' % video_id
  26. self._set_cookie('91porn.com', 'language', 'cn_CN')
  27. webpage = self._download_webpage(url, video_id, 'get HTML content')
  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. # get real url
  34. file_id = self._search_regex(
  35. r'so.addVariable\(\'file\',\'(\d+)\'', webpage, 'file id')
  36. sec_code = self._search_regex(
  37. r'so.addVariable\(\'seccode\',\'([^\']+)\'', webpage, 'sec code')
  38. max_vid = self._search_regex(
  39. r'so.addVariable\(\'max_vid\',\'(\d+)\'', webpage, 'max vid')
  40. url_params = compat_urllib_parse.urlencode({
  41. 'VID': file_id,
  42. 'mp4': '1',
  43. 'seccode': sec_code,
  44. 'max_vid': max_vid,
  45. })
  46. info_cn = self._download_webpage(
  47. 'http://91porn.com/getfile.php?' + url_params, video_id,
  48. 'get real video url')
  49. video_url = self._search_regex(r'file=([^&]+)&', info_cn, 'url')
  50. duration = parse_duration(self._search_regex(
  51. r'时长:\s*</span>\s*(\d+:\d+)', webpage, 'duration', fatal=False))
  52. comment_count = int_or_none(self._search_regex(
  53. r'留言:\s*</span>\s*(\d+)', webpage, 'comment count', fatal=False))
  54. return {
  55. 'id': video_id,
  56. 'title': title,
  57. 'url': video_url,
  58. 'duration': duration,
  59. 'comment_count': comment_count,
  60. }