4 from .common
import InfoExtractor
5 from ..aes
import aes_decrypt_text
16 class Tube8IE(InfoExtractor
):
18 _VALID_URL
= r
'https?://(?:www\.)?tube8\.com/(?:[^/]+/)+(?P<display_id>[^/]+)/(?P<id>\d+)'
19 _EMBED_REGEX
= [r
'<iframe[^>]+\bsrc=["\'](?P
<url
>(?
:https?
:)?
//(?
:www\
.)?tube8\
.com
/embed
/(?
:[^
/]+/)+\d
+)']
21 'url
': 'http
://www
.tube8
.com
/teen
/kasia
-music
-video
/229795/',
22 'md5
': '65e20c48e6abff62ed0c3965fff13a39
',
25 'display_id
': 'kasia
-music
-video
',
27 'description
': 'hot teen Kasia grinding
',
28 'uploader
': 'unknown
',
29 'title
': 'Kasia music video
',
32 'categories
': ['Teen
'],
36 'url
': 'http
://www
.tube8
.com
/shemale
/teen
/blonde
-cd
-gets
-kidnapped
-by
-two
-blacks
-and-punished
-for-being
-a
-slutty
-girl
/19569151/',
37 'only_matching
': True,
40 def _extract_info(self, url, fatal=True):
41 mobj = self._match_valid_url(url)
42 video_id = mobj.group('id')
43 display_id = (mobj.group('display_id
')
44 if 'display_id
' in mobj.groupdict()
45 else None) or mobj.group('id')
47 webpage = self._download_webpage(
48 url, display_id, headers={'Cookie
': 'age_verified
=1'})
58 def extract_format(format_url, height=None):
59 format_url = url_or_none(format_url)
60 if not format_url or not format_url.startswith(('http
', '//')):
62 if format_url in format_urls:
64 format_urls.add(format_url)
65 tbr = int_or_none(self._search_regex(
66 r'[/_
](\d
+)[kK
][/_
]', format_url, 'tbr
', default=None))
68 height = int_or_none(self._search_regex(
69 r'[/_
](\d
+)[pP
][/_
]', format_url, 'height
', default=None))
71 format_url = aes_decrypt_text(
72 video_url, title, 32).decode('utf
-8')
75 'format_id
': format_field(height, None, '%dp
'),
80 flashvars = self._parse_json(
82 r'flashvars\s
*=\s
*({.+?
});', webpage,
83 'flashvars
', default='{}'),
84 display_id, fatal=False)
87 title = flashvars.get('video_title
')
88 thumbnail = flashvars.get('image_url
')
89 duration = int_or_none(flashvars.get('video_duration
'))
90 encrypted = flashvars.get('encrypted
') is True
91 for key, value in flashvars.items():
92 mobj = re.search(r'quality_(\d
+)[pP
]', key)
94 extract_format(value, int(mobj.group(1)))
95 video_url = flashvars.get('video_url
')
96 if video_url and determine_ext(video_url, None):
97 extract_format(video_url)
99 video_url = self._html_search_regex(
100 r'flashvars\
.video_url\s
*=\s
*(["\'])(?P<url>http.+?)\1',
101 webpage, 'video url', default=None, group='url')
103 extract_format(urllib.parse.unquote(video_url))
106 if 'title="This video
is no longer available
"' in webpage:
107 self.raise_no_formats(
108 f'Video {video_id} is no longer available', expected=True)
111 title = self._html_search_regex(
112 r'<h1[^>]*>([^<]+)', webpage, 'title')
116 'display_id': display_id,
117 'title': strip_or_none(title),
118 'thumbnail': thumbnail,
119 'duration': duration,
124 def _real_extract(self, url):
125 webpage, info = self._extract_info(url)
127 if not info['title']:
128 info['title'] = self._html_search_regex(
129 r'videoTitle\s*=\s*"([^
"]+)', webpage, 'title')
131 description = self._html_search_regex(
132 r'(?s)Description:</dt>\s*<dd>(.+?)</dd>', webpage, 'description', fatal=False)
133 uploader = self._html_search_regex(
134 r'<span class="username
">\s*(.+?)\s*<',
135 webpage, 'uploader', fatal=False)
137 like_count = int_or_none(self._search_regex(
138 r'rupVar\s*=\s*"(\d
+)"', webpage, 'like count', fatal=False))
139 dislike_count = int_or_none(self._search_regex(
140 r'rdownVar\s*=\s*"(\d
+)"', webpage, 'dislike count', fatal=False))
141 view_count = str_to_int(self._search_regex(
142 r'Views:\s*</dt>\s*<dd>([\d,\.]+)',
143 webpage, 'view count', fatal=False))
144 comment_count = str_to_int(self._search_regex(
145 r'<span id="allCommentsCount
">(\d+)</span>',
146 webpage, 'comment count', fatal=False))
148 category = self._search_regex(
149 r'Category:\s*</dt>\s*<dd>\s*<a[^>]+href=[^>]+>([^<]+)',
150 webpage, 'category', fatal=False)
151 categories = [category] if category else None
153 tags_str = self._search_regex(
154 r'(?s)Tags:\s*</dt>\s*<dd>(.+?)</(?!a)',
155 webpage, 'tags', fatal=False)
156 tags = list(re.findall(
157 r'<a[^>]+href=[^>]+>([^<]+)', tags_str)) if tags_str else None
160 'description': description,
161 'uploader': uploader,
162 'view_count': view_count,
163 'like_count': like_count,
164 'dislike_count': dislike_count,
165 'comment_count': comment_count,
166 'categories': categories,