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.

90 lines
3.0 KiB

10 years ago
  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. parse_duration,
  6. fix_xml_ampersands,
  7. )
  8. class TNAFlixIE(InfoExtractor):
  9. _VALID_URL = r'https?://(?:www\.)?tnaflix\.com/[^/]+/(?P<display_id>[^/]+)/video(?P<id>\d+)'
  10. _TITLE_REGEX = r'<title>(.+?) - TNAFlix Porn Videos</title>'
  11. _DESCRIPTION_REGEX = r'<h3 itemprop="description">([^<]+)</h3>'
  12. _CONFIG_REGEX = r'flashvars\.config\s*=\s*escape\("([^"]+)"'
  13. _TESTS = [
  14. {
  15. 'url': 'http://www.tnaflix.com/porn-stars/Carmella-Decesare-striptease/video553878',
  16. 'md5': 'ecf3498417d09216374fc5907f9c6ec0',
  17. 'info_dict': {
  18. 'id': '553878',
  19. 'display_id': 'Carmella-Decesare-striptease',
  20. 'ext': 'mp4',
  21. 'title': 'Carmella Decesare - striptease',
  22. 'description': '',
  23. 'thumbnail': 're:https?://.*\.jpg$',
  24. 'duration': 91,
  25. 'age_limit': 18,
  26. }
  27. },
  28. {
  29. 'url': 'https://www.tnaflix.com/amateur-porn/bunzHD-Ms.Donk/video358632',
  30. 'matching_only': True,
  31. }
  32. ]
  33. def _real_extract(self, url):
  34. mobj = re.match(self._VALID_URL, url)
  35. video_id = mobj.group('id')
  36. display_id = mobj.group('display_id')
  37. webpage = self._download_webpage(url, display_id)
  38. title = self._html_search_regex(
  39. self._TITLE_REGEX, webpage, 'title') if self._TITLE_REGEX else self._og_search_title(webpage)
  40. description = self._html_search_regex(
  41. self._DESCRIPTION_REGEX, webpage, 'description', fatal=False, default='')
  42. age_limit = self._rta_search(webpage)
  43. duration = self._html_search_meta('duration', webpage, 'duration', default=None)
  44. if duration:
  45. duration = parse_duration(duration[1:])
  46. cfg_url = self._proto_relative_url(self._html_search_regex(
  47. self._CONFIG_REGEX, webpage, 'flashvars.config'), 'http:')
  48. cfg_xml = self._download_xml(
  49. cfg_url, display_id, note='Downloading metadata',
  50. transform_source=fix_xml_ampersands)
  51. thumbnail = cfg_xml.find('./startThumb').text
  52. formats = []
  53. for item in cfg_xml.findall('./quality/item'):
  54. video_url = re.sub('speed=\d+', 'speed=', item.find('videoLink').text)
  55. format_id = item.find('res').text
  56. fmt = {
  57. 'url': video_url,
  58. 'format_id': format_id,
  59. }
  60. m = re.search(r'^(\d+)', format_id)
  61. if m:
  62. fmt['height'] = int(m.group(1))
  63. formats.append(fmt)
  64. self._sort_formats(formats)
  65. return {
  66. 'id': video_id,
  67. 'display_id': display_id,
  68. 'title': title,
  69. 'description': description,
  70. 'thumbnail': thumbnail,
  71. 'duration': duration,
  72. 'age_limit': age_limit,
  73. 'formats': formats,
  74. }