Skip to content
This repository has been archived by the owner on Jan 23, 2024. It is now read-only.

Commit

Permalink
switch back to library ids for all interactions; omit type when adding [
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-weber committed Feb 21, 2016
1 parent f9eb8c3 commit f5dea5e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
10 changes: 6 additions & 4 deletions src/js/googlemusic.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,9 @@ function addTracks(userIndex, playlistId, tracks, callback, onError) {
// [["<sessionid>",1],["<listid>",[["<store id or songid>",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 => {
Expand Down Expand Up @@ -268,18 +270,18 @@ 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 = {};
for (let i = 0; i < contents.length; i++) {
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];
}
}

Expand Down
12 changes: 0 additions & 12 deletions src/js/track.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit f5dea5e

Please sign in to comment.