itunes-bridge
Advanced tools
Comparing version 0.1.0 to 0.1.5
@@ -11,13 +11,29 @@ // iTunes Bridge 0.1-alpha by AngryKiller. | ||
exports.getCurrentTrackName = function() { | ||
return applescript.sync('tell application "iTunes" to set track_name to the name of the current track'); | ||
return applescript.sync('tell application "iTunes" to get the name of the current track'); | ||
}; | ||
exports.getCurrentTrackArtist = function() { | ||
return applescript.sync('tell application "iTunes" to set track_artist to the artist of the current track'); | ||
return applescript.sync('tell application "iTunes" to get the artist of the current track'); | ||
} | ||
exports.getCurrentTrackAlbum = function() { | ||
return applescript.sync('tell application "iTunes" to set track_album to the album of the current track'); | ||
return applescript.sync('tell application "iTunes" to get the album of the current track'); | ||
} | ||
exports.getCurrentTrackDuration = function() { | ||
var durationInSeconds = applescript.sync('tell application "iTunes" to set track_album to the duration of the current track'); | ||
var durationInSeconds = applescript.sync('tell application "iTunes" to get the duration of the current track'); | ||
return secToMin(durationInSeconds); | ||
} | ||
exports.getCurrentTrackReleaseYear = function() { | ||
return applescript.sync('tell application "iTunes" to get the year of the current track'); | ||
} | ||
exports.getCurrentTrackGenre = function() { | ||
return applescript.sync('tell application "iTunes" to get the genre of the current track'); | ||
} | ||
exports.getPlayerState = function() { | ||
// TODO: Check if iTunes is launched as another check before the AppleScript one | ||
return applescript.sync('tell application "iTunes" to get the player state'); | ||
} | ||
exports.getPlaylistCount = function() { | ||
return applescript.sync('tell application "iTunes" to get the count of playlists'); | ||
} | ||
exports.getTrackCount = function() { | ||
return applescript.sync('tell application "iTunes" to get the count of tracks'); | ||
} |
{ | ||
"name": "itunes-bridge", | ||
"version": "0.1.0", | ||
"version": "0.1.5", | ||
"description": "A NodeJS package to control and get informations from iTunes through AppleScript", | ||
@@ -5,0 +5,0 @@ "main": "itunes-bridge.js", |
# iTunes-bridge | ||
A NodeJS package to control and get informations from iTunes through AppleScript | ||
A macOS only NodeJS package to control and get informations from iTunes through AppleScript | ||
### This package is a WIP, a lot of functions will be added in the future and some that are already existing could change | ||
#Documentation | ||
No documentation yet, but you can look at the code of [iTunes-Discord integration](https://github.com/AngryKiller/iTunes-Discord-integration/tree/dev) that is a great example of the usages possible with iTunes-bridge. | ||
# Documentation | ||
No documentation yet, but you can look at the code of [iTunes-Discord integration](https://github.com/AngryKiller/iTunes-Discord-integration/tree/dev) that is a great example of the usages possible with iTunes-bridge. | ||
There is also an example.js that you can run. | ||
const iTunes = require('./itunes-bridge'); | ||
var currentPlayerState = iTunes.getPlayerState(); | ||
if(currentPlayerState == 'playing') { | ||
var exampleMsg = "iTunes is currently playing " + iTunes.getCurrentTrackName() + " by " + iTunes.getCurrentTrackArtist() + ' from the album "' + iTunes.getCurrentTrackAlbum() + '". This song is ' + iTunes.getCurrentTrackDuration() + ' long'; | ||
var exampleMsg2 = "You have " + iTunes.getPlaylistCount() + " playlists in your library and " + iTunes.getTrackCount() + " tracks!"; | ||
console.log(exampleMsg); | ||
console.log(exampleMsg2); | ||
}else if(currentPlayerState == 'paused'){ | ||
var exampleMsg = 'iTunes is currently paused'; | ||
console.log(exampleMsg) | ||
}else{ // If iTunes is not playing or paused, we assume that he is stopped | ||
var exampleMsg = "iTunes is not playing at the moment."; | ||
console.log(exampleMsg); | ||
} | ||
57088
8
33
31