1 from __future__ import unicode_literals
6 from .common import InfoExtractor
8 compat_urllib_parse_urlparse,
13 from ..aes import aes_decrypt_text
16 class Tube8IE(InfoExtractor):
17 _VALID_URL = r'https?://(?:www\.)?tube8\.com/(?:[^/]+/){2}(?P<id>\d+)'
19 'url': 'http://www.tube8.com/teen/kasia-music-video/229795/',
20 'md5': '44bf12b98313827dd52d35b8706a4ea0',
24 'description': 'hot teen Kasia grinding',
25 'uploader': 'unknown',
26 'title': 'Kasia music video',
31 def _real_extract(self, url):
32 mobj = re.match(self._VALID_URL, url)
33 video_id = mobj.group('id')
35 req = compat_urllib_request.Request(url)
36 req.add_header('Cookie', 'age_verified=1')
37 webpage = self._download_webpage(req, video_id)
39 flashvars = json.loads(self._html_search_regex(
40 r'var flashvars\s*=\s*({.+?})', webpage, 'flashvars'))
42 video_url = flashvars['video_url']
43 if flashvars.get('encrypted') is True:
44 video_url = aes_decrypt_text(video_url, flashvars['video_title'], 32).decode('utf-8')
45 path = compat_urllib_parse_urlparse(video_url).path
46 format_id = '-'.join(path.split('/')[4].split('_')[:2])
48 thumbnail = flashvars.get('image_url')
50 title = self._html_search_regex(
51 r'videotitle\s*=\s*"([^"]+)', webpage, 'title')
52 description = self._html_search_regex(
53 r'>Description:</strong>(.+?)<', webpage, 'description', fatal=False)
54 uploader = self._html_search_regex(
55 r'<strong class="video-username">(?:<a href="[^"]+">)?([^<]+)(?:</a>)?</strong>',
56 webpage, 'uploader', fatal=False)
58 like_count = int_or_none(self._html_search_regex(
59 r"rupVar\s*=\s*'(\d+)'", webpage, 'like count', fatal=False))
60 dislike_count = int_or_none(self._html_search_regex(
61 r"rdownVar\s*=\s*'(\d+)'", webpage, 'dislike count', fatal=False))
62 view_count = self._html_search_regex(
63 r'<strong>Views: </strong>([\d,\.]+)</li>', webpage, 'view count', fatal=False)
65 view_count = str_to_int(view_count)
66 comment_count = self._html_search_regex(
67 r'<span id="allCommentsCount">(\d+)</span>', webpage, 'comment count', fatal=False)
69 comment_count = str_to_int(comment_count)
75 'description': description,
76 'thumbnail': thumbnail,
78 'format_id': format_id,
79 'view_count': view_count,
80 'like_count': like_count,
81 'dislike_count': dislike_count,
82 'comment_count': comment_count,