Skip to content

feat: remove duplicate tracks, market availability, logging - #6

Open
niccocco wants to merge 3 commits into
patdeg:mainfrom
niccocco:main
Open

feat: remove duplicate tracks, market availability, logging#6
niccocco wants to merge 3 commits into
patdeg:mainfrom
niccocco:main

Conversation

@niccocco

@niccocco niccocco commented Apr 9, 2026

Copy link
Copy Markdown

Small edit to ensure that songs with the same uri can't be added to the playlist, changed the hard-coded market code to support different regiosn, moved logging utility in a specific function

@niccocco
niccocco marked this pull request as draft April 9, 2026 21:29
@niccocco
niccocco marked this pull request as ready for review April 9, 2026 22:14
@neurovish

Copy link
Copy Markdown

Filtering by URI doesn't always work since the same song could appear in multiple albums and have a different URI, such as:
https://open.spotify.com/track/6Ch2oscBP8Wo49ZQ3O1IhE
https://open.spotify.com/track/1MKONR4zoVOAoSZ7bLAmM1
https://open.spotify.com/track/5OCg8d9czRGEE77gAbR0oC
https://open.spotify.com/track/3HNAsFCYjP4GzOGIMylOK1
https://open.spotify.com/track/3dOB8dJAt4TNY11aOCkL29

Could the deduplication use name+artist?

@niccocco

Copy link
Copy Markdown
Author

we could use name+artist but I think the best way is to use the isrc field provided in the track api response.
For the URI that you wrote it stayed the same (USAT22403022)and it should be the correct way to handle the deduplication

@neurovish

Copy link
Copy Markdown

It doesn't appear that the isrc field is working. After a few runs, i saw the de-dupe messages, but got another that pulled in https://open.spotify.com/track/5uOOjYyNN0SWKXT4HDJJts and https://open.spotify.com/track/1MKONR4zoVOAoSZ7bLAmM1. I added some debug messages, and it looks like the isrc field is not set:

const dedupeKey = item.type === "track" && item.isrc ? item.isrc : item.uri;

/* Debug stuff */
console.log(URI is ${item.uri})
console.log(ISRC is ${item.isrc})

output
URI is spotify:track:6H8RdbbpEi7vUfXHV4bc4q
ISRC is undefined

I haven't had time to look deeper than this.

@neurovish

neurovish commented Jul 26, 2026

Copy link
Copy Markdown

Ok, it was bugging me. I tested out adding
isrc: track.external_ids?.isrc,
to the 2 allTracks.push() and tracks.push(), and that pulls in the isrc field to item. Don't really know how github works, so haven't touched any of the code here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants