cody-music
Advanced tools
Comparing version 2.0.4 to 2.0.5
@@ -102,3 +102,3 @@ "use strict"; | ||
if (!track || !track.id) { | ||
const itunesDesktopRunning = await isPlayerRunning(models_1.PlayerName.SpotifyDesktop); | ||
const itunesDesktopRunning = await isPlayerRunning(models_1.PlayerName.ItunesDesktop); | ||
if (itunesDesktopRunning) { | ||
@@ -124,5 +124,7 @@ track = await getTrack(models_1.PlayerName.ItunesDesktop); | ||
if (player === models_1.PlayerName.SpotifyWeb) { | ||
// fetch the web track | ||
track = await musicPlayerCtr.getSpotifyWebCurrentTrack(); | ||
} | ||
else { | ||
// fetch the track from the specified player name | ||
track = await musicCtr.run(player, "state"); | ||
@@ -129,0 +131,0 @@ if (track) { |
@@ -65,3 +65,7 @@ "use strict"; | ||
player = musicUtil.getPlayerName(player); | ||
const command = `pgrep -x ${player}`; | ||
let appName = "Spotify.app"; | ||
if (player === models_1.PlayerName.ItunesDesktop) { | ||
appName = "iTunes.app"; | ||
} | ||
const command = `ps -ef | grep "${appName}" | grep -v grep | awk '{print $2}'`; | ||
// this returns the PID of the requested player | ||
@@ -136,4 +140,11 @@ const result = await musicUtil.execCmd(command); | ||
// make it an object | ||
itunesTrack = JSON.parse(itunesTrack); | ||
if (!itunesTrack || !itunesTrack.id) { | ||
try { | ||
itunesTrack = JSON.parse(itunesTrack); | ||
if (!itunesTrack || !itunesTrack.id) { | ||
// play from the user's default playlist | ||
script = this.scripts.playFromLibrary; | ||
params.push("Library"); | ||
} | ||
} | ||
catch (err) { | ||
// play from the user's default playlist | ||
@@ -140,0 +151,0 @@ script = this.scripts.playFromLibrary; |
@@ -100,2 +100,3 @@ "use strict"; | ||
let track = null; | ||
if (spotifyDevices.length > 0) { | ||
@@ -114,4 +115,5 @@ track = await getTrack(PlayerName.SpotifyWeb); | ||
const itunesDesktopRunning = await isPlayerRunning( | ||
PlayerName.SpotifyDesktop | ||
PlayerName.ItunesDesktop | ||
); | ||
if (itunesDesktopRunning) { | ||
@@ -139,4 +141,6 @@ track = await getTrack(PlayerName.ItunesDesktop); | ||
if (player === PlayerName.SpotifyWeb) { | ||
// fetch the web track | ||
track = await musicPlayerCtr.getSpotifyWebCurrentTrack(); | ||
} else { | ||
// fetch the track from the specified player name | ||
track = await musicCtr.run(player, "state"); | ||
@@ -143,0 +147,0 @@ if (track) { |
@@ -75,3 +75,9 @@ import { MusicUtil } from "./util"; | ||
player = musicUtil.getPlayerName(player); | ||
const command = `pgrep -x ${player}`; | ||
let appName = "Spotify.app"; | ||
if (player === PlayerName.ItunesDesktop) { | ||
appName = "iTunes.app"; | ||
} | ||
const command = `ps -ef | grep "${appName}" | grep -v grep | awk '{print $2}'`; | ||
// this returns the PID of the requested player | ||
@@ -157,4 +163,10 @@ const result = await musicUtil.execCmd(command); | ||
// make it an object | ||
itunesTrack = JSON.parse(itunesTrack); | ||
if (!itunesTrack || !itunesTrack.id) { | ||
try { | ||
itunesTrack = JSON.parse(itunesTrack); | ||
if (!itunesTrack || !itunesTrack.id) { | ||
// play from the user's default playlist | ||
script = this.scripts.playFromLibrary; | ||
params.push("Library"); | ||
} | ||
} catch (err) { | ||
// play from the user's default playlist | ||
@@ -161,0 +173,0 @@ script = this.scripts.playFromLibrary; |
{ | ||
"name": "cody-music", | ||
"version": "2.0.4", | ||
"version": "2.0.5", | ||
"description": "mac osx spotify and itunes music player controller, spotify audio features, itunes and spotify genre, and playlist control", | ||
@@ -12,3 +12,4 @@ "main": "dist/index.js", | ||
"web-test": "npm run build && mocha -r ts-node/register test/web/test.ts --reporter spec --timeout 20000 --exit", | ||
"controls-test": "npm run build && mocha -r ts-node/register test/controls/test.ts --reporter spec --timeout 20000 --exit" | ||
"controls-test": "npm run build && mocha -r ts-node/register test/controls/test.ts --reporter spec --timeout 20000 --exit", | ||
"itunes-test": "npm run build && mocha -r ts-node/register test/itunes/test.ts --reporter spec --timeout 20000 --exit" | ||
}, | ||
@@ -15,0 +16,0 @@ "repository": { |
281712
85
6822