X-Git-Url: https://git.mdrn.pl/audio.git/blobdiff_plain/4660a2368dbaa858636ca3ab8b64433b721b1457..7a7629297f382c47a84ec5786c8cdd52224887ae:/src/apiclient/models.py diff --git a/src/apiclient/models.py b/src/apiclient/models.py index ae8c74a..07f804f 100644 --- a/src/apiclient/models.py +++ b/src/apiclient/models.py @@ -37,24 +37,27 @@ class YouTubeToken(models.Model): token_updater=self.token_updater ) - def call(self, method, url, params=None, data=None, media_data=None): + def call(self, method, url, params=None, json=None, data=None, resumable_data=None): params = params or {} - params['uploadType'] = 'resumable' + if resumable_data: + params['uploadType'] = 'resumable' session = self.get_session() response = session.request( method=method, url=url, - json=data, + json=json, + data=data, params=params, headers={ - 'X-Upload-Content-Length': str(len(media_data)), + 'X-Upload-Content-Length': str(len(resumable_data)), 'x-upload-content-type': 'application/octet-stream', - } - ) - location = response.headers['Location'] - return session.put( - url=location, - data=media_data, - headers={"Content-Type": "application/octet-stream"}, + } if resumable_data else {} ) + if resumable_data: + location = response.headers['Location'] + return session.put( + url=location, + data=resumable_data, + headers={"Content-Type": "application/octet-stream"}, + )