diff --git a/README.md b/README.md index a3f05a5..95c4ec2 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ var iTunesEmitter = iTunes.emitter; switch(currentTrack.playerState){ case "playing": { - var exampleMsg = "iTunes is currently playing " + currentTrack.name + " by " + currentTrack.artist + ' from the album "' + currentTrack.album + '". This song is ' + currentTrack.duration + 's long and will finish in ' + currentTrack.remainingTime+'s'; + var exampleMsg = "iTunes is currently playing " + decodeURIComponent(currentTrack.name) + " by " + decodeURIComponent(currentTrack.artist) + ' from the album "' + decodeURIComponent(currentTrack.album) + '". This song is ' + currentTrack.duration + 's long and will finish in ' + currentTrack.remainingTime+'s'; var exampleMsg2 = "You have " + iTunes.getPlaylistCount('/Users/steve/Music/iTunes/iTunes Library.xml') + " playlists in your library and " + iTunes.getTrackCount('/Users/steve/Music/iTunes/iTunes Library.xml') + " tracks!"; console.log(exampleMsg); console.log(exampleMsg2); @@ -38,16 +38,16 @@ switch(currentTrack.playerState){ iTunesEmitter.on('playing', function(type, currentTrack){ // If it is a paused track that restarts playing if(type === "player_state_change") { - console.log(currentTrack.name + " has been resumed! "); + console.log(decodeURIComponent(currentTrack.name) + " has been resumed! "); // Or if it is a new track }else if(type === 'new_track'){ - console.log(currentTrack.name+" is now playing!") + console.log(decodeURIComponent(currentTrack.name)+" is now playing!") } }); // Do something when iTunes is paused iTunesEmitter.on('paused', function(type, currentTrack){ - console.log(currentTrack.name+" is now paused!"); + console.log(decodeURIComponent(currentTrack.name)+" is now paused!"); }); // Do something when iTunes is stopped iTunesEmitter.on('stopped', function(){ diff --git a/package.json b/package.json index 56a1ee1..12b07e7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "itunes-bridge", - "version": "0.6.6", + "version": "0.6.7", "description": "A macOS and Windows NodeJS package to control and get informations from iTunes and macOS Music app through AppleScript", "main": "itunes-bridge.js", "repository": { diff --git a/wscript/iTunesFetcher.js b/wscript/iTunesFetcher.js index 9ea6100..03d0780 100644 --- a/wscript/iTunesFetcher.js +++ b/wscript/iTunesFetcher.js @@ -30,16 +30,16 @@ function getCurrentTrack(){ } } json = { - "name": currentTrack.name, - "artist": currentTrack.artist, - "album": currentTrack.album, + "name": encodeURIComponent(currentTrack.name), + "artist": encodeURIComponent(currentTrack.artist), + "album": encodeURIComponent(currentTrack.album), "mediaKind": currentTrack.kind, "duration": currentTrack.duration, "elapsedTime": iTunesApp.PlayerPosition, "remainingTime": remainingTime, - "genre": currentTrack.genre, + "genre": encodeURIComponent(currentTrack.genre), "releaseYear": currentTrack.year, - "id": currentTrack.name, // I haven't found a way to get the current track ID with iTunes COM :/ + "id": encodeURIComponent(currentTrack.name), // I haven't found a way to get the current track ID with iTunes COM :/ "playerState": playerState }; } catch (e) {