Encode filename with UTF-8 before upload (fixes #5)

This commit is contained in:
sigma67 2020-04-13 21:37:11 +02:00
commit 6cdfb39055
No known key found for this signature in database
GPG key ID: 1545A01D4474BAF0
2 changed files with 2 additions and 2 deletions

View file

@ -34,7 +34,7 @@ class TestYTMusic(unittest.TestCase):
self.assertEqual(len(results), 50)
def test_upload_song(self):
response = youtube_auth.upload_song('../Madeon.mp3')
response = youtube_auth.upload_song('../12 - Turning Point 자.mp3')
self.assertEqual(response, 'STATUS_SUCCEEDED')
def test_delete_uploaded_song(self):

View file

@ -466,7 +466,7 @@ class YTMusic:
headers = self.headers
upload_url = "https://upload.youtube.com/upload/usermusic/http?authuser=0"
filesize = os.path.getsize(filepath)
body = "filename=" + ntpath.basename(filepath)
body = ("filename=" + ntpath.basename(filepath)).encode('utf-8')
headers['content-type'] = 'application/x-www-form-urlencoded;charset=utf-8'
headers['X-Goog-Upload-Command'] = 'start'
headers['X-Goog-Upload-Header-Content-Length'] = str(filesize)