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.

89 lines
3.2 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..compat import compat_urlparse
  5. from ..utils import (
  6. int_or_none,
  7. js_to_json,
  8. parse_filesize,
  9. str_to_int,
  10. )
  11. class PornComIE(InfoExtractor):
  12. _VALID_URL = r'https?://(?:[a-zA-Z]+\.)?porn\.com/videos/(?:(?P<display_id>[^/]+)-)?(?P<id>\d+)'
  13. _TESTS = [{
  14. 'url': 'http://www.porn.com/videos/teen-grabs-a-dildo-and-fucks-her-pussy-live-on-1hottie-i-rec-2603339',
  15. 'md5': '3f30ce76267533cd12ba999263156de7',
  16. 'info_dict': {
  17. 'id': '2603339',
  18. 'display_id': 'teen-grabs-a-dildo-and-fucks-her-pussy-live-on-1hottie-i-rec',
  19. 'ext': 'mp4',
  20. 'title': 'Teen grabs a dildo and fucks her pussy live on 1hottie, I rec',
  21. 'thumbnail': 're:^https?://.*\.jpg$',
  22. 'duration': 551,
  23. 'view_count': int,
  24. 'age_limit': 18,
  25. },
  26. }, {
  27. 'url': 'http://se.porn.com/videos/marsha-may-rides-seth-on-top-of-his-thick-cock-2658067',
  28. 'only_matching': True,
  29. }]
  30. def _real_extract(self, url):
  31. mobj = re.match(self._VALID_URL, url)
  32. video_id = mobj.group('id')
  33. display_id = mobj.group('display_id') or video_id
  34. webpage = self._download_webpage(url, display_id)
  35. config = self._parse_json(
  36. self._search_regex(
  37. r'=\s*({.+?})\s*,\s*[\da-zA-Z_]+\s*=',
  38. webpage, 'config', default='{}'),
  39. display_id, transform_source=js_to_json, fatal=False)
  40. if config:
  41. title = config['title']
  42. formats = [{
  43. 'url': stream['url'],
  44. 'format_id': stream.get('id'),
  45. 'height': int_or_none(self._search_regex(
  46. r'^(\d+)[pP]', stream.get('id') or '', 'height', default=None))
  47. } for stream in config['streams'] if stream.get('url')]
  48. thumbnail = (compat_urlparse.urljoin(
  49. config['thumbCDN'], config['poster'])
  50. if config.get('thumbCDN') and config.get('poster') else None)
  51. duration = int_or_none(config.get('length'))
  52. else:
  53. title = self._search_regex(
  54. (r'<title>([^<]+)</title>', r'<h1[^>]*>([^<]+)</h1>'),
  55. webpage, 'title')
  56. formats = [{
  57. 'url': compat_urlparse.urljoin(url, format_url),
  58. 'format_id': '%sp' % height,
  59. 'height': int(height),
  60. 'filesize_approx': parse_filesize(filesize),
  61. } for format_url, height, filesize in re.findall(
  62. r'<a[^>]+href="(/download/[^"]+)">MPEG4 (\d+)p<span[^>]*>(\d+\s+[a-zA-Z]+)<',
  63. webpage)]
  64. thumbnail = None
  65. duration = None
  66. self._sort_formats(formats)
  67. view_count = str_to_int(self._search_regex(
  68. r'class=["\']views["\'][^>]*><p>([\d,.]+)', webpage, 'view count'))
  69. return {
  70. 'id': video_id,
  71. 'display_id': display_id,
  72. 'title': title,
  73. 'thumbnail': thumbnail,
  74. 'duration': duration,
  75. 'view_count': view_count,
  76. 'formats': formats,
  77. 'age_limit': 18,
  78. }