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.

74 lines
2.4 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>\w+)/(?P<display_id>[\w-]+)'
  11. _TESTS = [{
  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': 1838,
  20. 'view_count': int,
  21. 'age_limit': 18,
  22. },
  23. }, {
  24. # New (May 2016) URL layout
  25. 'url': 'http://www.eporner.com/hd-porn/3YRUtzMcWn0/Star-Wars-XXX-Parody/',
  26. 'only_matching': True,
  27. }]
  28. def _real_extract(self, url):
  29. mobj = re.match(self._VALID_URL, url)
  30. video_id = mobj.group('id')
  31. display_id = mobj.group('display_id')
  32. webpage = self._download_webpage(url, display_id)
  33. title = self._html_search_regex(
  34. r'<title>(.*?) - EPORNER', webpage, 'title')
  35. redirect_url = 'http://www.eporner.com/config5/%s' % video_id
  36. player_code = self._download_webpage(
  37. redirect_url, display_id, note='Downloading player config')
  38. sources = self._search_regex(
  39. r'(?s)sources\s*:\s*\[\s*({.+?})\s*\]', player_code, 'sources')
  40. formats = []
  41. for video_url, format_id in re.findall(r'file\s*:\s*"([^"]+)",\s*label\s*:\s*"([^"]+)"', sources):
  42. fmt = {
  43. 'url': video_url,
  44. 'format_id': format_id,
  45. }
  46. m = re.search(r'^(\d+)', format_id)
  47. if m:
  48. fmt['height'] = int(m.group(1))
  49. formats.append(fmt)
  50. self._sort_formats(formats)
  51. duration = parse_duration(self._html_search_meta('duration', webpage))
  52. view_count = str_to_int(self._search_regex(
  53. r'id="cinemaviews">\s*([0-9,]+)\s*<small>views',
  54. webpage, 'view count', fatal=False))
  55. return {
  56. 'id': video_id,
  57. 'display_id': display_id,
  58. 'title': title,
  59. 'duration': duration,
  60. 'view_count': view_count,
  61. 'formats': formats,
  62. 'age_limit': 18,
  63. }