I am trying to implement Last.FM API using a JavaScript wrapper made by 'leemm', and it seems to function properly, with it returning information through testing. But when I try to use the 'track.getInfo()' method, it starts to throw
error: {
code: '5',
message: "Invalid format - This service doesn't exist in that format"
},
text: undefined
}
For songs such as 'Survival of The Fittest' by 'Mobb Deep'. But it returns information properly for other songs such as 'HUMBLE.' by 'Kendrick Lamar'.
This is my function:
async function lastFMTest(){
const data = await lastfm.track.getInfo({
artist: 'Kendrick Lamar',
track: 'HUMBLE.',
username: 'NAG_Z',
autocorrect: '1'
});
console.log(data.track.name, data.track.userplaycount, data.track.toptags.tag[0].name);
}
I noticed that getInfo() method returns information for a good amount of tracks before crashing on one particular track. I checked the unofficial documentation and it says:
Last.fm Error Code 5: Invalid Response Format
A
formatparameter is necessary in addition to the documented parameters, this may either have a value ofXMLorJSON(case insensitive). Requesting data in another format will emit this error. Some methods do support more than these 2 formats, the methods that do have their formats listed in this documentation.
So I tried inserting a format parameter specifying 'json' which results in the same issue, 'XML' breaks the method though I do wish my data returned in JSON format so I don't really think XML is the way to go.
This is most likely due to my lack of understanding of the API or possibly JavaScript as I am still a novice, if anyone could help me I would greatly appreciate it!
EDIT:
For the format parameter I tried both 'json' and 'JSON', doesn't work even afterward.
I don't know if this matters; but I went to the url for each song
Click "Play Track" and it plays https://www.last.fm/music/Kendrick+Lamar/_/HUMBLE.
Click "Play Track" and it says "Track unavailable." https://www.last.fm/music/Mobb+Deep/_/Survival+of+the+Fittest
So maybe something is going on within the leemm wrapper for last.fm? If I go to the api directly via
audioscrobbler, I get a responseThen I went to the album info and got several tracks
Following that, the LP Version doesn't seem to have a track at all. https://www.last.fm/music/Mobb+Deep/_/Survival+of+the+Fittest+(LP+Version)
And the other urls that are in the api response: https://www.last.fm/music/Mobb+Deep/_/Survival+Of+The+Fittest+(Remix)+(Extended+Version)
https://www.last.fm/music/Mobb+Deep/_/Survival+Of+The+Fittest+(Remix)+(Instrumental)
This one has a track, says "Track unavailable" when playingg https://www.last.fm/music/Mobb+Deep/_/Survival+Of+The+Fittest+(A+Cappella)