1 from __future__
import unicode_literals
5 from .common
import InfoExtractor
7 compat_urllib_parse_urlparse
,
13 from ..aes
import aes_decrypt_text
16 class SpankwireIE(InfoExtractor
):
17 _VALID_URL
= r
'https?://(?:www\.)?(?P<url>spankwire\.com/[^/]*/video(?P<videoid>[0-9]+)/?)'
19 'url': 'http://www.spankwire.com/Buckcherry-s-X-Rated-Music-Video-Crazy-Bitch/video103545/',
20 'md5': '8bbfde12b101204b39e4b9fe7eb67095',
24 'title': 'Buckcherry`s X Rated Music Video Crazy Bitch',
25 'description': 'Crazy Bitch X rated music video.',
27 'uploader_id': '124697',
28 'upload_date': '20070508',
33 def _real_extract(self
, url
):
34 mobj
= re
.match(self
._VALID
_URL
, url
)
35 video_id
= mobj
.group('videoid')
36 url
= 'http://www.' + mobj
.group('url')
38 req
= compat_urllib_request
.Request(url
)
39 req
.add_header('Cookie', 'age_verified=1')
40 webpage
= self
._download
_webpage
(req
, video_id
)
42 title
= self
._html
_search
_regex
(
43 r
'<h1>([^<]+)', webpage
, 'title')
44 description
= self
._html
_search
_regex
(
45 r
'<div\s+id="descriptionContent">([^<]+)<',
46 webpage
, 'description', fatal
=False)
47 thumbnail
= self
._html
_search
_regex
(
48 r
'playerData\.screenShot\s*=\s*["\']([^
"\']+)["\']',
49 webpage, 'thumbnail
', fatal=False)
51 uploader = self._html_search_regex(
52 r'by
:\s
*<a
[^
>]*>(.+?
)</a
>',
53 webpage, 'uploader
', fatal=False)
54 uploader_id = self._html_search_regex(
55 r'by
:\s
*<a href
="/Profile\.aspx\?.*?UserId=(\d+).*?"',
56 webpage, 'uploader
id', fatal=False)
57 upload_date = unified_strdate(self._html_search_regex(
58 r'</a
> on (.+?
) at \d
+:\d
+',
59 webpage, 'upload date
', fatal=False))
61 view_count = str_to_int(self._html_search_regex(
62 r'<div
id="viewsCounter"><span
>([\d
,\
.]+)</span
> views
</div
>',
63 webpage, 'view count
', fatal=False))
64 comment_count = str_to_int(self._html_search_regex(
65 r'Comments
<span
[^
>]+>\s
*\
(([\d
,\
.]+)\
)</span
>',
66 webpage, 'comment count
', fatal=False))
68 video_urls = list(map(
69 compat_urllib_parse.unquote,
70 re.findall(r'playerData\
.cdnPath
[0-9]{3,}\s
*=\s
*["\']([^"\']+)["\']', webpage)))
71 if webpage.find('flashvars\.encrypted = "true
"') != -1:
72 password = self._html_search_regex(
73 r'flashvars\.video_title = "([^
"]+)',
74 webpage, 'password').replace('+', ' ')
75 video_urls = list(map(
76 lambda s: aes_decrypt_text(s, password, 32).decode('utf-8'),
80 for video_url in video_urls:
81 path = compat_urllib_parse_urlparse(video_url).path
82 format = path.split('/')[4].split('_')[:2]
83 resolution, bitrate_str = format
84 format = "-".join(format)
85 height = int(resolution.rstrip('Pp'))
86 tbr = int(bitrate_str.rstrip('Kk'))
89 'resolution': resolution,
95 self._sort_formats(formats)
97 age_limit = self._rta_search(webpage)
102 'description': description,
103 'thumbnail': thumbnail,
104 'uploader': uploader,
105 'uploader_id': uploader_id,
106 'upload_date': upload_date,
107 'view_count': view_count,
108 'comment_count': comment_count,
110 'age_limit': age_limit,