[GH-ISSUE #168] struct.error: unpack requires a buffer of 4 bytes #152

Closed
opened 2026-02-27 04:57:50 +03:00 by kerem · 3 comments
Owner

Originally created by @m335671 on GitHub (Feb 10, 2026).
Original GitHub issue: https://github.com/Googolplexed0/zotify/issues/168

Originally assigned to: @Googolplexed0 on GitHub.

Zotify Version
Zotify 0.15.6 on the new hierarchy branch

Bug Description
The crash happens at the start of the command right after the logging in step

Bug Triggering Command
`zotify --client-id MY_CLIENTID --persist --save-credentials "True" -rp "/DATA/Media/Music" -q "very_high" -rt "True" --bulk-wait-time 10 --retry-attempts 30 -ie "True" -ip "True" --print-errors "True" --print-api-errors "True" --print-skips "True" https://open.spotify.com/playlist/myplaylistID

Error Traceback / Logs

Traceback (most recent call last):
  File "/root/.local/bin/zotify", line 6, in <module>
    sys.exit(main())
             ^^^^^^
  File "/root/.local/pipx/venvs/zotify/lib/python3.11/site-packages/zotify/__main__.py", line 142, in main
    Zotify.configure(args)
  File "/root/.local/pipx/venvs/zotify/lib/python3.11/site-packages/zotify/config.py", line 742, in configure
    try: Zotify.login(args)
         ^^^^^^^^^^^^^^^^^^
  File "/root/.local/pipx/venvs/zotify/lib/python3.11/site-packages/zotify/config.py", line 695, in login
    cls.SESSION = session_builder.create()
                  ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.local/pipx/venvs/zotify/lib/python3.11/site-packages/librespot/core.py", line 1679, in create
    session.connect()
  File "/root/.local/pipx/venvs/zotify/lib/python3.11/site-packages/librespot/core.py", line 1068, in connect
    ap_response_message_length = self.connection.read_int()
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.local/pipx/venvs/zotify/lib/python3.11/site-packages/librespot/core.py", line 1956, in read_int
    return struct.unpack(">i", self.read(4))[0]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
struct.error: unpack requires a buffer of 4 bytes

Config File

{
    "ROOT_PATH": "~/Music/Zotify Music",
    "SAVE_CREDENTIALS": "True",
    "CREDENTIALS_LOCATION": "",
    "OUTPUT": "",
    "OUTPUT_SINGLE": "{artist}/{album}/{artist}_{song_name}",
    "OUTPUT_ALBUM": "{artist}/{album}/{album_num}_{artist}_{song_name}",
    "OUTPUT_PLAYLIST_EXT": "{playlist}/{playlist_num}_{artist}_{song_name}",
    "OUTPUT_LIKED_SONGS": "Liked Songs/{artist}_{song_name}",
    "ROOT_PODCAST_PATH": "~/Music/Zotify Podcasts",
    "SPLIT_ALBUM_DISCS": "False",
    "MAX_FILENAME_LENGTH": "0",
    "OPTIMIZED_DOWNLOADING": "True",
    "BULK_WAIT_TIME": "1",
    "DOWNLOAD_REAL_TIME": "False",
    "TEMP_DOWNLOAD_DIR": "",
    "DOWNLOAD_PARENT_ALBUM": "False",
    "NO_COMPILATION_ALBUMS": "False",
    "NO_VARIOUS_ARTISTS": "False",
    "NO_ARTIST_APPEARS_ON": "False",
    "DISCOG_BY_ALBUM_ARTIST": "False",
    "REGEX_ENABLED": "False",
    "REGEX_TRACK_SKIP": "",
    "REGEX_EPISODE_SKIP": "",
    "REGEX_ALBUM_SKIP": "",
    "DOWNLOAD_FORMAT": "copy",
    "DOWNLOAD_QUALITY": "auto",
    "TRANSCODE_BITRATE": "auto",
    "CUSTOM_FFMEPG_ARGS": "",
    "SONG_ARCHIVE_LOCATION": "",
    "DISABLE_SONG_ARCHIVE": "False",
    "DISABLE_DIRECTORY_ARCHIVES": "False",
    "SKIP_EXISTING": "True",
    "SKIP_PREVIOUSLY_DOWNLOADED": "False",
    "EXPORT_M3U8": "False",
    "M3U8_LOCATION": "",
    "M3U8_REL_PATHS": "True",
    "LIKED_SONGS_ARCHIVE_M3U8": "True",
    "LYRICS_TO_METADATA": "True",
    "LYRICS_TO_FILE": "True",
    "LYRICS_LOCATION": "",
    "OUTPUT_LYRICS": "{artist}_{song_name}",
    "ALWAYS_CHECK_LYRICS": "False",
    "LYRICS_MD_HEADER": "False",
    "BYPASS_MD_API": "False",
    "LANGUAGE": "en",
    "MD_DISC_TRACK_TOTALS": "True",
    "MD_SAVE_GENRES": "True",
    "MD_ALLGENRES": "False",
    "MD_GENREDELIMITER": ", ",
    "MD_ARTISTDELIMITER": ", ",
    "SEARCH_QUERY_SIZE": "10",
    "STRICT_LIBRARY_VERIFY": "True",
    "ALBUM_ART_JPG_FILE": "False",
    "RETRY_ATTEMPTS": "1",
    "CHUNK_SIZE": "20000",
    "REDIRECT_ADDRESS": "127.0.0.1",
    "PRINT_SPLASH": "False",
    "PRINT_PROGRESS_INFO": "True",
    "PRINT_SKIPS": "True",
    "PRINT_DOWNLOADS": "True",
    "PRINT_DOWNLOAD_PROGRESS": "True",
    "PRINT_URL_PROGRESS": "True",
    "PRINT_ALBUM_PROGRESS": "True",
    "PRINT_ARTIST_PROGRESS": "True",
    "PRINT_PLAYLIST_PROGRESS": "True",
    "PRINT_WARNINGS": "True",
    "PRINT_ERRORS": "True",
    "PRINT_API_ERRORS": "True",
    "STANDARD_INTERFACE": "False",
    "FFMPEG_LOG_LEVEL": "error"
}

Additional Context
I saw someone mentioning this bug in the #143 issue but the person was saying it has been fixed. I hope its not a duplicate and that i'm only doing a bad command... Sorry i'm a newbie so maybe what i'm reporting is not useful or not a bug. ADDITIONAL NOTE: zotify was working with all of these arguments with 2 other playlists while i was on the efficient api branch, I had to switch branch beacause of the error ValueError: <zotify.api.Track object at 0x7f23f859c3d0> is not in list which is also referenced in #143
and was marked as fixed in the new-hierarchy branch

Originally created by @m335671 on GitHub (Feb 10, 2026). Original GitHub issue: https://github.com/Googolplexed0/zotify/issues/168 Originally assigned to: @Googolplexed0 on GitHub. **Zotify Version** Zotify 0.15.6 on the new hierarchy branch **Bug Description** The crash happens at the start of the command right after the logging in step **Bug Triggering Command** `zotify --client-id MY_CLIENTID --persist --save-credentials "True" -rp "/DATA/Media/Music" -q "very_high" -rt "True" --bulk-wait-time 10 --retry-attempts 30 -ie "True" -ip "True" --print-errors "True" --print-api-errors "True" --print-skips "True" https://open.spotify.com/playlist/myplaylistID **Error Traceback / Logs** ``` Traceback (most recent call last): File "/root/.local/bin/zotify", line 6, in <module> sys.exit(main()) ^^^^^^ File "/root/.local/pipx/venvs/zotify/lib/python3.11/site-packages/zotify/__main__.py", line 142, in main Zotify.configure(args) File "/root/.local/pipx/venvs/zotify/lib/python3.11/site-packages/zotify/config.py", line 742, in configure try: Zotify.login(args) ^^^^^^^^^^^^^^^^^^ File "/root/.local/pipx/venvs/zotify/lib/python3.11/site-packages/zotify/config.py", line 695, in login cls.SESSION = session_builder.create() ^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/.local/pipx/venvs/zotify/lib/python3.11/site-packages/librespot/core.py", line 1679, in create session.connect() File "/root/.local/pipx/venvs/zotify/lib/python3.11/site-packages/librespot/core.py", line 1068, in connect ap_response_message_length = self.connection.read_int() ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/.local/pipx/venvs/zotify/lib/python3.11/site-packages/librespot/core.py", line 1956, in read_int return struct.unpack(">i", self.read(4))[0] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ struct.error: unpack requires a buffer of 4 bytes ``` **Config File** ``` { "ROOT_PATH": "~/Music/Zotify Music", "SAVE_CREDENTIALS": "True", "CREDENTIALS_LOCATION": "", "OUTPUT": "", "OUTPUT_SINGLE": "{artist}/{album}/{artist}_{song_name}", "OUTPUT_ALBUM": "{artist}/{album}/{album_num}_{artist}_{song_name}", "OUTPUT_PLAYLIST_EXT": "{playlist}/{playlist_num}_{artist}_{song_name}", "OUTPUT_LIKED_SONGS": "Liked Songs/{artist}_{song_name}", "ROOT_PODCAST_PATH": "~/Music/Zotify Podcasts", "SPLIT_ALBUM_DISCS": "False", "MAX_FILENAME_LENGTH": "0", "OPTIMIZED_DOWNLOADING": "True", "BULK_WAIT_TIME": "1", "DOWNLOAD_REAL_TIME": "False", "TEMP_DOWNLOAD_DIR": "", "DOWNLOAD_PARENT_ALBUM": "False", "NO_COMPILATION_ALBUMS": "False", "NO_VARIOUS_ARTISTS": "False", "NO_ARTIST_APPEARS_ON": "False", "DISCOG_BY_ALBUM_ARTIST": "False", "REGEX_ENABLED": "False", "REGEX_TRACK_SKIP": "", "REGEX_EPISODE_SKIP": "", "REGEX_ALBUM_SKIP": "", "DOWNLOAD_FORMAT": "copy", "DOWNLOAD_QUALITY": "auto", "TRANSCODE_BITRATE": "auto", "CUSTOM_FFMEPG_ARGS": "", "SONG_ARCHIVE_LOCATION": "", "DISABLE_SONG_ARCHIVE": "False", "DISABLE_DIRECTORY_ARCHIVES": "False", "SKIP_EXISTING": "True", "SKIP_PREVIOUSLY_DOWNLOADED": "False", "EXPORT_M3U8": "False", "M3U8_LOCATION": "", "M3U8_REL_PATHS": "True", "LIKED_SONGS_ARCHIVE_M3U8": "True", "LYRICS_TO_METADATA": "True", "LYRICS_TO_FILE": "True", "LYRICS_LOCATION": "", "OUTPUT_LYRICS": "{artist}_{song_name}", "ALWAYS_CHECK_LYRICS": "False", "LYRICS_MD_HEADER": "False", "BYPASS_MD_API": "False", "LANGUAGE": "en", "MD_DISC_TRACK_TOTALS": "True", "MD_SAVE_GENRES": "True", "MD_ALLGENRES": "False", "MD_GENREDELIMITER": ", ", "MD_ARTISTDELIMITER": ", ", "SEARCH_QUERY_SIZE": "10", "STRICT_LIBRARY_VERIFY": "True", "ALBUM_ART_JPG_FILE": "False", "RETRY_ATTEMPTS": "1", "CHUNK_SIZE": "20000", "REDIRECT_ADDRESS": "127.0.0.1", "PRINT_SPLASH": "False", "PRINT_PROGRESS_INFO": "True", "PRINT_SKIPS": "True", "PRINT_DOWNLOADS": "True", "PRINT_DOWNLOAD_PROGRESS": "True", "PRINT_URL_PROGRESS": "True", "PRINT_ALBUM_PROGRESS": "True", "PRINT_ARTIST_PROGRESS": "True", "PRINT_PLAYLIST_PROGRESS": "True", "PRINT_WARNINGS": "True", "PRINT_ERRORS": "True", "PRINT_API_ERRORS": "True", "STANDARD_INTERFACE": "False", "FFMPEG_LOG_LEVEL": "error" } ``` **Additional Context** I saw someone mentioning this bug in the #143 issue but the person was saying it has been fixed. I hope its not a duplicate and that i'm only doing a bad command... Sorry i'm a newbie so maybe what i'm reporting is not useful or not a bug. ADDITIONAL NOTE: zotify was working with all of these arguments with 2 other playlists while i was on the efficient api branch, I had to switch branch beacause of the error `ValueError: <zotify.api.Track object at 0x7f23f859c3d0> is not in list` which is also referenced in #143 and was marked as fixed in the new-hierarchy branch
kerem 2026-02-27 04:57:50 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@RGPZ commented on GitHub (Feb 11, 2026):

Try run the command again, I get this error every now and then and after a rerun it just works.

<!-- gh-comment-id:3883545257 --> @RGPZ commented on GitHub (Feb 11, 2026): Try run the command again, I get this error every now and then and after a rerun it just works.
Author
Owner

@m335671 commented on GitHub (Feb 11, 2026):

Thanks for the reply ! I hope this will be fixed one day...

<!-- gh-comment-id:3884857247 --> @m335671 commented on GitHub (Feb 11, 2026): Thanks for the reply ! I hope this will be fixed one day...
Author
Owner

@Googolplexed0 commented on GitHub (Feb 12, 2026):

File "/root/.local/pipx/venvs/zotify/lib/python3.11/site-packages/librespot/core.py", line 1956, in read_int
return struct.unpack(">i", self.read(4))[0]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
struct.error: unpack requires a buffer of 4 bytes

Unfortunately, this is an erratic bug within librespot, not this project. Not sure what causes it or how to fix it. See #331.

<!-- gh-comment-id:3888124900 --> @Googolplexed0 commented on GitHub (Feb 12, 2026): > File "/root/.local/pipx/venvs/zotify/lib/python3.11/site-packages/librespot/core.py", line 1956, in read_int > return struct.unpack(">i", self.read(4))[0] > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > struct.error: unpack requires a buffer of 4 bytes Unfortunately, this is an erratic bug within librespot, not this project. Not sure what causes it or how to fix it. See [#331](https://github.com/kokarare1212/librespot-python/issues/331).
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/zotify#152
No description provided.