logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

porn91.py (2116B)


  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. video_link_url = self._search_regex(
  34. r'<textarea[^>]+id=["\']fm-video_link[^>]+>([^<]+)</textarea>',
  35. webpage, 'video link')
  36. videopage = self._download_webpage(video_link_url, video_id)
  37. info_dict = self._parse_html5_media_entries(url, videopage, video_id)[0]
  38. duration = parse_duration(self._search_regex(
  39. r'时长:\s*</span>\s*(\d+:\d+)', webpage, 'duration', fatal=False))
  40. comment_count = int_or_none(self._search_regex(
  41. r'留言:\s*</span>\s*(\d+)', webpage, 'comment count', fatal=False))
  42. info_dict.update({
  43. 'id': video_id,
  44. 'title': title,
  45. 'duration': duration,
  46. 'comment_count': comment_count,
  47. 'age_limit': self._rta_search(webpage),
  48. })
  49. return info_dict