First, sorry that its a long post, I tried to explain it as best I could and be succinct. Read it at your own pace if you're bored or something, I'll be responsive to any replies.
Importantly I want to say that I know nothing about scripting, and (not trying to sound like a jerk) don't want to learn it myself because my brain is too fried to learn something that requires decent memory, organization or concentration ability due to an undisclosed reason, I just want to fix the script.
I'm not an idiot though, I can run terminal or script editor and follow instructions and plug things in and give error results.
The script is run from script editor and involves ifttt, webhooks, spotify, applescript and shellscript, but the script is the important part in this, because it's broken.
Basically the script is adding current playing spotify songs to predefined playlists, it works great, BUT if the song title has a quotation mark in it, single or double, it will give error messages (different ones in each situation) and not add those songs, and many songs have those.
So it renders it essentially useless to me, as the value of it to me is to control spotify from outside the app, like if I'm watching twitch.
I tried asking on reddit, hiring a freelancer from freelancer website, and apple support forums, people tried and offered a few suggestions but they didn't work so this is one of my last websites to try, it's very important to me that this script works, because I can't do proper music discovery without it, but it's broken as is.
For background, this is the tutorial I initially followed step by step to get the script working (for songs without quotes in the title).
This is the script I run in script terminal
if application "Spotify" is running then
tell application "Spotify"
if player state is playing then
set ArtistName to (get artist of current track)
set SongName to (get name of current track)
end if
end tell
end if
do shell script " curl -X POST -H \"Content-Type: application/json\" -d '{\"value1\":\"" & songname & "\",\"value2\":\"" & ArtistName & "\"}' https://maker.ifttt.com/trigger/add/with/key/REPLACEME"
I put my webhooks key in place of REPLACEME when I actually run it, but I was told not to share that online.
If I run it on a song with 1 quote marks ' it says in script editor result
error "sh: -c: line 0: unexpected EOF while looking for matching `"' sh: -c: line 1: syntax error: unexpected end of file" number 2
If I run it on a song with 2 quote marks " it says
"Bad Request"
If I run it on song without quote marks it is a success and adds the song to playlist and says
"Congratulations! You've fired the add event"
2 people from different sites have independently suggested I replace the shellscript with this instead, something about quoted form of
do shell script " curl -X POST -H \"Content-Type: application/json\" -d '{\"value1\":\"" & quoted form of songname & "\",\"value2\":\"" & quoted form of ArtistName & "\"}' https://maker.ifttt.com/trigger/add/with/key/REPLACEME"
It doesn't work though
1 quote fail is
error "sh: -c: line 0: unexpected EOF while looking for matching `"' sh: -c: line 1: syntax error: unexpected end of file" number 2
2 quote fail is
error "sh: -c: line 0: syntax error near unexpected token
(' sh: -c: line 0:
curl -X POST -H "Content-Type: application/json" -d '{"value1":"'Great Fairy Fountain (From "The Legend of Zelda: Ocarina of Time") - Piano Version'","value2":"'Koji Kondo'"}' https://maker.ifttt.com/trigger/add/with/key/REPLACEME'" number 2
(song info is just whatever I was playing while testing).
Someone also suggested
set myJSONdata to "{\"value1\":\"" & SongName & "\",\"value2\":\"" & ArtistName & "\"}"
do shell script "echo curl -X POST -H \"Content-Type: application/json\" -d " & quoted form of myJSONdata & " hhttps://maker.ifttt.com/trigger/add/with/key/REPLACEME"
I didn't know exactly where to plug that in, but it gave error messages as well
"curl -X POST -H Content-Type: application/json -d {"value1":"Orphée Suite - 6. Orphee's Return","value2":"Philip Glass"} hhttps://maker.ifttt.com/trigger/add/with/key/REPLACEME"
or
error "The variable SongName is not defined." number -2753 from "SongName"
Depending on where I placed it in the script, he didn't reply to me after he suggested it so I don't know if I screwed that up.
The poor guy who spent hours trying for me on freelancer tried, but he didn't have a mac and wasn't experienced in applescript, but he said the applescript part was the problem not the shellscript, after suggesting the quoted form and it didn't work, he tried
if application "Spotify" is running then
tell application "Spotify"
if player state is playing then
set ArtistName to (get artist of current track)
set SongName to (get name of current track)
end if
end tell
end if
set delim to "\""
set {myTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, {delim}}
set myList to text items of SongName
set AppleScript's text item delimiters to myTID
set listSize to count of myList
set counter = 0
repeat with myItem in myList
if counter < listSize
set SongName to SongName & delim
end if
end repeat
do shell script " curl -X POST -H \"Content-Type: application/json\" -d '{\"value1\":\"" & songname & "\",\"value2\":\"" & ArtistName & "\"}' https://maker.ifttt.com/trigger/add/with/key/REPLACEME"
It gave error
syntax error, a end of line can't go after this number, then it highlights set counter = 0 line in the script.
I don't really want to try freelancer again because I don't like the pressure of milestone payments deadlines and hiring people to work for me when I am so inexperienced in scripting to discuss it with them, I prefer to take it slowly on forums.
So that's all the info I have, any help is greatly appreciated, I will respond and try any suggestions, I can reimburse to someones paypal who gets it to work for time spent if they desire so, thank you.