]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/tnaflix.py
[TNAFlix] Allow dot (and more) in cat_id and display_id
[yt-dlp.git] / youtube_dl / extractor / tnaflix.py
CommitLineData
1dba4a21 1from __future__ import unicode_literals
2
3import re
4
5from .common import InfoExtractor
6from ..utils import (
7 parse_duration,
eb833b7f 8 fix_xml_ampersands,
1dba4a21 9)
10
eb833b7f 11
1dba4a21 12class TNAFlixIE(InfoExtractor):
e7752cd5 13 _VALID_URL = r'https?://(?:www\.)?tnaflix\.com/(?P<cat_id>[^/]+)/(?P<display_id>[^/]+)/video(?P<id>\d+)'
eb833b7f 14
079d1dcd 15 _TITLE_REGEX = r'<title>(.+?) - TNAFlix Porn Videos</title>'
eb833b7f
S
16 _DESCRIPTION_REGEX = r'<h3 itemprop="description">([^<]+)</h3>'
17 _CONFIG_REGEX = r'flashvars\.config\s*=\s*escape\("([^"]+)"'
18
1dba4a21 19 _TEST = {
e7752cd5 20 'url': 'https://www.tnaflix.com/amateur-porn/bunzHD-Ms.Donk/video358632',
21 'md5': '6c431ea56756497e227fb3f01a687869',
1dba4a21 22 'info_dict': {
e7752cd5 23 'id': '358632',
24 'display_id': 'bunzHD-Ms.Donk',
1dba4a21 25 'ext': 'mp4',
e7752cd5 26 'title': 'bunzHD Ms.Donk',
27 'description': 'bubble booty ebony teen goddess Ms.Donk has a firm ass and acts like she is shy but really she is a freak in the sheets watch her 20 min XX rated vid at bunzHD.com click on the catalog link',
1dba4a21 28 'thumbnail': 're:https?://.*\.jpg$',
e7752cd5 29 'duration': 394,
1dba4a21 30 'age_limit': 18,
31 }
32 }
33
34 def _real_extract(self, url):
35 mobj = re.match(self._VALID_URL, url)
36 video_id = mobj.group('id')
37 display_id = mobj.group('display_id')
38
39 webpage = self._download_webpage(url, display_id)
40
eb833b7f
S
41 title = self._html_search_regex(
42 self._TITLE_REGEX, webpage, 'title') if self._TITLE_REGEX else self._og_search_title(webpage)
43 description = self._html_search_regex(
44 self._DESCRIPTION_REGEX, webpage, 'description', fatal=False, default='')
45
46 age_limit = self._rta_search(webpage)
47
48 duration = self._html_search_meta('duration', webpage, 'duration', default=None)
49 if duration:
50 duration = parse_duration(duration[1:])
51
68f705ca
S
52 cfg_url = self._proto_relative_url(self._html_search_regex(
53 self._CONFIG_REGEX, webpage, 'flashvars.config'), 'http:')
eb833b7f
S
54
55 cfg_xml = self._download_xml(
56 cfg_url, display_id, note='Downloading metadata',
57 transform_source=fix_xml_ampersands)
58
59 thumbnail = cfg_xml.find('./startThumb').text
60
1dba4a21 61 formats = []
eb833b7f
S
62 for item in cfg_xml.findall('./quality/item'):
63 video_url = re.sub('speed=\d+', 'speed=', item.find('videoLink').text)
64 format_id = item.find('res').text
1dba4a21 65 fmt = {
66 'url': video_url,
67 'format_id': format_id,
68 }
69 m = re.search(r'^(\d+)', format_id)
70 if m:
71 fmt['height'] = int(m.group(1))
72 formats.append(fmt)
73 self._sort_formats(formats)
5f6a1245 74
1dba4a21 75 return {
76 'id': video_id,
77 'display_id': display_id,
1dba4a21 78 'title': title,
eb833b7f 79 'description': description,
1dba4a21 80 'thumbnail': thumbnail,
eb833b7f
S
81 'duration': duration,
82 'age_limit': age_limit,
83 'formats': formats,
1dba4a21 84 }