[ie/dropbox] Fix password-protected video extraction (#11636)
[yt-dlp3.git] / yt_dlp / extractor / clippit.py
blob393f21730809d67d1872d217955d7d2eee573e2d
1 import re
3 from .common import InfoExtractor
4 from ..utils import (
5 parse_iso8601,
6 qualities,
10 class ClippitIE(InfoExtractor):
12 _VALID_URL = r'https?://(?:www\.)?clippituser\.tv/c/(?P<id>[a-z]+)'
13 _TEST = {
14 'url': 'https://www.clippituser.tv/c/evmgm',
15 'md5': '963ae7a59a2ec4572ab8bf2f2d2c5f09',
16 'info_dict': {
17 'id': 'evmgm',
18 'ext': 'mp4',
19 'title': 'Bye bye Brutus. #BattleBots - Clippit',
20 'uploader': 'lizllove',
21 'uploader_url': 'https://www.clippituser.tv/p/lizllove',
22 'timestamp': 1472183818,
23 'upload_date': '20160826',
24 'description': 'BattleBots | ABC',
25 'thumbnail': r're:^https?://.*\.jpg$',
29 def _real_extract(self, url):
30 video_id = self._match_id(url)
31 webpage = self._download_webpage(url, video_id)
33 title = self._html_search_regex(r'<title.*>(.+?)</title>', webpage, 'title')
35 FORMATS = ('sd', 'hd')
36 quality = qualities(FORMATS)
37 formats = []
38 for format_id in FORMATS:
39 url = self._html_search_regex(rf'data-{format_id}-file="(.+?)"',
40 webpage, 'url', fatal=False)
41 if not url:
42 continue
43 match = re.search(r'/(?P<height>\d+)\.mp4', url)
44 formats.append({
45 'url': url,
46 'format_id': format_id,
47 'quality': quality(format_id),
48 'height': int(match.group('height')) if match else None,
51 uploader = self._html_search_regex(r'class="username".*>\s+(.+?)\n',
52 webpage, 'uploader', fatal=False)
53 uploader_url = ('https://www.clippituser.tv/p/' + uploader
54 if uploader else None)
56 timestamp = self._html_search_regex(r'datetime="(.+?)"',
57 webpage, 'date', fatal=False)
58 thumbnail = self._html_search_regex(r'data-image="(.+?)"',
59 webpage, 'thumbnail', fatal=False)
61 return {
62 'id': video_id,
63 'title': title,
64 'formats': formats,
65 'uploader': uploader,
66 'uploader_url': uploader_url,
67 'timestamp': parse_iso8601(timestamp),
68 'description': self._og_search_description(webpage),
69 'thumbnail': thumbnail,