eporner.py 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. try:
  31. view_count = int(mobj.group('units'))
  32. view_count += int(mobj.group('thousands')) * 1000
  33. except:
  34. pass
  35. return {
  36. 'id': video_id,
  37. 'url': video_url,
  38. 'title': title,
  39. 'duration': int_or_none(duration),
  40. 'view_count': int_or_none(view_count),
  41. }