1 from __future__
import unicode_literals
5 from .common
import InfoExtractor
7 compat_urllib_parse_unquote
,
8 compat_urllib_parse_urlparse
,
15 from ..aes
import aes_decrypt_text
18 class SpankwireIE(InfoExtractor
):
19 _VALID_URL
= r
'https?://(?:www\.)?(?P<url>spankwire\.com/[^/]*/video(?P<id>[0-9]+)/?)'
21 # download URL pattern: */<height>P_<tbr>K_<video_id>.mp4
22 'url': 'http://www.spankwire.com/Buckcherry-s-X-Rated-Music-Video-Crazy-Bitch/video103545/',
23 'md5': '8bbfde12b101204b39e4b9fe7eb67095',
27 'title': 'Buckcherry`s X Rated Music Video Crazy Bitch',
28 'description': 'Crazy Bitch X rated music video.',
30 'uploader_id': '124697',
31 'upload_date': '20070507',
35 # download URL pattern: */mp4_<format_id>_<video_id>.mp4
36 'url': 'http://www.spankwire.com/Titcums-Compiloation-I/video1921551/',
37 'md5': '09b3c20833308b736ae8902db2f8d7e6',
41 'title': 'Titcums Compiloation I',
42 'description': 'cum on tits',
43 'uploader': 'dannyh78999',
44 'uploader_id': '3056053',
45 'upload_date': '20150822',
50 def _real_extract(self
, url
):
51 mobj
= re
.match(self
._VALID
_URL
, url
)
52 video_id
= mobj
.group('id')
54 req
= sanitized_Request('http://www.' + mobj
.group('url'))
55 req
.add_header('Cookie', 'age_verified=1')
56 webpage
= self
._download
_webpage
(req
, video_id
)
58 title
= self
._html
_search
_regex
(
59 r
'<h1>([^<]+)', webpage
, 'title')
60 description
= self
._html
_search
_regex
(
61 r
'(?s)<div\s+id="descriptionContent">(.+?)</div>',
62 webpage
, 'description', fatal
=False)
63 thumbnail
= self
._html
_search
_regex
(
64 r
'playerData\.screenShot\s*=\s*["\']([^
"\']+)["\']',
65 webpage, 'thumbnail
', fatal=False)
67 uploader = self._html_search_regex(
68 r'by
:\s
*<a
[^
>]*>(.+?
)</a
>',
69 webpage, 'uploader
', fatal=False)
70 uploader_id = self._html_search_regex(
71 r'by
:\s
*<a href
="/(?:user/viewProfile|Profile\.aspx)\?.*?UserId=(\d+).*?"',
72 webpage, 'uploader
id', fatal=False)
73 upload_date = unified_strdate(self._html_search_regex(
74 r'</a
> on (.+?
) at \d
+:\d
+',
75 webpage, 'upload date
', fatal=False))
77 view_count = str_to_int(self._html_search_regex(
78 r'<div
id="viewsCounter"><span
>([\d
,\
.]+)</span
> views
</div
>',
79 webpage, 'view count
', fatal=False))
80 comment_count = str_to_int(self._html_search_regex(
81 r'<span\s
+id="spCommentCount"[^
>]*>([\d
,\
.]+)</span
>',
82 webpage, 'comment count
', fatal=False))
85 r'playerData\
.cdnPath([0-9]{3,}
)\s
*=\s
*(?
:encodeURIComponent\
()?
["\']([^"\']+)["\']', webpage)
86 heights = [int(video[0]) for video in videos]
87 video_urls = list(map(compat_urllib_parse_unquote, [video[1] for video in videos]))
88 if webpage.find('flashvars\.encrypted = "true
"') != -1:
89 password = self._search_regex(
90 r'flashvars\.video_title = "([^
"]+)',
91 webpage, 'password').replace('+', ' ')
92 video_urls = list(map(
93 lambda s: aes_decrypt_text(s, password, 32).decode('utf-8'),
97 for height, video_url in zip(heights, video_urls):
98 path = compat_urllib_parse_urlparse(video_url).path
99 _, quality = path.split('/')[4].split('_')[:2]
104 tbr = self._search_regex(r'^(\d+)[Kk]$', quality, 'tbr', default=None)
108 'format_id': '%dp' % height,
111 f['format_id'] = quality
113 self._sort_formats(formats)
115 age_limit = self._rta_search(webpage)
120 'description': description,
121 'thumbnail': thumbnail,
122 'uploader': uploader,
123 'uploader_id': uploader_id,
124 'upload_date': upload_date,
125 'view_count': view_count,
126 'comment_count': comment_count,
128 'age_limit': age_limit,