X-Git-Url: https://git.mdrn.pl/audio.git/blobdiff_plain/d7186e88fcc0cf5d5449a16d3907e01aaafc484e..d59a371f240c5fa1dbce1bd40a61e60c60a19d2a:/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"}, + )