eporner.py 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import int_or_none
  6. class EpornerIE(InfoExtractor):
  7. _VALID_URL = r'http?://(?:www\.)?eporner\.com/hd-porn/(?P<id>\d+)/(?P<title_dash>[\w-]+)/?'
  8. _TEST = {
  9. 'url': 'http://www.eporner.com/hd-porn/95008/Infamous-Tiffany-Teen-Strip-Tease-Video/',
  10. 'md5': '3b427ae4b9d60619106de3185c2987cd',
  11. 'info_dict': {
  12. 'id': '95008',
  13. 'ext': 'flv',
  14. 'title': 'Infamous Tiffany Teen Strip Tease Video',
  15. 'duration': 194
  16. }
  17. }
  18. def _real_extract(self, url):
  19. mobj = re.match(self._VALID_URL, url)
  20. video_id = mobj.group('id')
  21. webpage = self._download_webpage(url, video_id)
  22. title = self._html_search_regex(r'<title>(.*?) - EPORNER', webpage, 'title')
  23. redirect_code = self._html_search_regex(r'<script type="text/javascript" src="/config5/'+str(video_id)+'/([a-f\d]+)/">', webpage, 'redirect_code')
  24. redirect_url = 'http://www.eporner.com/config5/' + str(video_id) +'/'+ redirect_code
  25. webpage2 = self._download_webpage(redirect_url, video_id)
  26. video_url = self._html_search_regex(r'file: "(.*?)",', webpage2, 'video_url')
  27. mobj = re.search(r'class="mbtim">(?P<minutes>\d+):(?P<seconds>\d+)</div>', webpage)
  28. duration = int(mobj.group('minutes')) * 60 + int(mobj.group('seconds')) if mobj else None
  29. mobj = re.search(r'id="cinemaviews">((?P<thousands>\d+),)?(?P<units>\d+)<small>views', webpage)
  30. view_count = int(mobj.group('thousands')) * 1000 + int(mobj.group('units')) if mobj else None
  31. return {
  32. 'id': video_id,
  33. 'url': video_url,
  34. 'title': title,
  35. 'duration': int_or_none(duration),
  36. 'view_count': int_or_none(view_count),
  37. }