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<videoid>[0-9]+)/?)'
21 'url': 'http://www.spankwire.com/Buckcherry-s-X-Rated-Music-Video-Crazy-Bitch/video103545/',
22 'md5': '8bbfde12b101204b39e4b9fe7eb67095',
26 'title': 'Buckcherry`s X Rated Music Video Crazy Bitch',
27 'description': 'Crazy Bitch X rated music video.',
29 'uploader_id': '124697',
30 'upload_date': '20070507',
35 'url': 'http://www.spankwire.com/Titcums-Compiloation-I/video1921551/',
36 'md5': '09b3c20833308b736ae8902db2f8d7e6',
40 'title': 'Titcums Compiloation I',
41 'description': 'cum on tits',
42 'uploader': 'dannyh78999',
43 'uploader_id': '3056053',
44 'upload_date': '20150822',
49 def _real_extract(self, url):
50 mobj = re.match(self._VALID_URL, url)
51 video_id = mobj.group('videoid')
52 url = 'http://www.' + mobj.group('url')
54 req = compat_urllib_request.Request(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\?.*?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))
84 video_urls = list(map(
85 compat_urllib_parse_unquote,
86 re.findall(r'playerData\.cdnPath[0-9]{3,}\s*=\s*(?:encodeURIComponent\()?["\']([^"\']+)["\']', webpage)))
87 if webpage.find('flashvars\.encrypted = "true"') != -1:
88 password = self._search_regex(
89 r'flashvars\.video_title = "([^"]+)',
90 webpage, 'password').replace('+', ' ')
91 video_urls = list(map(
92 lambda s: aes_decrypt_text(s, password, 32).decode('utf-8'),
96 for video_url in video_urls:
97 path = compat_urllib_parse_urlparse(video_url).path
98 format = path.split('/')[4].split('_')[:2]
99 if format[0] == 'mp4':
100 format_id, quality = format
101 format = "-".join(format)
102 if quality == 'normal':
104 elif quality == 'high':
106 elif quality == 'ultra':
108 elif quality == '720p':
117 resolution, bitrate_str = format
118 format = "-".join(format)
119 height = int(resolution.rstrip('Pp'))
120 tbr = int(bitrate_str.rstrip('Kk'))
123 'resolution': resolution,
129 self._sort_formats(formats)
131 age_limit = self._rta_search(webpage)
136 'description': description,
137 'thumbnail': thumbnail,
138 'uploader': uploader,
139 'uploader_id': uploader_id,
140 'upload_date': upload_date,
141 'view_count': view_count,
142 'comment_count': comment_count,
144 'age_limit': age_limit,