]>
Commit | Line | Data |
---|---|---|
9ac0a675 PH |
1 | from __future__ import unicode_literals |
2 | ||
7b2212e9 | 3 | import re |
4 | ||
5 | from .common import InfoExtractor | |
1cc79574 | 6 | from ..compat import ( |
47af21e8 | 7 | compat_urllib_parse_unquote, |
7b2212e9 | 8 | compat_urllib_parse_urlparse, |
9 | compat_urllib_request, | |
1cc79574 PH |
10 | ) |
11 | from ..utils import ( | |
9767726b | 12 | str_to_int, |
1cc79574 | 13 | unified_strdate, |
7b2212e9 | 14 | ) |
9767726b | 15 | from ..aes import aes_decrypt_text |
7b2212e9 | 16 | |
9ac0a675 | 17 | |
7b2212e9 | 18 | class SpankwireIE(InfoExtractor): |
9767726b | 19 | _VALID_URL = r'https?://(?:www\.)?(?P<url>spankwire\.com/[^/]*/video(?P<videoid>[0-9]+)/?)' |
7b2212e9 | 20 | _TEST = { |
9ac0a675 | 21 | 'url': 'http://www.spankwire.com/Buckcherry-s-X-Rated-Music-Video-Crazy-Bitch/video103545/', |
9767726b | 22 | 'md5': '8bbfde12b101204b39e4b9fe7eb67095', |
9ac0a675 | 23 | 'info_dict': { |
9767726b S |
24 | 'id': '103545', |
25 | 'ext': 'mp4', | |
26 | 'title': 'Buckcherry`s X Rated Music Video Crazy Bitch', | |
27 | 'description': 'Crazy Bitch X rated music video.', | |
28 | 'uploader': 'oreusz', | |
29 | 'uploader_id': '124697', | |
44705366 | 30 | 'upload_date': '20070507', |
9767726b | 31 | 'age_limit': 18, |
7b2212e9 | 32 | } |
33 | } | |
34 | ||
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') | |
39 | ||
40 | req = compat_urllib_request.Request(url) | |
41 | req.add_header('Cookie', 'age_verified=1') | |
42 | webpage = self._download_webpage(req, video_id) | |
43 | ||
fdb4d278 S |
44 | title = self._html_search_regex( |
45 | r'<h1>([^<]+)', webpage, 'title') | |
0ad97bbc | 46 | description = self._html_search_regex( |
44705366 | 47 | r'(?s)<div\s+id="descriptionContent">(.+?)</div>', |
fdb4d278 | 48 | webpage, 'description', fatal=False) |
9767726b | 49 | thumbnail = self._html_search_regex( |
d3c9af84 | 50 | r'playerData\.screenShot\s*=\s*["\']([^"\']+)["\']', |
fdb4d278 | 51 | webpage, 'thumbnail', fatal=False) |
9767726b S |
52 | |
53 | uploader = self._html_search_regex( | |
fdb4d278 S |
54 | r'by:\s*<a [^>]*>(.+?)</a>', |
55 | webpage, 'uploader', fatal=False) | |
9767726b | 56 | uploader_id = self._html_search_regex( |
fdb4d278 S |
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)) | |
7b2212e9 | 62 | |
fdb4d278 S |
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( | |
44705366 | 67 | r'<span\s+id="spCommentCount"[^>]*>([\d,\.]+)</span>', |
fdb4d278 S |
68 | webpage, 'comment count', fatal=False)) |
69 | ||
70 | video_urls = list(map( | |
47af21e8 | 71 | compat_urllib_parse_unquote, |
44705366 | 72 | re.findall(r'playerData\.cdnPath[0-9]{3,}\s*=\s*(?:encodeURIComponent\()?["\']([^"\']+)["\']', webpage))) |
7b2212e9 | 73 | if webpage.find('flashvars\.encrypted = "true"') != -1: |
1434184c | 74 | password = self._search_regex( |
fdb4d278 S |
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'), | |
79 | video_urls)) | |
7b2212e9 | 80 | |
81 | formats = [] | |
82 | for video_url in video_urls: | |
a56f9de1 | 83 | path = compat_urllib_parse_urlparse(video_url).path |
7b2212e9 | 84 | format = path.split('/')[4].split('_')[:2] |
9ac0a675 | 85 | resolution, bitrate_str = format |
a56f9de1 | 86 | format = "-".join(format) |
9767726b S |
87 | height = int(resolution.rstrip('Pp')) |
88 | tbr = int(bitrate_str.rstrip('Kk')) | |
7b2212e9 | 89 | formats.append({ |
90 | 'url': video_url, | |
9ac0a675 | 91 | 'resolution': resolution, |
7b2212e9 | 92 | 'format': format, |
9ac0a675 PH |
93 | 'tbr': tbr, |
94 | 'height': height, | |
7b2212e9 | 95 | 'format_id': format, |
96 | }) | |
9ac0a675 | 97 | self._sort_formats(formats) |
7b2212e9 | 98 | |
750e9833 FV |
99 | age_limit = self._rta_search(webpage) |
100 | ||
7b2212e9 | 101 | return { |
102 | 'id': video_id, | |
9767726b | 103 | 'title': title, |
7b2212e9 | 104 | 'description': description, |
9767726b S |
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, | |
7b2212e9 | 111 | 'formats': formats, |
750e9833 | 112 | 'age_limit': age_limit, |
7b2212e9 | 113 | } |