From f5dea5e9f081013f1064a662447a39787237088c Mon Sep 17 00:00:00 2001 From: Simon Weber Date: Sun, 21 Feb 2016 01:53:13 -0500 Subject: [PATCH] switch back to library ids for all interactions; omit type when adding [#35 #20] --- src/js/googlemusic.js | 10 ++++++---- src/js/track.js | 12 ------------ 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/src/js/googlemusic.js b/src/js/googlemusic.js index 438cd46..30e85da 100644 --- a/src/js/googlemusic.js +++ b/src/js/googlemusic.js @@ -190,7 +190,9 @@ function addTracks(userIndex, playlistId, tracks, callback, onError) { // [["",1],["",[["",tracktype]]]] const payload = [['', 1], [ - playlistId, tracks.map(t => [Track.getPlaylistAddId(t), t.type]), + // Google always sends [id, type] pairs, but that's caused problems for me around AA and store ids and types. + // Just sending an id seems to work, so maybe that'll fix everything? + playlistId, tracks.map(t => [t.id]), ], ]; authedGMRequest('addtrackstoplaylist', payload, userIndex, 'post', response => { @@ -268,7 +270,7 @@ exports.setPlaylistContents = function setPlaylistContents(db, userIndex, playli const idsToAdd = {}; for (let i = 0; i < tracks.length; i++) { const track = tracks[i]; - idsToAdd[Track.getPlaylistAddId(track)] = track; + idsToAdd[track.id] = track; } const deleteCandidates = {}; @@ -276,10 +278,10 @@ exports.setPlaylistContents = function setPlaylistContents(db, userIndex, playli const remoteTrack = contents[i].track; const entryId = contents[i].entryId; - if (!(Track.getPlaylistAddId(remoteTrack) in idsToAdd)) { + if (!(remoteTrack.id in idsToAdd)) { deleteCandidates[remoteTrack.id] = entryId; } else { - delete idsToAdd[Track.getPlaylistAddId(remoteTrack)]; + delete idsToAdd[remoteTrack.id]; } } diff --git a/src/js/track.js b/src/js/track.js index 5f162f1..37b4ec4 100644 --- a/src/js/track.js +++ b/src/js/track.js @@ -89,18 +89,6 @@ exports.fromJsproto = function fromJsproto(jsproto) { return track; }; -exports.getPlaylistAddId = function getPlaylistAddId(track) { - // Return the id for this track when interacting with Google. - // For some reason Google doesn't accept AA playlist adds with library ids. - let id = track.id; - - if (track.type === 7) { - id = track.storeId; - } - - return id; -}; - exports.toString = function toString(track) { let output = ''; for (const key in track) {