cody-music
Advanced tools
Comparing version 2.2.1 to 2.2.2
@@ -170,3 +170,8 @@ "use strict"; | ||
let jsonStr = jsonList[i].trim(); | ||
jsonResult[i] = JSON.parse(jsonStr); | ||
try { | ||
jsonResult[i] = JSON.parse(jsonStr); | ||
} | ||
catch (err) { | ||
console.log("Unable to parse track: ", jsonStr); | ||
} | ||
} | ||
@@ -394,8 +399,5 @@ } | ||
playlistItem.tracks = new models_1.PlaylistTrackInfo(); | ||
let result = await getTracksByPlaylistName(player, name); | ||
if (result) { | ||
let jsonList = result.split("[TRACK_END],"); | ||
playlistItem.tracks.total = jsonList | ||
? jsonList.length | ||
: 0; | ||
let tracksResult = await getTracksByPlaylistName(player, name); | ||
if (tracksResult) { | ||
playlistItem.tracks.total = Object.keys(tracksResult).length; | ||
} | ||
@@ -402,0 +404,0 @@ playlists.push(playlistItem); |
@@ -122,3 +122,2 @@ export declare enum PlayerType { | ||
type: string; | ||
total: number; | ||
} |
@@ -158,5 +158,4 @@ "use strict"; | ||
this.type = "playlist"; | ||
this.total = 0; | ||
} | ||
} | ||
exports.PlaylistItem = PlaylistItem; |
@@ -13,2 +13,3 @@ "use strict"; | ||
const CodyMusic = __importStar(require("../../index")); | ||
const models_1 = require("../../lib/models"); | ||
const controller_1 = require("../../lib/controller"); | ||
@@ -65,2 +66,10 @@ const musicUtil = new util_1.MusicUtil(); | ||
}); | ||
it("Get itunes playlists", done => { | ||
CodyMusic.getPlaylists(models_1.PlayerName.ItunesDesktop).then((result) => { | ||
expect(result.length).to.not.equal(0); | ||
const playlistItem = result[0]; | ||
expect(playlistItem.tracks.total).to.not.equal(0); | ||
done(); | ||
}); | ||
}); | ||
}); |
@@ -196,3 +196,7 @@ "use strict"; | ||
let jsonStr = jsonList[i].trim(); | ||
jsonResult[i] = JSON.parse(jsonStr); | ||
try { | ||
jsonResult[i] = JSON.parse(jsonStr); | ||
} catch (err) { | ||
// it might be the success response "ok" | ||
} | ||
} | ||
@@ -421,8 +425,10 @@ } | ||
playlistItem.tracks = new PlaylistTrackInfo(); | ||
let result = await getTracksByPlaylistName(player, name); | ||
if (result) { | ||
let jsonList = result.split("[TRACK_END],"); | ||
playlistItem.tracks.total = jsonList | ||
? jsonList.length | ||
: 0; | ||
let tracksResult = await getTracksByPlaylistName( | ||
player, | ||
name | ||
); | ||
if (tracksResult) { | ||
playlistItem.tracks.total = Object.keys( | ||
tracksResult | ||
).length; | ||
} | ||
@@ -429,0 +435,0 @@ playlists.push(playlistItem); |
@@ -141,3 +141,2 @@ export enum PlayerType { | ||
type: string = "playlist"; | ||
total: number = 0; | ||
} |
{ | ||
"name": "cody-music", | ||
"version": "2.2.1", | ||
"version": "2.2.2", | ||
"description": "mac osx spotify and itunes music player controller, spotify audio features, itunes and spotify genre, and playlist control", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
import { MusicUtil } from "../../lib/util"; | ||
const expect = require("chai").expect; | ||
import * as CodyMusic from "../../index"; | ||
import { Track } from "../../lib/models"; | ||
import { Track, PlayerName, PlaylistItem } from "../../lib/models"; | ||
import { MusicController } from "../../lib/controller"; | ||
@@ -63,2 +63,13 @@ | ||
}); | ||
it("Get itunes playlists", done => { | ||
CodyMusic.getPlaylists(PlayerName.ItunesDesktop).then( | ||
(result: PlaylistItem[]) => { | ||
expect(result.length).to.not.equal(0); | ||
const playlistItem: PlaylistItem = result[0]; | ||
expect(playlistItem.tracks.total).to.not.equal(0); | ||
done(); | ||
} | ||
); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
307242
7511