Skip to content

Commit

Permalink
Decode URI when result is obtained from shell
Browse files Browse the repository at this point in the history
  • Loading branch information
AngryKiller committed May 31, 2021
1 parent a5ee9aa commit 1aeb11d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var iTunesEmitter = iTunes.emitter;

switch(currentTrack.playerState){
case "playing": {
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 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 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);
Expand All @@ -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(decodeURIComponent(currentTrack.name) + " has been resumed! ");
console.log(currentTrack.name + " has been resumed! ");
// Or if it is a new track
}else if(type === 'new_track'){
console.log(decodeURIComponent(currentTrack.name)+" is now playing!")
console.log(currentTrack.name+" is now playing!")
}
});

// Do something when iTunes is paused
iTunesEmitter.on('paused', function(type, currentTrack){
console.log(decodeURIComponent(currentTrack.name)+" is now paused!");
console.log(currentTrack.name+" is now paused!");
});
// Do something when iTunes is stopped
iTunesEmitter.on('stopped', function(){
Expand Down
2 changes: 1 addition & 1 deletion itunes-bridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ function runScript(req, type, args, isJson) {
switch(type){
case "fetch": {
if(isJson) {
return JSON.parse(execSync('cscript //Nologo ' + iTunesFetcherScpt + ' ' + req, { encoding: 'utf8'}));
return JSON.parse(decodeURIComponent(execSync('cscript //Nologo ' + iTunesFetcherScpt + ' ' + req, { encoding: 'utf8'})));
}else{
return execSync('cscript //Nologo ' + iTunesFetcherScpt+' ' + req, { encoding: 'utf8'});
}
Expand Down

0 comments on commit 1aeb11d

Please sign in to comment.