1 from __future__ import unicode_literals
5 from .common import InfoExtractor
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': '20070508',
35 def _real_extract(self, url):
36 mobj = re.match(self._VALID_URL, url)
37 video_id = mobj.group('videoid')
38 url = 'http://www.' + mobj.group('url')
40 req = compat_urllib_request.Request(url)
41 req.add_header('Cookie', 'age_verified=1')
42 webpage = self._download_webpage(req, video_id)
44 title = self._html_search_regex(
45 r'<h1>([^<]+)', webpage, 'title')
46 description = self._html_search_regex(
47 r'<div\s+id="descriptionContent">([^<]+)<',
48 webpage, 'description', fatal=False)
49 thumbnail = self._html_search_regex(
50 r'playerData\.screenShot\s*=\s*["\']([^"\']+)["\']',
51 webpage, 'thumbnail', fatal=False)
53 uploader = self._html_search_regex(
54 r'by:\s*<a [^>]*>(.+?)</a>',
55 webpage, 'uploader', fatal=False)
56 uploader_id = self._html_search_regex(
57 r'by:\s*<a href="/Profile\.aspx\?.*?UserId=(\d+).*?"',
58 webpage, 'uploader id', fatal=False)
59 upload_date = unified_strdate(self._html_search_regex(
60 r'</a> on (.+?) at \d+:\d+',
61 webpage, 'upload date', fatal=False))
63 view_count = str_to_int(self._html_search_regex(
64 r'<div id="viewsCounter"><span>([\d,\.]+)</span> views</div>',
65 webpage, 'view count', fatal=False))
66 comment_count = str_to_int(self._html_search_regex(
67 r'Comments<span[^>]+>\s*\(([\d,\.]+)\)</span>',
68 webpage, 'comment count', fatal=False))
70 video_urls = list(map(
71 compat_urllib_parse.unquote,
72 re.findall(r'playerData\.cdnPath[0-9]{3,}\s*=\s*["\']([^"\']+)["\']', webpage)))
73 if webpage.find('flashvars\.encrypted = "true"') != -1:
74 password = self._search_regex(
75 r'flashvars\.video_title = "([^"]+)',
76 webpage, 'password').replace('+', ' ')
77 video_urls = list(map(
78 lambda s: aes_decrypt_text(s, password, 32).decode('utf-8'),
82 for video_url in video_urls:
83 path = compat_urllib_parse_urlparse(video_url).path
84 format = path.split('/')[4].split('_')[:2]
85 resolution, bitrate_str = format
86 format = "-".join(format)
87 height = int(resolution.rstrip('Pp'))
88 tbr = int(bitrate_str.rstrip('Kk'))
91 'resolution': resolution,
97 self._sort_formats(formats)
99 age_limit = self._rta_search(webpage)
104 'description': description,
105 'thumbnail': thumbnail,
106 'uploader': uploader,
107 'uploader_id': uploader_id,
108 'upload_date': upload_date,
109 'view_count': view_count,
110 'comment_count': comment_count,
112 'age_limit': age_limit,