]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/spankbang.py
[README.md] Bind info dict URLs to a fixed blob (closes #18492)
[yt-dlp.git] / youtube_dl / extractor / spankbang.py
CommitLineData
64102296 1from __future__ import unicode_literals
2
64102296 3import re
4
d97aae75 5from .common import InfoExtractor
7773a928
S
6from ..utils import (
7 ExtractorError,
8 parse_duration,
9 parse_resolution,
10 str_to_int,
11)
d97aae75
S
12
13
64102296 14class SpankBangIE(InfoExtractor):
3192d4bc 15 _VALID_URL = r'https?://(?:(?:www|m|[a-z]{2})\.)?spankbang\.com/(?P<id>[\da-z]+)/video'
d9e543b6 16 _TESTS = [{
d97aae75
S
17 'url': 'http://spankbang.com/3vvn/video/fantasy+solo',
18 'md5': '1cc433e1d6aa14bc376535b8679302f7',
19 'info_dict': {
20 'id': '3vvn',
21 'ext': 'mp4',
22 'title': 'fantasy solo',
7773a928 23 'description': 'dillion harper masturbates on a bed',
ec85ded8 24 'thumbnail': r're:^https?://.*\.jpg$',
d97aae75
S
25 'uploader': 'silly2587',
26 'age_limit': 18,
5c1d459a 27 }
d9e543b6
S
28 }, {
29 # 480p only
30 'url': 'http://spankbang.com/1vt0/video/solvane+gangbang',
31 'only_matching': True,
69263044
S
32 }, {
33 # no uploader
34 'url': 'http://spankbang.com/lklg/video/sex+with+anyone+wedding+edition+2',
35 'only_matching': True,
3192d4bc
W
36 }, {
37 # mobile page
38 'url': 'http://m.spankbang.com/1o2de/video/can+t+remember+her+name',
39 'only_matching': True,
7773a928
S
40 }, {
41 # 4k
42 'url': 'https://spankbang.com/1vwqx/video/jade+kush+solo+4k',
43 'only_matching': True,
d9e543b6 44 }]
64102296 45
46 def _real_extract(self, url):
47 video_id = self._match_id(url)
7773a928
S
48 webpage = self._download_webpage(url, video_id, headers={
49 'Cookie': 'country=US'
50 })
64102296 51
8fe767e0
S
52 if re.search(r'<[^>]+\bid=["\']video_removed', webpage):
53 raise ExtractorError(
54 'Video %s is not available' % video_id, expected=True)
55
7773a928
S
56 formats = []
57 for mobj in re.finditer(
58 r'stream_url_(?P<id>[^\s=]+)\s*=\s*(["\'])(?P<url>(?:(?!\2).)+)\2',
59 webpage):
60 format_id, format_url = mobj.group('id', 'url')
61 f = parse_resolution(format_id)
62 f.update({
63 'url': format_url,
64 'format_id': format_id,
65 })
66 formats.append(f)
d97aae75
S
67 self._sort_formats(formats)
68
69 title = self._html_search_regex(
c3111ab3 70 r'(?s)<h1[^>]*>(.+?)</h1>', webpage, 'title')
7773a928
S
71 description = self._search_regex(
72 r'<div[^>]+\bclass=["\']bottom[^>]+>\s*<p>[^<]*</p>\s*<p>([^<]+)',
73 webpage, 'description', fatal=False)
d97aae75
S
74 thumbnail = self._og_search_thumbnail(webpage)
75 uploader = self._search_regex(
dc2c37f3 76 r'class="user"[^>]*><img[^>]+>([^<]+)',
69263044 77 webpage, 'uploader', default=None)
7773a928
S
78 duration = parse_duration(self._search_regex(
79 r'<div[^>]+\bclass=["\']right_side[^>]+>\s*<span>([^<]+)',
80 webpage, 'duration', fatal=False))
81 view_count = str_to_int(self._search_regex(
82 r'([\d,.]+)\s+plays', webpage, 'view count', fatal=False))
d97aae75
S
83
84 age_limit = self._rta_search(webpage)
64102296 85
86 return {
d97aae75
S
87 'id': video_id,
88 'title': title,
89 'description': description,
90 'thumbnail': thumbnail,
91 'uploader': uploader,
7773a928
S
92 'duration': duration,
93 'view_count': view_count,
d97aae75
S
94 'formats': formats,
95 'age_limit': age_limit,
64102296 96 }