OK to use assert for developer errors

Authored by: bashonly
This commit is contained in:
bashonly 2025-04-30 01:26:36 -05:00
parent daf2be0f25
commit 6464bfa78c
No known key found for this signature in database
GPG Key ID: 783F096F253D15B0

View File

@ -5,7 +5,6 @@ import time
from .common import InfoExtractor from .common import InfoExtractor
from ..utils import ( from ..utils import (
ExtractorError,
determine_ext, determine_ext,
filter_dict, filter_dict,
float_or_none, float_or_none,
@ -141,19 +140,17 @@ class ZDFBaseIE(InfoExtractor):
} }
def _download_graphql(self, item_id, data_desc, query=None, body=None): def _download_graphql(self, item_id, data_desc, query=None, body=None):
if not query and not body: assert query or body, 'One of query or body is required'
raise ExtractorError(
'GraphQL API requires either query parameters or a body',
video_id=item_id)
return self._download_json( return self._download_json(
'https://api.zdf.de/graphql', item_id, note=f'Downloading {data_desc}', 'https://api.zdf.de/graphql', item_id,
errnote=f'Failed to download {data_desc}', query=query, f'Downloading {data_desc}', f'Failed to download {data_desc}',
data=json.dumps(body).encode() if body else None, headers={ query=query, data=json.dumps(body).encode() if body else None,
headers=filter_dict({
'Api-Auth': self._get_api_token(), 'Api-Auth': self._get_api_token(),
'Apollo-Require-Preflight': True, 'Apollo-Require-Preflight': True,
'Content-Type': 'application/json' if body else None, 'Content-Type': 'application/json' if body else None,
}) }))
@staticmethod @staticmethod
def _extract_thumbnails(source): def _extract_thumbnails(source):