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.

70 lines
2.3 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': 1838,
  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_url = 'http://www.eporner.com/config5/%s' % video_id
  32. player_code = self._download_webpage(
  33. redirect_url, display_id, note='Downloading player config')
  34. sources = self._search_regex(
  35. r'(?s)sources\s*:\s*\[\s*({.+?})\s*\]', player_code, 'sources')
  36. formats = []
  37. for video_url, format_id in re.findall(r'file\s*:\s*"([^"]+)",\s*label\s*:\s*"([^"]+)"', sources):
  38. fmt = {
  39. 'url': video_url,
  40. 'format_id': format_id,
  41. }
  42. m = re.search(r'^(\d+)', format_id)
  43. if m:
  44. fmt['height'] = int(m.group(1))
  45. formats.append(fmt)
  46. self._sort_formats(formats)
  47. duration = parse_duration(self._html_search_meta('duration', webpage))
  48. view_count = str_to_int(self._search_regex(
  49. r'id="cinemaviews">\s*([0-9,]+)\s*<small>views',
  50. webpage, 'view count', fatal=False))
  51. return {
  52. 'id': video_id,
  53. 'display_id': display_id,
  54. 'title': title,
  55. 'duration': duration,
  56. 'view_count': view_count,
  57. 'formats': formats,
  58. 'age_limit': 18,
  59. }