Skip to content

Commit a1ca062

Browse files
Creepy Guy In The Cornerdschmidt
authored andcommitted
amazon: Enable Music Unlimited
1 parent 04e19ea commit a1ca062

File tree

1 file changed

+48
-4
lines changed

1 file changed

+48
-4
lines changed

amazon/content/contents/code/amazon.js

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,28 @@ var AmazonResolver = Tomahawk.extend( Tomahawk.Resolver, {
156156
});
157157
},
158158

159+
_convertTrack2: function (entry) {
160+
var track = {
161+
artist: entry.artist.name,
162+
album: entry.album.title,
163+
track: entry.title,
164+
title: entry.title,
165+
166+
albumpos: entry.trackNum,
167+
discnumber: entry.discNum,
168+
169+
duration: entry.duration,
170+
171+
checked: true,
172+
type: "track",
173+
url : 'amzn://track/' + entry.duration + '/ASIN/' + entry.asin
174+
};
175+
// also has originalReleaseDate with values like 1476921600000
176+
177+
track.hint = track.url;
178+
return track;
179+
},
180+
159181
_convertTrack: function (entry) {
160182
if (entry.hasOwnProperty('metadata'))
161183
entry = entry.metadata;
@@ -187,9 +209,6 @@ var AmazonResolver = Tomahawk.extend( Tomahawk.Resolver, {
187209
else
188210
track.url = 'amzn://track/' + entry.duration + '/ASIN/' + entry.asin;
189211

190-
if (entry.hasOwnProperty('bitrate'))
191-
track.bitrate = entry.bitrate;
192-
193212
track.hint = track.url;
194213
return track;
195214
},
@@ -205,7 +224,32 @@ var AmazonResolver = Tomahawk.extend( Tomahawk.Resolver, {
205224

206225

207226
//Just a guess, not sure how to check if haz prime music
208-
if (that._appConfig['featureController']['primePlatformMS3'] == 1)
227+
if (that._appConfig.featureController.hawkfireAccess == 1)
228+
{
229+
Tomahawk.log("Music Unlimited");
230+
return that._post(that.api_location + "clientbuddy/compartments/eeb70a31c77c4ecd/handlers/search", {
231+
data: {
232+
"keywords" : params.query,
233+
"offset" : 0,
234+
"count" : 100,
235+
"marketplaceId" : that._appConfig['cirrus']['marketplaceId'],
236+
"features" : ["musicSubscription"],
237+
"isMusicSubscription" : true,
238+
"primeOnly" : false,
239+
"requestUiContentDeliveredMetrics" : true,
240+
"sslMedia" : true,
241+
"types" : ["track" /* "album", "artist", "station", "playlist" */ ]
242+
},
243+
dataFormat: 'json',
244+
headers : {
245+
"x-amzn-cb-deviceid" : that._appConfig.deviceId,
246+
"x-amzn-cb-devicetype" : that._appConfig.deviceType
247+
}
248+
}, false).then( function (response) {
249+
return response.trackList.map(that._convertTrack2, that);
250+
});
251+
}
252+
else if (that._appConfig.featureController.robin == 1)
209253
{
210254
//I have no idea where this URL comes from yet
211255
//This is to search 'Prime Music'

0 commit comments

Comments
 (0)