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.

75 lines
2.5 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import (
  6. parse_duration,
  7. str_to_int,
  8. )
  9. class EpornerIE(InfoExtractor):
  10. _VALID_URL = r'https?://(?:www\.)?eporner\.com/hd-porn/(?P<id>\d+)/(?P<display_id>[\w-]+)'
  11. _TEST = {
  12. 'url': 'http://www.eporner.com/hd-porn/95008/Infamous-Tiffany-Teen-Strip-Tease-Video/',
  13. 'md5': '39d486f046212d8e1b911c52ab4691f8',
  14. 'info_dict': {
  15. 'id': '95008',
  16. 'display_id': 'Infamous-Tiffany-Teen-Strip-Tease-Video',
  17. 'ext': 'mp4',
  18. 'title': 'Infamous Tiffany Teen Strip Tease Video',
  19. 'duration': 194,
  20. 'view_count': int,
  21. 'age_limit': 18,
  22. }
  23. }
  24. def _real_extract(self, url):
  25. mobj = re.match(self._VALID_URL, url)
  26. video_id = mobj.group('id')
  27. display_id = mobj.group('display_id')
  28. webpage = self._download_webpage(url, display_id)
  29. title = self._html_search_regex(
  30. r'<title>(.*?) - EPORNER', webpage, 'title')
  31. redirect_code = self._html_search_regex(
  32. r'<script type="text/javascript" src="/config5/%s/([a-f\d]+)/">' % video_id,
  33. webpage, 'redirect_code')
  34. redirect_url = 'http://www.eporner.com/config5/%s/%s' % (video_id, redirect_code)
  35. player_code = self._download_webpage(
  36. redirect_url, display_id, note='Downloading player config')
  37. sources = self._search_regex(
  38. r'(?s)sources\s*:\s*\[\s*({.+?})\s*\]', player_code, 'sources')
  39. formats = []
  40. for video_url, format_id in re.findall(r'file\s*:\s*"([^"]+)",\s*label\s*:\s*"([^"]+)"', sources):
  41. fmt = {
  42. 'url': video_url,
  43. 'format_id': format_id,
  44. }
  45. m = re.search(r'^(\d+)', format_id)
  46. if m:
  47. fmt['height'] = int(m.group(1))
  48. formats.append(fmt)
  49. self._sort_formats(formats)
  50. duration = parse_duration(self._search_regex(
  51. r'class="mbtim">([0-9:]+)</div>', webpage, 'duration',
  52. fatal=False))
  53. view_count = str_to_int(self._search_regex(
  54. r'id="cinemaviews">\s*([0-9,]+)\s*<small>views',
  55. webpage, 'view count', fatal=False))
  56. return {
  57. 'id': video_id,
  58. 'display_id': display_id,
  59. 'title': title,
  60. 'duration': duration,
  61. 'view_count': view_count,
  62. 'formats': formats,
  63. 'age_limit': self._rta_search(webpage),
  64. }