Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cody-music

Package Overview
Dependencies
Maintainers
1
Versions
234
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cody-music - npm Package Compare versions

Comparing version 2.0.1 to 2.0.2

2

dist/lib/apis.d.ts

@@ -38,2 +38,4 @@ import { PlayerName, Track, PlayerDevice, SpotifyAudioFeature } from "./models";

* Spotify web, desktop, or itunes desktop.
* It will return an empty Track object if it's unable to
* find a running track.
* @returns {Promise<Track>}

@@ -40,0 +42,0 @@ **/

29

dist/lib/apis.js

@@ -85,2 +85,4 @@ "use strict";

* Spotify web, desktop, or itunes desktop.
* It will return an empty Track object if it's unable to
* find a running track.
* @returns {Promise<Track>}

@@ -90,3 +92,3 @@ **/

const spotifyDevices = await getSpotifyDevices();
let track = new models_1.Track();
let track = null;
if (spotifyDevices.length > 0) {

@@ -115,27 +117,16 @@ track = await getTrack(models_1.PlayerName.SpotifyWeb);

track = await musicPlayerCtr.getSpotifyWebCurrentTrack();
if (track) {
track.playerType = models_1.PlayerType.WebSpotify;
}
}
if (!track || !track.id) {
else {
track = await musicCtr.run(player, "state");
if (track) {
track = JSON.parse(track);
if (player === models_1.PlayerName.SpotifyDesktop) {
track.playerType = models_1.PlayerType.MacSpotifyDesktop;
// applescript "id" returns the web equivelant of the "uri" value
// check if it's an advertisement
if (track.id.includes("spotify:ad:")) {
track.state = models_1.TrackStatus.Advertisement;
}
try {
track = JSON.parse(track);
}
else {
track.playerType = models_1.PlayerType.MacItunesDesktop;
}
catch (e) { }
}
}
if (track && track.id) {
return track;
if (!track || musicUtil.isEmptyObj(track)) {
track = new models_1.Track();
}
return new models_1.Track();
return track;
}

@@ -142,0 +133,0 @@ exports.getTrack = getTrack;

@@ -14,3 +14,5 @@ "use strict";

const models_1 = require("../../lib/models");
const controller_1 = require("../../lib/controller");
const musicUtil = new util_1.MusicUtil();
const musicCtr = controller_1.MusicController.getInstance();
/**

@@ -26,12 +28,16 @@ * Don't add "async" into the it condition.

before(done => {
const accessToken = "123abc";
CodyMusic.setCredentials({
refreshToken: "AQCSjp8_taBNv46KFtHsRpU9IcppjCDyGBWN4pATLLXqBPa4Wjk38CY703-WnG4xk7zVbU7niLKQrsYi_zkGnFIy2HuZv-RyiU9fwkE-uw3HUI-vqWBxZoEbdZEIcM1zIqPs3w",
clientSecret: "2b40b4975b2743189c87f4712c0cd59e",
clientId: "eb67e22ba1c6474aad8ec8067480d9dc",
accessToken: accessToken
musicCtr
.quitApp(CodyMusic.PlayerName.SpotifyDesktop)
.then((result) => {
const accessToken = "123abc";
CodyMusic.setCredentials({
refreshToken: "AQCSjp8_taBNv46KFtHsRpU9IcppjCDyGBWN4pATLLXqBPa4Wjk38CY703-WnG4xk7zVbU7niLKQrsYi_zkGnFIy2HuZv-RyiU9fwkE-uw3HUI-vqWBxZoEbdZEIcM1zIqPs3w",
clientSecret: "2b40b4975b2743189c87f4712c0cd59e",
clientId: "eb67e22ba1c6474aad8ec8067480d9dc",
accessToken: accessToken
});
let setAccessToken = CodyMusic.getAccessToken();
expect(setAccessToken).to.equal(accessToken);
done();
});
let setAccessToken = CodyMusic.getAccessToken();
expect(setAccessToken).to.equal(accessToken);
done();
});

@@ -54,3 +60,26 @@ after("web play music test completion", done => {

});
it("Launch web player", done => {
it("Launch and test track state", done => {
CodyMusic.launchPlayer(CodyMusic.PlayerName.SpotifyWeb, {}).then(result => {
CodyMusic.getRunningTrack().then((track) => {
expect(track.id).to.equal("");
done();
});
});
});
it("Check the spotify web player devices", done => {
/**
* [ { id: '116ab2c405ba92f106f4d10d45bb42cba89ec9e2',
is_active: false,
is_private_session: false,
is_restricted: false,
name: 'Web Player (Chrome)',
type: 'Computer',
volume_percent: 100 } ]
*/
CodyMusic.getSpotifyDevices().then((response) => {
console.log("spotify devices: ", response);
done();
});
});
it("Launch and play web player", done => {
CodyMusic.getSpotifyDevices().then(async (response) => {

@@ -98,2 +127,3 @@ let hasComputerDevice = false;

const device_id = response[0].id;
musicUtil.sleep(1000);
response = await CodyMusic.playSpotifyDevice(device_id);

@@ -108,2 +138,3 @@ expect(response.status).to.equal(204);

const device_id = response[0].id;
musicUtil.sleep(1000);
const options = {

@@ -121,2 +152,3 @@ device_id

const device_id = response[0].id;
musicUtil.sleep(1000);
// https://open.spotify.com/track/0i0wnv9UoFdZ5MfuFGQzMy

@@ -144,2 +176,3 @@ // name: 'Last Hurrah'

const device_id = response[0].id;
musicUtil.sleep(1000);
let options = {

@@ -146,0 +179,0 @@ device_id,

@@ -93,2 +93,4 @@ "use strict";

* Spotify web, desktop, or itunes desktop.
* It will return an empty Track object if it's unable to
* find a running track.
* @returns {Promise<Track>}

@@ -98,3 +100,3 @@ **/

const spotifyDevices = await getSpotifyDevices();
let track: Track = new Track();
let track = null;
if (spotifyDevices.length > 0) {

@@ -109,2 +111,3 @@ track = await getTrack(PlayerName.SpotifyWeb);

}
return track;

@@ -124,28 +127,16 @@ }

track = await musicPlayerCtr.getSpotifyWebCurrentTrack();
} else {
track = await musicCtr.run(player, "state");
if (track) {
track.playerType = PlayerType.WebSpotify;
try {
track = JSON.parse(track);
} catch (e) {}
}
}
if (!track || !track.id) {
track = await musicCtr.run(player, "state");
if (track) {
track = JSON.parse(track);
if (player === PlayerName.SpotifyDesktop) {
track.playerType = PlayerType.MacSpotifyDesktop;
// applescript "id" returns the web equivelant of the "uri" value
// check if it's an advertisement
if (track.id.includes("spotify:ad:")) {
track.state = TrackStatus.Advertisement;
}
} else {
track.playerType = PlayerType.MacItunesDesktop;
}
}
if (!track || musicUtil.isEmptyObj(track)) {
track = new Track();
}
if (track && track.id) {
return track;
}
return new Track();
return track;
}

@@ -152,0 +143,0 @@

{
"name": "cody-music",
"version": "2.0.1",
"version": "2.0.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 { TrackStatus } from "../../lib/models";
import { TrackStatus, Track } from "../../lib/models";
import { MusicController } from "../../lib/controller";
const musicUtil = new MusicUtil();
const musicCtr = MusicController.getInstance();

@@ -18,16 +20,20 @@ /**

before(done => {
const accessToken = "123abc";
CodyMusic.setCredentials({
refreshToken:
"AQCSjp8_taBNv46KFtHsRpU9IcppjCDyGBWN4pATLLXqBPa4Wjk38CY703-WnG4xk7zVbU7niLKQrsYi_zkGnFIy2HuZv-RyiU9fwkE-uw3HUI-vqWBxZoEbdZEIcM1zIqPs3w",
clientSecret: "2b40b4975b2743189c87f4712c0cd59e",
clientId: "eb67e22ba1c6474aad8ec8067480d9dc",
accessToken: accessToken
});
musicCtr
.quitApp(CodyMusic.PlayerName.SpotifyDesktop)
.then((result: any) => {
const accessToken = "123abc";
CodyMusic.setCredentials({
refreshToken:
"AQCSjp8_taBNv46KFtHsRpU9IcppjCDyGBWN4pATLLXqBPa4Wjk38CY703-WnG4xk7zVbU7niLKQrsYi_zkGnFIy2HuZv-RyiU9fwkE-uw3HUI-vqWBxZoEbdZEIcM1zIqPs3w",
clientSecret: "2b40b4975b2743189c87f4712c0cd59e",
clientId: "eb67e22ba1c6474aad8ec8067480d9dc",
accessToken: accessToken
});
let setAccessToken = CodyMusic.getAccessToken();
let setAccessToken = CodyMusic.getAccessToken();
expect(setAccessToken).to.equal(accessToken);
expect(setAccessToken).to.equal(accessToken);
done();
done();
});
});

@@ -54,3 +60,30 @@

it("Launch web player", done => {
it("Launch and test track state", done => {
CodyMusic.launchPlayer(CodyMusic.PlayerName.SpotifyWeb, {}).then(
result => {
CodyMusic.getRunningTrack().then((track: Track) => {
expect(track.id).to.equal("");
done();
});
}
);
});
it("Check the spotify web player devices", done => {
/**
* [ { id: '116ab2c405ba92f106f4d10d45bb42cba89ec9e2',
is_active: false,
is_private_session: false,
is_restricted: false,
name: 'Web Player (Chrome)',
type: 'Computer',
volume_percent: 100 } ]
*/
CodyMusic.getSpotifyDevices().then((response: any) => {
console.log("spotify devices: ", response);
done();
});
});
it("Launch and play web player", done => {
CodyMusic.getSpotifyDevices().then(

@@ -106,2 +139,3 @@ async (response: CodyMusic.PlayerDevice[]) => {

const device_id = response[0].id;
musicUtil.sleep(1000);
response = await CodyMusic.playSpotifyDevice(device_id);

@@ -117,2 +151,3 @@ expect(response.status).to.equal(204);

const device_id = response[0].id;
musicUtil.sleep(1000);
const options = {

@@ -134,2 +169,3 @@ device_id

const device_id = response[0].id;
musicUtil.sleep(1000);
// https://open.spotify.com/track/0i0wnv9UoFdZ5MfuFGQzMy

@@ -164,2 +200,3 @@ // name: 'Last Hurrah'

const device_id = response[0].id;
musicUtil.sleep(1000);
let options = {

@@ -166,0 +203,0 @@ device_id,

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc