[ie/wistia] Support password-protected videos (#11100)
[yt-dlp3.git] / yt_dlp / extractor / vuclip.py
blobad7eab351e3bda9f7a00c5b2c2eb49c81f82adc8
1 import re
2 import urllib.parse
4 from .common import InfoExtractor
5 from ..utils import (
6 ExtractorError,
7 parse_duration,
8 remove_end,
12 class VuClipIE(InfoExtractor):
13 _VALID_URL = r'https?://(?:m\.)?vuclip\.com/w\?.*?cid=(?P<id>[0-9]+)'
15 _TEST = {
16 'url': 'http://m.vuclip.com/w?cid=1129900602&bu=8589892792&frm=w&z=34801&op=0&oc=843169247&section=recommend',
17 'info_dict': {
18 'id': '1129900602',
19 'ext': '3gp',
20 'title': 'Top 10 TV Convicts',
21 'duration': 733,
25 def _real_extract(self, url):
26 video_id = self._match_id(url)
27 webpage = self._download_webpage(url, video_id)
29 ad_m = re.search(
30 r'''value="No.*?" onClick="location.href='([^"']+)'"''', webpage)
31 if ad_m:
32 urlr = urllib.parse.urlparse(url)
33 adfree_url = urlr.scheme + '://' + urlr.netloc + ad_m.group(1)
34 webpage = self._download_webpage(
35 adfree_url, video_id, note='Download post-ad page')
37 error_msg = self._html_search_regex(
38 r'<p class="message">(.*?)</p>', webpage, 'error message',
39 default=None)
40 if error_msg:
41 raise ExtractorError(
42 f'{self.IE_NAME} said: {error_msg}', expected=True)
44 # These clowns alternate between two page types
45 video_url = self._search_regex(
46 r'<a[^>]+href="([^"]+)"[^>]*><img[^>]+src="[^"]*/play\.gif',
47 webpage, 'video URL', default=None)
48 if video_url:
49 formats = [{
50 'url': video_url,
52 else:
53 formats = self._parse_html5_media_entries(url, webpage, video_id)[0]['formats']
55 title = remove_end(self._html_search_regex(
56 r'<title>(.*?)-\s*Vuclip</title>', webpage, 'title').strip(), ' - Video')
58 duration = parse_duration(self._html_search_regex(
59 r'[(>]([0-9]+:[0-9]+)(?:<span|\))', webpage, 'duration', fatal=False))
61 return {
62 'id': video_id,
63 'formats': formats,
64 'title': title,
65 'duration': duration,