secuvera / SpotMyBackup

Backup and Restore your Spotify Playlists and "My Music"
GNU General Public License v2.0
988 stars 250 forks source link

Failed to load resource #29

Open nivaivax opened 6 years ago

nivaivax commented 6 years ago

Hi!

Tried the online tool (Edge+Chrome) end get stuck a this: 43 artists 296 playlists 42421 tracks

Please wait. Loading your playlists ...

On F12 console i get this error message.

api.spotify.com/v1/users//playlists/37i9dQZF1DX0bwWyVo0VqH/tracks:1 Failed to load resource: the server responded with a status of 404 ()

This is what the link says: { "error": { "status": 401, "message": "No token provided" } }

Empty/erroneous user/playlist perhaps?

secuvera commented 6 years ago

Hi, thanks for the error message, you might have removed the user_id between users/?/playlists. If you did, great ^^ (for security reasons), otherwise the problem might be that the url is invalid because of the missing user_id. I did not test Edge, but the Login does not work on Internet Explorer(end of sentence). Chrome and Firefox should work thought. Try to logout from Spotify or clear your Browsercache and then login anew on spotmybackup.com. The token is something you get for your client after the login, without it no request will work.

I just tested the export and reupload on a new account. The starred playlist should have been optional on import after recent changes, but it wasn't optional enough. Therefore the import failed during the check. So there was an error in the import anyway.

Nonetheless, i also encountered a rate limit on the hosted version on spotmybackup.com. But thats for another fix.

Updated spotmybackup.com and tested export&import successfully (with ratelimit errors :( ). Update github repo.

nivaivax commented 6 years ago

Hi!

No, the error message is just like that, with that URL.

I tried it again in chrome and still get the same error. Also, I believe I have more than 296 playlists, so I suppose it stops somewhere along the way.

I suppose it some old data error from a bad playlist from years ago (signed up way back when Spotify started) that's causing the problem. I don't know how to turn the string into an actual playlist though, otherwise I might be able to delete it.

secuvera commented 6 years ago

Hmm, strange idea, the export looks like below, just more entries, can you open your exportfile and remove all entries except for the parts with "37i9dQZF1DX0bwWyVo0VqH" in it and post the resulting exportfile. I might be able to try an import with that cut down exportfile. Would figuring out the error easier.

Thats what a minimal exportfile should look like (lots of organized ids ^^): { "playlists": { "list1": { "name": "list1", "id": "3MOtPX4---------------", "tracks": [ { "id": "1BPybPV---------------", "uri": "spotify:track:1BPybPV---------------" } ] } }, "saved": [ { "id": "3eYrwDV---------------", "uri": "spotify:track:3eYrwDV---------------" } ] }

nivaivax commented 6 years ago

I don't get an export file, it just stops at "Please wait. Loading your playlists ..." - or does it store a file temporary somewhere?

secuvera commented 6 years ago

Oh the export, right, we might need to find out why your user_id is empty. Open Dev-Console with F12, reload the spotmybackup-Page with F5, under Sources on the left side there should be listed (index) under www.spotmybackup.com. On the left side of the file should be line numbers, if you click on them you can set breakpoints (blue marker appeas). Set a breakpoint on line 598 and 607, both inside handleAuth. After Login your page should now halt there and you can inspect the accessToken, F8 resumes to the second breakpoint, inspect the userId.

Maybe both values are empty for you, what would be strange. Would be worth a look.

nivaivax commented 6 years ago

No, they both have values, and the userId displays my name etc.

Is it really a login error though, because it load 298 playlists and 40000 tracks. It seems more like there is a data error in the data it's receiving. Perhaps it's a playlist I'm following, or some playlist that was created in Spotify's youth and the data then got corrupted?

Is there some way to just ignore the error so it can keep working and provide an export file, instead of halting? I probably don't care about that particular playlist either way...

And thanks for the help! Really appreciated!

secuvera commented 6 years ago

I would assume the operation stops inside the loadTrackChunks function, which downloads the Tracks step by step.

We got 2 options:

  1. You set a breakpoint inside handlePlaylistRequests and remove the bad playlist from inside arr before resuming. Would be the cool hacker way ;)

  2. Or you paste following code inside your DevConsole before you Export (i added the callback which returns if a fail happens - not tested). This will override the function till you close the tab. Would be the ok i trust you that you didn't add malicious code there way ;) : function loadTrackChunks(url, arr, callback) { $.ajax({ url: url, headers: { 'Authorization': 'Bearer ' + token }, success: function (data) { if (!data) return; if ('items' in data) { $.each(data.items, function (index, value) { if(value.track !== null){ arr.push({ id: value.track.id, uri: value.track.uri });
    }else{ console.log("track is null", value); }
    }); } else { arr.push({ id: data.track.id, uri: data.track.uri }); } if (data.next) { loadTrackChunksWithTimeout(data.next, arr, callback); } else { callback(); } }, fail: function (jqXHR, textStatus, errorThrown) { callback(); } }); }

nivaivax commented 6 years ago

I've been googling quite a bit on how to do this, with local overrides and just pasting in the console, but can't get it to work. Any suggestions?

The best I get when doing it is VM287:21 Uncaught ReferenceError: loadTrackChunksWithTimeout is not defined at Object.success (eval at ((index):3), :21:1)

nivaivax commented 6 years ago

changed loadTrackChunksWithTimeout to loadTrackChunks and pasted the code in the console. Now I dont get the ReferenceError above, but I'm still stuck at 298 playlists, so it doesnt seem to ignore the error.

BartlomiejSkwira commented 6 years ago

I have the same issue, I log in with Spotify, a few playlists manage to load (sometimes 10, sometimes 4), then I get a few JS errors and the backup stops

image

All return this:

{
  "error": {
    "status": 401,
    "message": "No token provided"
  }
}
BartlomiejSkwira commented 6 years ago

After updating Chrome to the newest version Version 68.0.3440.106 (Official Build) (64-bit) on Mac it behaves a little bit different. When I click "Login with Spotify" and the popup appears I get the first error:

image

I click login, and it kinda works, backup starts, 10 playlists load and then I get the second error:

image

BartlomiejSkwira commented 6 years ago

Something is off with Chrome. Running the backup on Firefox 61.0.2 (64-bit) worked without problems. @nivaivax I recommending this way of exporting

nivaivax commented 6 years ago

It seems now it's going through all playlists and tracks in both in SpotMyBackup and Backify without errors, dont' know if that's a fix from Spotify's side or a change in the code.

However, when clicking the export button, it doesn't work in Edge or Chrome. It shows the sliding wave over the icon as if though it was downloading, but nothing starts. On Chrome Android it shows the error message: "download failed due to an unknown error"

It does work on Firefox though!

RahulDAnand commented 6 years ago

Hey, I was going through the same issue as OP. I was getting error 401 on a console. Solution for this issue is: Try on a different browser and it will work.

Thanks,