oauth: add safeguard exception to upload_song

This commit is contained in:
sigma67 2023-04-06 23:00:04 +02:00
commit 69a419f0bd
No known key found for this signature in database
GPG key ID: 1C314227DF0103D0
3 changed files with 6 additions and 0 deletions

View file

@ -4,6 +4,9 @@ brand_account_empty = 1123456629123420379537
headers = headers_auth_json_as_string
headers_empty = headers_account_with_empty_library_as_json_as_string
headers_file = ./headers_auth.json
headers_oauth = ./oauth.json
oauth_code = {"device_code":"","user_code":"","expires_in":1800,"interval":5,"verification_url":"https://www.google.com/device"}
oauth_token = {"access_token":"","expires_in":1000,"refresh_token":"","scope":"https://www.googleapis.com/auth/youtube","token_type":"Bearer"}
headers_raw = raw_headers_pasted_from_browser
[playlists]

View file

@ -466,6 +466,7 @@ class TestYTMusic(unittest.TestCase):
def test_upload_song(self):
self.assertRaises(Exception, self.yt_auth.upload_song, 'song.wav')
self.assertRaises(Exception, self.yt_oauth.upload_song, config['uploads']['file'])
response = self.yt_auth.upload_song(get_resource(config['uploads']['file']))
self.assertEqual(response.status_code, 409)

View file

@ -194,6 +194,8 @@ class UploadsMixin:
:return: Status String or full response
"""
self._check_auth()
if not self.is_browser_auth:
raise Exception("Please provide authentication before using this function")
if not os.path.isfile(filepath):
raise Exception("The provided file does not exist.")