sigma67 / ytmusicapi

Unofficial API for YouTube Music
https://ytmusicapi.readthedocs.io
MIT License
1.71k stars 195 forks source link

Upload crashes on the large file: KeyError: 'x-goog-upload-url' #647

Closed ptabor closed 1 day ago

ptabor commented 1 month ago

When trying to upload large file (>300MB audiobook):

The library is crashing with:

# Traceback (most recent call last):
# File "/yt-music/upload.py", line 40, in run
# result = ytmusic.upload_song(file)
# ^^^^^^^^^^^^^^^^^^^^^^^^^
# File "/home/nonroot/.local/lib/python3.12/site-packages/ytmusicapi/mixins/uploads.py", line 237, in upload_song
# upload_url = response.headers["X-Goog-Upload-URL"]
# ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
# File "/home/nonroot/.local/lib/python3.12/site-packages/requests/structures.py", line 52, in __getitem__
# return self._store[key.lower()][1]
# ~~~~~~~~~~~^^^^^^^^^^^^^
# KeyError: 'x-goog-upload-url'
#
# During handling of the above exception, another exception occurred:

Expected output: The upload function should return a failed result.

sigma67 commented 1 day ago

Hi @ptabor , thanks for the report. Unfortunately the traceback is truncated so it's hard to find out what's going wrong.

However I suspect that you have hit the upload size limit, which seems to be around 300MB

https://www.reddit.com/r/YoutubeMusic/comments/gizdjz/upload_size_limit/

We could implement a check that prevents uploads larger than 300 MB.