Unable to handle albums with 13-digit UPC values
disconnect78 opened this issue · comments
$ d-fi https://open.spotify.com/album/5ltUnHY4jtZTMFM0TVUGtE # Album with UPC value 4058765612347
♥ d-fi - 2.0.5 ♥
──────────────────────────────────────────────
│ repo https://notabug.org/sayem314/d-fi │
│ github https://github.com/sayem314 │
│ coffee https://ko-fi.com/sayemchowdhury │
──────────────────────────────────────────────
✔ success Logged in as
✔ Select music quality: › MP3 - 320 kbps
✖ error No match on deezer for Best Of Liquid, Vol. 1 (UPC: 058765612347)
However:
$ d-fi https://open.spotify.com/album/2noRn2Aes5aoNVsU6iWThc # Album with UPC value 0724384960650
♥ d-fi - 2.0.5 ♥
──────────────────────────────────────────────
│ repo https://notabug.org/sayem314/d-fi │
│ github https://github.com/sayem314 │
│ coffee https://ko-fi.com/sayemchowdhury │
──────────────────────────────────────────────
✔ success Logged in as
✔ Select music quality: › MP3 - 320 kbps
? Select songs to download. Total of 14 tracks. ›
...
From my brief investigations it looks like Spotify always returns a 13-digit value for the UPC. If it starts with a 0
then the current behaviour of removing the first digit allows it to match Deezer. If it starts with anything else then the full 13-digit number needs to be used.
Amending /src/converter/deezer.ts
as follows works for the examples above:
else if (upc.length > 12 && upc.substring(0, 1) === '0') {
upc = upc.slice(-12);
}
I've tested it with a few other albums which all worked. I haven't yet found one that doesn't but that's no guarantee that this works for everything!
Thank you for detailed information. And I’m sorry for late reply, I was busy with some internal private work. This has been fixed on latest version.