1 from __future__ import unicode_literals
5 from .common import InfoExtractor
6 from ..compat import compat_str
12 from ..aes import aes_decrypt_text
15 class Tube8IE(InfoExtractor):
16 _VALID_URL = r'https?://(?:www\.)?tube8\.com/(?:[^/]+/)+(?P<display_id>[^/]+)/(?P<id>\d+)'
19 'url': 'http://www.tube8.com/teen/kasia-music-video/229795/',
20 'md5': '44bf12b98313827dd52d35b8706a4ea0',
23 'display_id': 'kasia-music-video',
25 'description': 'hot teen Kasia grinding',
26 'uploader': 'unknown',
27 'title': 'Kasia music video',
32 'url': 'http://www.tube8.com/shemale/teen/blonde-cd-gets-kidnapped-by-two-blacks-and-punished-for-being-a-slutty-girl/19569151/',
33 'only_matching': True,
37 def _real_extract(self, url):
38 mobj = re.match(self._VALID_URL, url)
39 video_id = mobj.group('id')
40 display_id = mobj.group('display_id')
42 req = sanitized_Request(url)
43 req.add_header('Cookie', 'age_verified=1')
44 webpage = self._download_webpage(req, display_id)
46 flashvars = self._parse_json(
48 r'flashvars\s*=\s*({.+?});\r?\n', webpage, 'flashvars'),
52 for key, video_url in flashvars.items():
53 if not isinstance(video_url, compat_str) or not video_url.startswith('http'):
55 height = self._search_regex(
56 r'quality_(\d+)[pP]', key, 'height', default=None)
59 if flashvars.get('encrypted') is True:
60 video_url = aes_decrypt_text(
61 video_url, flashvars['video_title'], 32).decode('utf-8')
64 'format_id': '%sp' % height,
65 'height': int(height),
67 self._sort_formats(formats)
69 thumbnail = flashvars.get('image_url')
71 title = self._html_search_regex(
72 r'videoTitle\s*=\s*"([^"]+)', webpage, 'title')
73 description = self._html_search_regex(
74 r'>Description:</strong>\s*(.+?)\s*<', webpage, 'description', fatal=False)
75 uploader = self._html_search_regex(
76 r'<span class="username">\s*(.+?)\s*<',
77 webpage, 'uploader', fatal=False)
79 like_count = int_or_none(self._html_search_regex(
80 r'rupVar\s*=\s*"(\d+)"', webpage, 'like count', fatal=False))
81 dislike_count = int_or_none(self._html_search_regex(
82 r'rdownVar\s*=\s*"(\d+)"', webpage, 'dislike count', fatal=False))
83 view_count = self._html_search_regex(
84 r'<strong>Views: </strong>([\d,\.]+)\s*</li>', webpage, 'view count', fatal=False)
86 view_count = str_to_int(view_count)
87 comment_count = self._html_search_regex(
88 r'<span id="allCommentsCount">(\d+)</span>', webpage, 'comment count', fatal=False)
90 comment_count = str_to_int(comment_count)
94 'display_id': display_id,
96 'description': description,
97 'thumbnail': thumbnail,
99 'view_count': view_count,
100 'like_count': like_count,
101 'dislike_count': dislike_count,
102 'comment_count': comment_count,