import json
import random
import re
+import urllib.parse
from .common import InfoExtractor
-from ..compat import compat_ord, compat_urllib_parse_unquote
+from ..compat import compat_ord
from ..utils import (
ExtractorError,
float_or_none,
'age_limit': 0,
'upload_date': '20160221',
'timestamp': 1456078244,
- }
+ },
}, {
'url': 'http://www.cda.pl/video/57413289',
'md5': 'a88828770a8310fc00be6c95faf7f4d5',
'age_limit': 0,
'upload_date': '20160220',
'timestamp': 1455968218,
- }
+ },
}, {
# Age-restricted with vfilm redirection
'url': 'https://www.cda.pl/video/8753244c4',
'average_rating': float,
'timestamp': 1633888264,
'upload_date': '20211010',
- }
+ },
}, {
# Age-restricted without vfilm redirection
'url': 'https://www.cda.pl/video/17028157b8',
'average_rating': float,
'timestamp': 1699705901,
'upload_date': '20231111',
- }
+ },
}, {
'url': 'http://ebd.cda.pl/0x0/5749950c',
'only_matching': True,
def decrypt_file(a):
for p in ('_XDDD', '_CDA', '_ADC', '_CXD', '_QWE', '_Q5', '_IKSDE'):
a = a.replace(p, '')
- a = compat_urllib_parse_unquote(a)
+ a = urllib.parse.unquote(a)
b = []
for c in a:
f = compat_ord(c)
def extract_format(page, version):
json_str = self._html_search_regex(
r'player_data=(\\?["\'])(?P<player_data>.+?)\1', page,
- '%s player_json' % version, fatal=False, group='player_data')
+ f'{version} player_json', fatal=False, group='player_data')
if not json_str:
return
player_data = self._parse_json(
- json_str, '%s player_data' % version, fatal=False)
+ json_str, f'{version} player_data', fatal=False)
if not player_data:
return
video = player_data.get('video')
if not video or 'file' not in video:
- self.report_warning('Unable to extract %s version information' % version)
+ self.report_warning(f'Unable to extract {version} version information')
return
if video['file'].startswith('uggc'):
video['file'] = codecs.decode(video['file'], 'rot_13')
continue
data = {'jsonrpc': '2.0', 'method': 'videoGetLink', 'id': 2,
'params': [video_id, cda_quality, video.get('ts'), video.get('hash2'), {}]}
- data = json.dumps(data).encode('utf-8')
+ data = json.dumps(data).encode()
video_url = self._download_json(
f'https://www.cda.pl/video/{video_id}', video_id, headers={
'Content-Type': 'application/json',
- 'X-Requested-With': 'XMLHttpRequest'
+ 'X-Requested-With': 'XMLHttpRequest',
}, data=data, note=f'Fetching {quality} url',
errnote=f'Failed to fetch {quality} url', fatal=False)
if try_get(video_url, lambda x: x['result']['status']) == 'ok':
info_dict['formats'].append({
'url': video_url,
'format_id': quality,
- 'height': int_or_none(quality[:-1])
+ 'height': int_or_none(quality[:-1]),
})
if not info_dict['duration']:
webpage = handler(
urljoin(self._BASE_URL, href), video_id,
- 'Downloading %s version information' % resolution, fatal=False)
+ f'Downloading {resolution} version information', fatal=False)
if not webpage:
# Manually report warning because empty page is returned when
# invalid version is requested.
- self.report_warning('Unable to download %s version information' % resolution)
+ self.report_warning(f'Unable to download {resolution} version information')
continue
extract_format(webpage, resolution)