1 from __future__
import unicode_literals
6 from .common
import InfoExtractor
8 compat_urllib_parse_urlparse
,
15 from ..aes
import aes_decrypt_text
18 class Tube8IE(InfoExtractor
):
19 _VALID_URL
= r
'https?://(?:www\.)?tube8\.com/(?:[^/]+/)+(?P<display_id>[^/]+)/(?P<id>\d+)'
22 'url': 'http://www.tube8.com/teen/kasia-music-video/229795/',
23 'md5': '44bf12b98313827dd52d35b8706a4ea0',
26 'display_id': 'kasia-music-video',
28 'description': 'hot teen Kasia grinding',
29 'uploader': 'unknown',
30 'title': 'Kasia music video',
35 'url': 'http://www.tube8.com/shemale/teen/blonde-cd-gets-kidnapped-by-two-blacks-and-punished-for-being-a-slutty-girl/19569151/',
36 'only_matching': True,
40 def _real_extract(self
, url
):
41 mobj
= re
.match(self
._VALID
_URL
, url
)
42 video_id
= mobj
.group('id')
43 display_id
= mobj
.group('display_id')
45 req
= compat_urllib_request
.Request(url
)
46 req
.add_header('Cookie', 'age_verified=1')
47 webpage
= self
._download
_webpage
(req
, display_id
)
49 flashvars
= json
.loads(self
._html
_search
_regex
(
50 r
'var flashvars\s*=\s*({.+?})', webpage
, 'flashvars'))
52 video_url
= flashvars
['video_url']
53 if flashvars
.get('encrypted') is True:
54 video_url
= aes_decrypt_text(video_url
, flashvars
['video_title'], 32).decode('utf-8')
55 path
= compat_urllib_parse_urlparse(video_url
).path
56 format_id
= '-'.join(path
.split('/')[4].split('_')[:2])
58 thumbnail
= flashvars
.get('image_url')
60 title
= self
._html
_search
_regex
(
61 r
'videotitle\s*=\s*"([^"]+)', webpage
, 'title')
62 description
= self
._html
_search
_regex
(
63 r
'>Description:</strong>(.+?)<', webpage
, 'description', fatal
=False)
64 uploader
= self
._html
_search
_regex
(
65 r
'<strong class="video-username">(?:<a href="[^"]+">)?([^<]+)(?:</a>)?</strong>',
66 webpage
, 'uploader', fatal
=False)
68 like_count
= int_or_none(self
._html
_search
_regex
(
69 r
"rupVar\s*=\s*'(\d+)'", webpage
, 'like count', fatal
=False))
70 dislike_count
= int_or_none(self
._html
_search
_regex
(
71 r
"rdownVar\s*=\s*'(\d+)'", webpage
, 'dislike count', fatal
=False))
72 view_count
= self
._html
_search
_regex
(
73 r
'<strong>Views: </strong>([\d,\.]+)</li>', webpage
, 'view count', fatal
=False)
75 view_count
= str_to_int(view_count
)
76 comment_count
= self
._html
_search
_regex
(
77 r
'<span id="allCommentsCount">(\d+)</span>', webpage
, 'comment count', fatal
=False)
79 comment_count
= str_to_int(comment_count
)
83 'display_id': display_id
,
86 'description': description
,
87 'thumbnail': thumbnail
,
89 'format_id': format_id
,
90 'view_count': view_count
,
91 'like_count': like_count
,
92 'dislike_count': dislike_count
,
93 'comment_count': comment_count
,