Skip to content
40 changes: 24 additions & 16 deletions amazon/content/contents/code/amazon.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,19 @@ var AmazonResolver = Tomahawk.extend( Tomahawk.Resolver, {
});
},

_decode: function (item) {
if (item) {
return he.decode(item);
}
return item;
},

_convertTrack2: function (entry) {
var track = {
artist: Tomahawk.htmlDecode(entry.artist.name),
album: Tomahawk.htmlDecode(entry.album.title),
track: Tomahawk.htmlDecode(entry.title),
title: Tomahawk.htmlDecode(entry.title),
artist: this._decode(entry.artist.name),
album: this._decode(entry.album.title),
track: this._decode(entry.title),
title: this._decode(entry.title),

albumpos: entry.trackNum,
discnumber: entry.discNum,
Expand All @@ -182,11 +189,11 @@ var AmazonResolver = Tomahawk.extend( Tomahawk.Resolver, {
if (entry.hasOwnProperty('metadata'))
entry = entry.metadata;
var track = {
artist: Tomahawk.htmlDecode(entry.artistName),
albumArtist: Tomahawk.htmlDecode(entry.albumArtistName),
album: Tomahawk.htmlDecode(entry.albumName),
track: Tomahawk.htmlDecode(entry.title),
title: Tomahawk.htmlDecode(entry.title),
artist: this._decode(entry.artistName),
albumArtist: this._decode(entry.albumArtistName),
album: this._decode(entry.albumName),
track: this._decode(entry.title),
title: this._decode(entry.title),

albumpos: entry.trackNum,
discnumber: entry.discNum,
Expand Down Expand Up @@ -227,16 +234,16 @@ var AmazonResolver = Tomahawk.extend( Tomahawk.Resolver, {

var that = this;


//Just a guess, not sure how to check if haz prime music
if (that._appConfig.featureController.hawkfireAccess == 1)
{
// User has Music Unlimited
return that._post(that.api_location + "clientbuddy/compartments/eeb70a31c77c4ecd/handlers/search", {
data: {
"keywords" : params.query,
"offset" : 0,
"count" : 100,
"marketplaceId" : that._appConfig['cirrus']['marketplaceId'],
"marketplaceId": that._appConfig['marketplaceId']
|| that._appConfig['cirrus']['marketplaceId'],
"features" : ["musicSubscription"],
"isMusicSubscription" : true,
"primeOnly" : false,
Expand All @@ -255,12 +262,12 @@ var AmazonResolver = Tomahawk.extend( Tomahawk.Resolver, {
}
else if (that._appConfig.featureController.robin == 1)
{
//I have no idea where this URL comes from yet
//This is to search 'Prime Music'
// User has Prime
return that._post(that.api_location + "clientbuddy/compartments/32f93572142e8f7c/handlers/search", {
data: {
"keywords" : params.query,
"marketplaceId" : that._appConfig['cirrus']['marketplaceId']
"marketplaceId": that._appConfig['marketplaceId']
|| that._appConfig['cirrus']['marketplaceId']
},
dataFormat: 'json'
}, true).then( function (response) {
Expand All @@ -269,6 +276,7 @@ var AmazonResolver = Tomahawk.extend( Tomahawk.Resolver, {
}).map(that._convertTrack, that);
});
} else {
// User doesn't have Unlimited nor Prime
return [];
}
},
Expand Down Expand Up @@ -572,7 +580,7 @@ var AmazonResolver = Tomahawk.extend( Tomahawk.Resolver, {
(track.primeStatus == 'PRIME' && that._appConfig.featureController.robin == 1) ||
(track.isMusicSubscription == 'true' && that._appConfig.featureController.hawkfireAccess == 1));
})
.map(that._convertTrack));
.map(that._convertTrack, that));
nextResultsToken = response.searchLibraryResponse.searchLibraryResult.nextResultsToken;
if (null === nextResultsToken)
return previousResults;
Expand Down
5 changes: 4 additions & 1 deletion amazon/content/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
"pluginName": "amazon",
"author": "Creepy Guy In The Corner",
"email": "",
"version": "0.0.11",
"version": "0.0.12",
"website": "http://gettomahawk.com",
"description": "Streams music from Amazon Music",
"type": "resolver/javascript",
"manifest": {
"main": "contents/code/amazon.js",
"libs": [
"he:1.1.1"
],
"icon": "contents/images/icon.png",
"iconWhite": "contents/images/iconWhite.png",
"iconBackground": "contents/images/iconBackground.png",
Expand Down
8 changes: 1 addition & 7 deletions ampache/content/contents/code/ampache.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,6 @@ var AmpacheResolver = Tomahawk.extend(Tomahawk.Resolver, {

this._ready = false;

if (!this.element) {
this.element = document.createElement('div');
}

// check resolver is properly configured
var userConfig = this.getUserConfig();
if (!userConfig.username || !userConfig.password || !userConfig.server) {
Expand Down Expand Up @@ -340,8 +336,7 @@ var AmpacheResolver = Tomahawk.extend(Tomahawk.Resolver, {
},

_decodeEntity: function (str) {
this.element.innerHTML = str;
return this.element.textContent;
return he.decode(str);
},

_parseSongResponse: function (xmlDoc) {
Expand Down Expand Up @@ -425,7 +420,6 @@ var AmpacheResolver = Tomahawk.extend(Tomahawk.Resolver, {
Tomahawk.resolver.instance = AmpacheResolver;

var ampacheCollection = Tomahawk.extend(Tomahawk.Collection, {
resolver: AmpacheResolver,
settings: {
id: "ampache",
prettyname: "Ampache",
Expand Down
4 changes: 3 additions & 1 deletion ampache/content/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
"type": "resolver/javascript",
"manifest": {
"main": "contents/code/ampache.js",
"scripts": [],
"libs": [
"cryptojs:3.1.2", "he:1.1.1"
],
"icon": "contents/images/icon.png",
"iconWhite": "contents/images/iconWhite.png",
"iconBackground": "contents/images/iconBackground.png",
Expand Down
Loading