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.

73 lines
2.6 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. 'age_limit': 18,
  22. }
  23. }
  24. def _real_extract(self, url):
  25. video_id = self._match_id(url)
  26. url = 'http://91porn.com/view_video.php?viewkey=%s' % video_id
  27. self._set_cookie('91porn.com', 'language', 'cn_CN')
  28. webpage = self._download_webpage(url, video_id, 'get HTML content')
  29. if '作为游客,你每天只可观看10个视频' in webpage:
  30. raise ExtractorError('91 Porn says: Daily limit 10 videos exceeded', expected=True)
  31. title = self._search_regex(
  32. r'<div id="viewvideo-title">([^<]+)</div>', webpage, 'title')
  33. title = title.replace('\n', '')
  34. # get real url
  35. file_id = self._search_regex(
  36. r'so.addVariable\(\'file\',\'(\d+)\'', webpage, 'file id')
  37. sec_code = self._search_regex(
  38. r'so.addVariable\(\'seccode\',\'([^\']+)\'', webpage, 'sec code')
  39. max_vid = self._search_regex(
  40. r'so.addVariable\(\'max_vid\',\'(\d+)\'', webpage, 'max vid')
  41. url_params = compat_urllib_parse.urlencode({
  42. 'VID': file_id,
  43. 'mp4': '1',
  44. 'seccode': sec_code,
  45. 'max_vid': max_vid,
  46. })
  47. info_cn = self._download_webpage(
  48. 'http://91porn.com/getfile.php?' + url_params, video_id,
  49. 'get real video url')
  50. video_url = self._search_regex(r'file=([^&]+)&', info_cn, 'url')
  51. duration = parse_duration(self._search_regex(
  52. r'时长:\s*</span>\s*(\d+:\d+)', webpage, 'duration', fatal=False))
  53. comment_count = int_or_none(self._search_regex(
  54. r'留言:\s*</span>\s*(\d+)', webpage, 'comment count', fatal=False))
  55. return {
  56. 'id': video_id,
  57. 'title': title,
  58. 'url': video_url,
  59. 'duration': duration,
  60. 'comment_count': comment_count,
  61. 'age_limit': self._rta_search(webpage),
  62. }