1 from __future__
import unicode_literals
5 from .common
import InfoExtractor
17 class RedTubeIE(InfoExtractor
):
18 _VALID_URL
= r
'https?://(?:(?:\w+\.)?redtube\.com/|embed\.redtube\.com/\?.*?\bid=)(?P<id>[0-9]+)'
20 'url': 'https://www.redtube.com/38864951',
21 'md5': '4fba70cbca3aefd25767ab4b523c9878',
25 'title': 'Public Sex on the Balcony in Freezing Paris! Amateur Couple LeoLulu',
26 'description': 'Watch video Public Sex on the Balcony in Freezing Paris! Amateur Couple LeoLulu on Redtube, home of free Blowjob porn videos and Blonde sex movies online. Video length: (10:46) - Uploaded by leolulu - Verified User - Starring Pornstar: Leolulu',
27 'upload_date': '20210111',
28 'timestamp': 1610343109,
32 'thumbnail': r
're:https://\wi-ph\.rdtcdn\.com/videos/.+/.+\.jpg',
35 'url': 'http://embed.redtube.com/?bgcolor=000000&id=1443286',
36 'only_matching': True,
38 'url': 'http://it.redtube.com/66418',
39 'only_matching': True,
43 def _extract_urls(webpage
):
45 r
'<iframe[^>]+?src=["\'](?P
<url
>(?
:https?
:)?
//embed\
.redtube\
.com
/\?.*?
\bid
=\d
+)',
48 def _real_extract(self, url):
49 video_id = self._match_id(url)
50 webpage = self._download_webpage(
51 'http
://www
.redtube
.com
/%s' % video_id, video_id)
54 (('video
-deleted
-info
', '>This video has been removed
'), 'has been removed
'),
55 (('private_video_text
', '>This video
is private
', '>Send a friend request to its owner to be able to view it
'), 'is private
'),
58 for patterns, message in ERRORS:
59 if any(p in webpage for p in patterns):
61 'Video
%s %s' % (video_id, message), expected=True)
63 info = self._search_json_ld(webpage, video_id, default={})
65 if not info.get('title
'):
66 info['title
'] = self._html_search_regex(
67 (r'<h(\d
)[^
>]+class="(?:video_title_text|videoTitle|video_title)[^"]*">(?P<title>(?:(?!\1).)+)</h\1>',
68 r'(?:videoTitle|title)\s*:\s*(["\'])(?P
<title
>(?
:(?
!\
1).)+)\
1',),
69 webpage, 'title
', group='title
',
70 default=None) or self._og_search_title(webpage)
73 sources = self._parse_json(
75 r'sources\s
*:\s
*({.+?}
)', webpage, 'source
', default='{}'),
76 video_id, fatal=False)
77 if sources and isinstance(sources, dict):
78 for format_id, format_url in sources.items():
82 'format_id
': format_id,
83 'height
': int_or_none(format_id),
85 medias = self._parse_json(
87 r'mediaDefinition
["\']?\s*:\s*(\[.+?}\s*\])', webpage,
88 'media definitions', default='{}'),
89 video_id, fatal=False)
90 for media in medias if isinstance(medias, list) else []:
91 format_url = url_or_none(media.get('videoUrl'))
94 format_id = media.get('format')
95 quality = media.get('quality')
96 if format_id == 'hls' or (format_id == 'mp4' and not quality):
97 more_media = self._download_json(format_url, video_id, fatal=False)
100 for media in more_media if isinstance(more_media, list) else []:
101 format_url = url_or_none(media.get('videoUrl'))
104 format_id = media.get('format')
105 if format_id == 'hls' or determine_ext(format_url) == 'm3u8':
106 formats.extend(self._extract_m3u8_formats(
107 format_url, video_id, 'mp4',
108 entry_protocol='m3u8_native', m3u8_id=format_id or 'hls',
111 format_id = media.get('quality')
115 'format_id': format_id,
116 'height': int_or_none(format_id),
119 video_url = self._html_search_regex(
120 r'<source src="(.+?
)" type="video
/mp4
">', webpage, 'video URL')
121 formats.append({'url': video_url, 'ext': 'mp4'})
122 self._sort_formats(formats)
124 thumbnail = self._og_search_thumbnail(webpage)
125 upload_date = unified_strdate(self._search_regex(
126 r'<span[^>]+>(?:ADDED|Published on) ([^<]+)<',
127 webpage, 'upload date', default=None))
128 duration = int_or_none(self._og_search_property(
129 'video:duration', webpage, default=None) or self._search_regex(
130 r'videoDuration\s*:\s*(\d+)', webpage, 'duration', default=None))
131 view_count = str_to_int(self._search_regex(
132 (r'<div[^>]*>Views</div>\s*<div[^>]*>\s*([\d,.]+)',
133 r'<span[^>]*>VIEWS</span>\s*</td>\s*<td>\s*([\d,.]+)',
134 r'<span[^>]+\bclass=["\']video_view_count
[^
>]*>\s
*([\d
,.]+)'),
135 webpage, 'view count
', default=None))
137 # No self-labeling, but they describe themselves as
138 # "Home of Videos Porno"
141 return merge_dicts(info, {
144 'thumbnail
': thumbnail,
145 'upload_date
': upload_date,
146 'duration
': duration,
147 'view_count
': view_count,
148 'age_limit
': age_limit,