[extractor/iwara] Fix format sorting (#6651)

Authored by: hasezoey
pull/6824/head
hasezoey 2 years ago committed by GitHub
parent d1483ec693
commit 56793f74c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -8,6 +8,7 @@ from ..utils import (
OnDemandPagedList, OnDemandPagedList,
int_or_none, int_or_none,
mimetype2ext, mimetype2ext,
qualities,
traverse_obj, traverse_obj,
unified_timestamp, unified_timestamp,
) )
@ -64,13 +65,15 @@ class IwaraIE(InfoExtractor):
# https://github.com/yt-dlp/yt-dlp/issues/6549#issuecomment-1473771047 # https://github.com/yt-dlp/yt-dlp/issues/6549#issuecomment-1473771047
x_version = hashlib.sha1('_'.join((paths[-1], q['expires'][0], '5nFp9kmbNnHdAFhaqMvt')).encode()).hexdigest() x_version = hashlib.sha1('_'.join((paths[-1], q['expires'][0], '5nFp9kmbNnHdAFhaqMvt')).encode()).hexdigest()
preference = qualities(['preview', '360', '540', 'Source'])
files = self._download_json(fileurl, video_id, headers={'X-Version': x_version}) files = self._download_json(fileurl, video_id, headers={'X-Version': x_version})
for fmt in files: for fmt in files:
yield traverse_obj(fmt, { yield traverse_obj(fmt, {
'format_id': 'name', 'format_id': 'name',
'url': ('src', ('view', 'download'), {self._proto_relative_url}), 'url': ('src', ('view', 'download'), {self._proto_relative_url}),
'ext': ('type', {mimetype2ext}), 'ext': ('type', {mimetype2ext}),
'quality': ('name', {lambda x: int_or_none(x) or 1e4}), 'quality': ('name', {preference}),
'height': ('name', {int_or_none}), 'height': ('name', {int_or_none}),
}, get_all=False) }, get_all=False)
@ -84,6 +87,11 @@ class IwaraIE(InfoExtractor):
elif errmsg: elif errmsg:
raise ExtractorError(f'Iwara says: {errmsg}') raise ExtractorError(f'Iwara says: {errmsg}')
if not video_data.get('fileUrl'):
if video_data.get('embedUrl'):
return self.url_result(video_data.get('embedUrl'))
raise ExtractorError('This video is unplayable', expected=True)
return { return {
'id': video_id, 'id': video_id,
'age_limit': 18 if video_data.get('rating') == 'ecchi' else 0, # ecchi is 'sexy' in Japanese 'age_limit': 18 if video_data.get('rating') == 'ecchi' else 0, # ecchi is 'sexy' in Japanese

Loading…
Cancel
Save