[GH-ISSUE #158] [Bug Report] Unwanted Track Copies In Shared Directory #141

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

Originally created by @carlyd95 on GitHub (Jan 22, 2026).
Original GitHub issue: https://github.com/Googolplexed0/zotify/issues/158

Originally assigned to: @Googolplexed0 on GitHub.

Zotify Version
v0.15.3 (new-hierarchy)

Bug Description
There are 2 scenarios that have unfavorable outcomes with optimized downloading (OD) on or off.

Scenario 1:

Description: first download of track shared by multiple playlists (batch download playlists required)

Outcome:

OD = True: Downloads the shared track but then copies it n times (n = # of playlists in the batch that contain the track -1)

OD = False: Downloads the shared track but then encounters an error upon second reference in the next playlist

Scenario 2:

Description: download a track that already has a file saved via a different track ID

Example tracks:
https://open.spotify.com/track/0Ftrkz2waaHcjKb4qYvLmz
https://open.spotify.com/track/3wJrBiiTIRRfKSL2TQWR60

Outcome:

OD = True: FIle is already present but still it donwloads/copies it n times (n = # of playlists in the batch that contain the track)

OD = False: File is already present but still it downloads/copies it 1 time

Bug Triggering Command
sudo -u pi /home/pi/.local/bin/zotify -f tz.txt --download-format mp3 --download-quality very_high --root-path /media/pi/X9/DJ/Music --output "{artist} - {song_name}" --download-real-time True --md-save-genres True --client-id XXXXXXXXXXXXXXXXXX --debug --optimized-downloading (False or True)

Error Traceback / Logs

OUTPUT:

Scenario 1 (OD=True):
No output issues.

Scenario 1 (OD=False):
`DEBUG
Duplicate Check
File Already Exists: False
id in Local Archive: False
id in Global Archive: False

[∙∙∙] Preparing Download...
[∙∙●] Fetching lyrics...

SKIPPING: LYRICS FOR "Billie Eilish - BIRDS OF A FEATHER" (LYRICS NOT AVAILABLE)

[∙∙●] Converting File...
### WARNING: ATTEMPT TO CLONE TRACK "KREAM - Sweat" FAILED ###
### FALLING BACK TO REDOWNLOAD ###
### EXPECTED SOURCE FILES THAT DO NOT EXIST: ###
### ERROR: UNEXPECTED ERROR DURING DOWNLOADS ###
### ATTEMPTING TO CLEAN UP ###

Traceback (most recent call last):
File "/home/pi/.local/share/pipx/venvs/zotify/lib/python3.11/site-packages/zotify/api.py", line 1478, in download
try: super().download(ParentStack([self]))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pi/.local/share/pipx/venvs/zotify/lib/python3.11/site-packages/zotify/api.py", line 1095, in download
item.download(parent_stack)
File "/home/pi/.local/share/pipx/venvs/zotify/lib/python3.11/site-packages/zotify/api.py", line 1095, in download
item.download(parent_stack)
File "/home/pi/.local/share/pipx/venvs/zotify/lib/python3.11/site-packages/zotify/api.py", line 738, in download
elif self.downloaded and self.clone_file(parent_stack):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pi/.local/share/pipx/venvs/zotify/lib/python3.11/site-packages/zotify/api.py", line 495, in clone_file
Printer.json_dump(self.real_filepaths)
File "/home/pi/.local/share/pipx/venvs/zotify/lib/python3.11/site-packages/zotify/termoutput.py", line 202, in json_dump
obj = Printer._api_shrink(obj)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pi/.local/share/pipx/venvs/zotify/lib/python3.11/site-packages/zotify/termoutput.py", line 129, in _api_shrink
for k, v in obj.items():
RuntimeError: dictionary changed size during iteration

### ERROR: CLEAN UP COMPLETE ###
### LOGGING ERROR AND TRACEBACK ###

DEBUG
Total API Calls: 6

Traceback (most recent call last):
File "/home/pi/.local/bin/zotify", line 7, in
sys.exit(main())
^^^^^^
File "/home/pi/.local/share/pipx/venvs/zotify/lib/python3.11/site-packages/zotify/main.py", line 143, in main
client(args, modes)
File "/home/pi/.local/share/pipx/venvs/zotify/lib/python3.11/site-packages/zotify/app.py", line 186, in client
perform_query(args)
File "/home/pi/.local/share/pipx/venvs/zotify/lib/python3.11/site-packages/zotify/app.py", line 178, in perform_query
raise e
File "/home/pi/.local/share/pipx/venvs/zotify/lib/python3.11/site-packages/zotify/app.py", line 149, in perform_query
Query(Zotify.DATETIME_LAUNCH).request(urls).execute()
File "/home/pi/.local/share/pipx/venvs/zotify/lib/python3.11/site-packages/zotify/api.py", line 1519, in execute
self.download()
File "/home/pi/.local/share/pipx/venvs/zotify/lib/python3.11/site-packages/zotify/api.py", line 1508, in download
raise interrupt
File "/home/pi/.local/share/pipx/venvs/zotify/lib/python3.11/site-packages/zotify/api.py", line 1478, in download
try: super().download(ParentStack([self]))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pi/.local/share/pipx/venvs/zotify/lib/python3.11/site-packages/zotify/api.py", line 1095, in download
item.download(parent_stack)
File "/home/pi/.local/share/pipx/venvs/zotify/lib/python3.11/site-packages/zotify/api.py", line 1095, in download
item.download(parent_stack)
File "/home/pi/.local/share/pipx/venvs/zotify/lib/python3.11/site-packages/zotify/api.py", line 738, in download
elif self.downloaded and self.clone_file(parent_stack):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pi/.local/share/pipx/venvs/zotify/lib/python3.11/site-packages/zotify/api.py", line 495, in clone_file
Printer.json_dump(self.real_filepaths)
File "/home/pi/.local/share/pipx/venvs/zotify/lib/python3.11/site-packages/zotify/termoutput.py", line 202, in json_dump
obj = Printer._api_shrink(obj)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pi/.local/share/pipx/venvs/zotify/lib/python3.11/site-packages/zotify/termoutput.py", line 129, in _api_shrink
for k, v in obj.items():
RuntimeError: dictionary changed size during iteration`

Scenario 2 output is the same respective of the OD setting

DEBUG:

Scenario 1 (OD=True):
zotify_DEBUG_2026-01-22_00-23-15.log

Scenario 1 (OD=False):
zotify_DEBUG_2026-01-22_00-25-28.log

Scenario 2 (OD=True):
zotify_DEBUG_2026-01-22_00-53-57.log

Scenario 2 (OD=False):
zotify_DEBUG_2026-01-22_00-57-53.log

Config File
config_DEBUG.json

Additional Comments
Saving all songs to a shared Music folder is potentially dependent to repeat these errors. I saved the tracks with the format: {artist} - {song_name}. I am not using Zotify's m3u8 feature currently.

Thank you!

Originally created by @carlyd95 on GitHub (Jan 22, 2026). Original GitHub issue: https://github.com/Googolplexed0/zotify/issues/158 Originally assigned to: @Googolplexed0 on GitHub. **Zotify Version** v0.15.3 (new-hierarchy) **Bug Description** There are 2 scenarios that have unfavorable outcomes with optimized downloading (OD) on or off. ### Scenario 1: **Description:** first download of track shared by multiple playlists (batch download playlists required) **Outcome:** > OD = True: Downloads the shared track but then copies it n times (n = # of playlists in the batch that contain the track -1) > OD = False: Downloads the shared track but then encounters an error upon second reference in the next playlist ### Scenario 2: **Description:** download a track that already has a file saved via a different track ID **Example tracks:** https://open.spotify.com/track/0Ftrkz2waaHcjKb4qYvLmz https://open.spotify.com/track/3wJrBiiTIRRfKSL2TQWR60 **Outcome:** > OD = True: FIle is already present but still it donwloads/copies it n times (n = # of playlists in the batch that contain the track) > OD = False: File is already present but still it downloads/copies it 1 time **Bug Triggering Command** sudo -u pi /home/pi/.local/bin/zotify -f tz.txt --download-format mp3 --download-quality very_high --root-path /media/pi/X9/DJ/Music --output "{artist} - {song_name}" --download-real-time True --md-save-genres True --client-id XXXXXXXXXXXXXXXXXX --debug --optimized-downloading (False or True) **Error Traceback / Logs** ### OUTPUT: **Scenario 1 (OD=True):** No output issues. **Scenario 1 (OD=False):** `DEBUG Duplicate Check File Already Exists: False id in Local Archive: False id in Global Archive: False [∙∙∙] Preparing Download... [∙∙●] Fetching lyrics... ### SKIPPING: LYRICS FOR "Billie Eilish - BIRDS OF A FEATHER" (LYRICS NOT AVAILABLE) ### [∙∙●] Converting File... \### WARNING: ATTEMPT TO CLONE TRACK "KREAM - Sweat" FAILED ### \### FALLING BACK TO REDOWNLOAD ### \### EXPECTED SOURCE FILES THAT DO NOT EXIST: ### \### ERROR: UNEXPECTED ERROR DURING DOWNLOADS ### \### ATTEMPTING TO CLEAN UP ### Traceback (most recent call last): File "/home/pi/.local/share/pipx/venvs/zotify/lib/python3.11/site-packages/zotify/api.py", line 1478, in download try: super().download(ParentStack([self])) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/.local/share/pipx/venvs/zotify/lib/python3.11/site-packages/zotify/api.py", line 1095, in download item.download(parent_stack) File "/home/pi/.local/share/pipx/venvs/zotify/lib/python3.11/site-packages/zotify/api.py", line 1095, in download item.download(parent_stack) File "/home/pi/.local/share/pipx/venvs/zotify/lib/python3.11/site-packages/zotify/api.py", line 738, in download elif self.downloaded and self.clone_file(parent_stack): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/.local/share/pipx/venvs/zotify/lib/python3.11/site-packages/zotify/api.py", line 495, in clone_file Printer.json_dump(self.real_filepaths) File "/home/pi/.local/share/pipx/venvs/zotify/lib/python3.11/site-packages/zotify/termoutput.py", line 202, in json_dump obj = Printer._api_shrink(obj) ^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/.local/share/pipx/venvs/zotify/lib/python3.11/site-packages/zotify/termoutput.py", line 129, in _api_shrink for k, v in obj.items(): RuntimeError: dictionary changed size during iteration \### ERROR: CLEAN UP COMPLETE ### \### LOGGING ERROR AND TRACEBACK ### DEBUG Total API Calls: 6 Traceback (most recent call last): File "/home/pi/.local/bin/zotify", line 7, in <module> sys.exit(main()) ^^^^^^ File "/home/pi/.local/share/pipx/venvs/zotify/lib/python3.11/site-packages/zotify/__main__.py", line 143, in main client(args, modes) File "/home/pi/.local/share/pipx/venvs/zotify/lib/python3.11/site-packages/zotify/app.py", line 186, in client perform_query(args) File "/home/pi/.local/share/pipx/venvs/zotify/lib/python3.11/site-packages/zotify/app.py", line 178, in perform_query raise e File "/home/pi/.local/share/pipx/venvs/zotify/lib/python3.11/site-packages/zotify/app.py", line 149, in perform_query Query(Zotify.DATETIME_LAUNCH).request(urls).execute() File "/home/pi/.local/share/pipx/venvs/zotify/lib/python3.11/site-packages/zotify/api.py", line 1519, in execute self.download() File "/home/pi/.local/share/pipx/venvs/zotify/lib/python3.11/site-packages/zotify/api.py", line 1508, in download raise interrupt File "/home/pi/.local/share/pipx/venvs/zotify/lib/python3.11/site-packages/zotify/api.py", line 1478, in download try: super().download(ParentStack([self])) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/.local/share/pipx/venvs/zotify/lib/python3.11/site-packages/zotify/api.py", line 1095, in download item.download(parent_stack) File "/home/pi/.local/share/pipx/venvs/zotify/lib/python3.11/site-packages/zotify/api.py", line 1095, in download item.download(parent_stack) File "/home/pi/.local/share/pipx/venvs/zotify/lib/python3.11/site-packages/zotify/api.py", line 738, in download elif self.downloaded and self.clone_file(parent_stack): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/.local/share/pipx/venvs/zotify/lib/python3.11/site-packages/zotify/api.py", line 495, in clone_file Printer.json_dump(self.real_filepaths) File "/home/pi/.local/share/pipx/venvs/zotify/lib/python3.11/site-packages/zotify/termoutput.py", line 202, in json_dump obj = Printer._api_shrink(obj) ^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/.local/share/pipx/venvs/zotify/lib/python3.11/site-packages/zotify/termoutput.py", line 129, in _api_shrink for k, v in obj.items(): RuntimeError: dictionary changed size during iteration` Scenario 2 output is the same respective of the OD setting ### DEBUG: **Scenario 1 (OD=True):** [zotify_DEBUG_2026-01-22_00-23-15.log](https://github.com/user-attachments/files/24787051/zotify_DEBUG_2026-01-22_00-23-15.log) **Scenario 1 (OD=False):** [zotify_DEBUG_2026-01-22_00-25-28.log](https://github.com/user-attachments/files/24787063/zotify_DEBUG_2026-01-22_00-25-28.log) **Scenario 2 (OD=True):** [zotify_DEBUG_2026-01-22_00-53-57.log](https://github.com/user-attachments/files/24787086/zotify_DEBUG_2026-01-22_00-53-57.log) **Scenario 2 (OD=False):** [zotify_DEBUG_2026-01-22_00-57-53.log](https://github.com/user-attachments/files/24787094/zotify_DEBUG_2026-01-22_00-57-53.log) **Config File** [config_DEBUG.json](https://github.com/user-attachments/files/24727970/config_DEBUG.json) **Additional Comments** Saving all songs to a shared Music folder is potentially dependent to repeat these errors. I saved the tracks with the format: {artist} - {song_name}. I am not using Zotify's m3u8 feature currently. Thank you!
kerem 2026-02-27 04:57:47 +03:00
  • closed this issue
  • added the
    bug
    stale
    labels
Author
Owner

@Googolplexed0 commented on GitHub (Jan 29, 2026):

All four testcases should be fixed and behave as expected after github.com/Googolplexed0/zotify@c1575b96d3. I accidentally both skipped some important checks when cloning and had a few checks against a value never updated from its initial None state.

For most use cases, there should still be cloning of the same track between file locations. For yours specifically, since all potential clones would be in the same directory and share a filename/filepath with the originals, there should be no cloning and therefore no duplicates. Please confirm if it does work for you.

<!-- gh-comment-id:3815206263 --> @Googolplexed0 commented on GitHub (Jan 29, 2026): All four testcases should be fixed and behave as expected after https://github.com/Googolplexed0/zotify/commit/c1575b96d33fcfbb1e27fcc910144ddeb3379bad. I accidentally both skipped some important checks when cloning and had a few checks against a value never updated from its initial `None` state. For most use cases, there should still be cloning of the same track between file locations. For yours specifically, since all potential clones would be in the same directory and share a filename/filepath with the originals, there should be no cloning and therefore no duplicates. Please confirm if it does work for you.
Author
Owner

@carlyd95 commented on GitHub (Feb 26, 2026):

@Googolplexed0 Sorry for the lack of response I was sick for a week and just got behind on a lot of responsibilities.

Thank you for your support! Looks like there still seems to be some issues with batch playlists from file.

Scenario 1 (OD Issues):

Description: first download of track shared by multiple playlists (batch download playlists required)

OD = false: FIXED!
OD = true: seems to skip all new songs, It doesn't even try to download them.

Output:
`DEBUG
### config_DEBUG.json saved to /home/pi/.config/zotify ###
### zotify_DEBUG_2026-02-25_22-49-16.log logging to /media/pi/X9/DJ/Music ###

[∙●∙] Logging in...
### WARNING: LOGIN FAILED (111) ###
### TRYING AGAIN AFTER SMALL WAIT ###

[∙∙∙] Logging in...
DEBUG
Session Initialized Successfully
User Subscription Type: PREMIUM
Request Parsed as 2 URLs

[∙∙●] Fetching playlist information...
[∙∙●] Fetching playlist information...
[●∙∙] Parsing playlist information...
[∙∙●] Fetching bulk genre information...
[∙∙●] Fetching bulk track/disc total information...
DEBUG
Total API Calls: 4`

Command Used:
sudo -u pi /home/pi/.local/bin/zotify -f tz.txt --download-format mp3 --download-quality very_high --root-path /media/pi/X9/DJ/Music --output "{artist} - {song_name}" --download-real-time True --md-save-genres True --client-id XXXXXXXXXXXXXXXXXXXX --debug --optimized-downloading True

Debug Log:
zotify_DEBUG_2026-02-25_22-49-16.log

Additional Note:
The original test was done with 2 playlists that both have the same single song which I have not downloaded before. I did another test by adding another song to both playlists that has already been downloaded and it outputs the following twice (once per playlist) but never outputs anything related to the track that has never been downloaded:

### SKIPPING: "AFRONOM - Spice" (TRACK DOWNLOADED PREVIOUSLY) ###
### FILE: "AFRONOM - Spice.mp3" ###

Scenario 2 (FIXED):

Description: download a track that already has a file saved via a different track ID

OD = false: Saves a duplicate for any track that has multiple track id references

Example in my .song_ids:

7fc4OLUDFGSbfBfwp6gWua 2025-06-07 02:46:17 Armin van Buuren Angels /media/pi/X9/DJ/Music/Armin van Buuren - Angels.mp3
0QWfgffeGPTSuoPgAzXxYh 2026-02-25 23:12:22 Armin van Buuren Angels /media/pi/X9/DJ/Music/Armin van Buuren - Angels_1.mp3

OD = true: Does not output anything related to the "new" track with the ID of 0QWfgffeGPTSuoPgAzXxYh like scenario 1 with OD set to true.

<!-- gh-comment-id:3963815665 --> @carlyd95 commented on GitHub (Feb 26, 2026): @Googolplexed0 Sorry for the lack of response I was sick for a week and just got behind on a lot of responsibilities. Thank you for your support! Looks like there still seems to be some issues with batch playlists from file. ### Scenario 1 (OD Issues): **Description:** first download of track shared by multiple playlists (batch download playlists required) >**OD = false:** FIXED! >**OD = true:** seems to skip all new songs, It doesn't even try to download them. **Output:** `DEBUG \### config_DEBUG.json saved to /home/pi/.config/zotify ### \### zotify_DEBUG_2026-02-25_22-49-16.log logging to /media/pi/X9/DJ/Music ### [∙●∙] Logging in... \### WARNING: LOGIN FAILED (111) ### \### TRYING AGAIN AFTER SMALL WAIT ### [∙∙∙] Logging in... DEBUG Session Initialized Successfully User Subscription Type: PREMIUM Request Parsed as 2 URLs [∙∙●] Fetching playlist information... [∙∙●] Fetching playlist information... [●∙∙] Parsing playlist information... [∙∙●] Fetching bulk genre information... [∙∙●] Fetching bulk track/disc total information... DEBUG Total API Calls: 4` **Command Used:** sudo -u pi /home/pi/.local/bin/zotify -f tz.txt --download-format mp3 --download-quality very_high --root-path /media/pi/X9/DJ/Music --output "{artist} - {song_name}" --download-real-time True --md-save-genres True --client-id XXXXXXXXXXXXXXXXXXXX --debug --optimized-downloading True **Debug Log:** [zotify_DEBUG_2026-02-25_22-49-16.log](https://github.com/user-attachments/files/25563419/zotify_DEBUG_2026-02-25_22-49-16.log) **Additional Note:** The original test was done with 2 playlists that both have the same single song which I have not downloaded before. I did another test by adding another song to both playlists that has already been downloaded and it outputs the following twice (once per playlist) but never outputs anything related to the track that has never been downloaded: >\### SKIPPING: "AFRONOM - Spice" (TRACK DOWNLOADED PREVIOUSLY) ### >\### FILE: "AFRONOM - Spice.mp3" ### ### Scenario 2 (FIXED): **Description:** download a track that already has a file saved via a different track ID >**OD = false:** Saves a duplicate for any track that has multiple track id references **Example in my .song_ids:** >7fc4OLUDFGSbfBfwp6gWua 2025-06-07 02:46:17 Armin van Buuren Angels /media/pi/X9/DJ/Music/Armin van Buuren - Angels.mp3 >0QWfgffeGPTSuoPgAzXxYh 2026-02-25 23:12:22 Armin van Buuren Angels /media/pi/X9/DJ/Music/Armin van Buuren - Angels_1.mp3 >**OD = true:** Does not output anything related to the "new" track with the ID of 0QWfgffeGPTSuoPgAzXxYh like scenario 1 with OD set to true.
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#141
No description provided.