[ie/soundcloud] Various fixes (#11820)
[yt-dlp.git] / yt_dlp / extractor / bigflix.py
blob9c55bb9682ef31cf2685079462b9df600a696c74
1 import base64
2 import re
3 import urllib.parse
5 from .common import InfoExtractor
8 class BigflixIE(InfoExtractor):
9 _VALID_URL = r'https?://(?:www\.)?bigflix\.com/.+/(?P<id>[0-9]+)'
10 _TESTS = [{
11 # 2 formats
12 'url': 'http://www.bigflix.com/Tamil-movies/Drama-movies/Madarasapatinam/16070',
13 'info_dict': {
14 'id': '16070',
15 'ext': 'mp4',
16 'title': 'Madarasapatinam',
17 'description': 'md5:9f0470b26a4ba8e824c823b5d95c2f6b',
18 'formats': 'mincount:2',
20 'params': {
21 'skip_download': True,
23 }, {
24 # multiple formats
25 'url': 'http://www.bigflix.com/Malayalam-movies/Drama-movies/Indian-Rupee/15967',
26 'only_matching': True,
29 def _real_extract(self, url):
30 video_id = self._match_id(url)
32 webpage = self._download_webpage(url, video_id)
34 title = self._html_search_regex(
35 r'<div[^>]+class=["\']pagetitle["\'][^>]*>(.+?)</div>',
36 webpage, 'title')
38 def decode_url(quoted_b64_url):
39 return base64.b64decode(urllib.parse.unquote(
40 quoted_b64_url)).decode('utf-8')
42 formats = []
43 for height, encoded_url in re.findall(
44 r'ContentURL_(\d{3,4})[pP][^=]+=([^&]+)', webpage):
45 video_url = decode_url(encoded_url)
46 f = {
47 'url': video_url,
48 'format_id': f'{height}p',
49 'height': int(height),
51 if video_url.startswith('rtmp'):
52 f['ext'] = 'flv'
53 formats.append(f)
55 file_url = self._search_regex(
56 r'file=([^&]+)', webpage, 'video url', default=None)
57 if file_url:
58 video_url = decode_url(file_url)
59 if all(f['url'] != video_url for f in formats):
60 formats.append({
61 'url': decode_url(file_url),
64 description = self._html_search_meta('description', webpage)
66 return {
67 'id': video_id,
68 'title': title,
69 'description': description,
70 'formats': formats,