3 from .common
import InfoExtractor
14 class ManyVidsIE(InfoExtractor
):
16 _VALID_URL
= r
'(?i)https?://(?:www\.)?manyvids\.com/video/(?P<id>\d+)'
19 'url': 'https://www.manyvids.com/Video/133957/everthing-about-me/',
20 'md5': '03f11bb21c52dd12a05be21a5c7dcc97',
24 'title': 'everthing about me (Preview)',
25 'uploader': 'ellyxxix',
31 'url': 'https://www.manyvids.com/Video/935718/MY-FACE-REVEAL/',
32 'md5': 'bb47bab0e0802c2a60c24ef079dfe60f',
36 'title': 'MY FACE REVEAL',
37 'description': 'md5:ec5901d41808b3746fed90face161612',
38 'uploader': 'Sarah Calanthe',
44 def _real_extract(self
, url
):
45 video_id
= self
._match
_id
(url
)
47 real_url
= 'https://www.manyvids.com/video/%s/gtm.js' % (video_id
, )
49 webpage
= self
._download
_webpage
(real_url
, video_id
)
51 # probably useless fallback
52 webpage
= self
._download
_webpage
(url
, video_id
)
54 info
= self
._search
_regex
(
55 r
'''(<div\b[^>]*\bid\s*=\s*(['"])pageMetaDetails\2[^>]*>)''',
56 webpage
, 'meta details', default
='')
57 info
= extract_attributes(info
)
59 player
= self
._search
_regex
(
60 r
'''(<div\b[^>]*\bid\s*=\s*(['"])rmpPlayerStream\2[^>]*>)''',
61 webpage
, 'player details', default
='')
62 player
= extract_attributes(player
)
64 video_urls_and_ids
= (
65 (info
.get('data-meta-video'), 'video'),
66 (player
.get('data-video-transcoded'), 'transcoded'),
67 (player
.get('data-video-filepath'), 'filepath'),
68 (self
._og
_search
_video
_url
(webpage
, secure
=False, default
=None), 'og_video'),
71 def txt_or_none(s
, default
=None):
72 return (s
.strip() or default
) if isinstance(s
, str) else default
74 uploader
= txt_or_none(info
.get('data-meta-author'))
78 s
= re
.sub(r
'^\s*%s\s+[|-]' % (re
.escape(uploader
), ), '', s
)
82 mung_title(info
.get('data-meta-title'))
83 or self
._html
_search
_regex
(
84 (r
'<span[^>]+class=["\']item
-title
[^
>]+>([^
<]+)',
85 r'<h2
[^
>]+class=["\']h2 m-0["\'][^
>]*>([^
<]+)'),
86 webpage, 'title
', default=None)
87 or self._html_search_meta(
88 'twitter
:title
', webpage, 'title
', fatal=True))
90 title = re.sub(r'\s
*[|
-]\s
+ManyVids\s
*$
', '', title) or title
92 if any(p in webpage for p in ('preview_videos
', '_preview
.mp4
')):
95 mv_token = self._search_regex(
96 r'data
-mvtoken
=(["\'])(?P<value>(?:(?!\1).)+)\1', webpage,
97 'mv token', default=None, group='value')
101 self._download_webpage(
102 'https://www.manyvids.com/includes/ajax_repository/you_had_me_at_hello.php',
103 video_id, note='Setting format cookies', fatal=False,
104 data=urlencode_postdata({
109 'X-Requested-With': 'XMLHttpRequest'
113 for v_url, fmt in video_urls_and_ids:
114 v_url = url_or_none(v_url)
117 if determine_ext(v_url) == 'm3u8':
118 formats.extend(self._extract_m3u8_formats(
119 v_url, video_id, 'mp4', entry_protocol='m3u8_native',
127 self._remove_duplicate_formats(formats)
130 if f.get('height') is None:
131 f['height'] = int_or_none(
132 self._search_regex(r'_(\d{2,3}[02468])_', f['url'], 'video height', default=None))
133 if '/preview/' in f['url']:
134 f['format_id'] = '_'.join(filter(None, (f.get('format_id'), 'preview')))
135 f['preference'] = -10
136 if 'transcoded' in f['format_id']:
137 f['preference'] = f.get('preference', -1) - 1
140 likes = self._search_regex(
141 r'''(<a\b[^>]*\bdata-id\s*=\s*(['"])%s\
2[^
>]*>)''' % (video_id, ),
142 webpage, 'likes', default='')
143 likes = extract_attributes(likes)
144 return int_or_none(likes.get('data-likes'))
147 return str_to_int(self._html_search_regex(
148 r'''(?s
)<span
\b[^
>]*\bclass\s
*=["']views-wrapper\b[^>]+>.+?<span\b[^>]+>\s*(\d[\d,.]*)\s*</span>''',
149 webpage, 'view count', default=None))
155 'description': txt_or_none(info.get('data-meta-description')),
156 'uploader': txt_or_none(info.get('data-meta-author')),
158 url_or_none(info.get('data-meta-image'))
159 or url_or_none(player.get('data-video-screenshot'))),
160 'view_count': get_views(),
161 'like_count': get_likes(),