Output $(querystring $(1)) with %20

This is my code now, but seems have new problem

$(eval var x="http://ac1011.hopto.org:4095/data/songlist.json?search=$(querystring $(1))",y="$(2)",a=($(urlfetch json http://ac1011.hopto.org:4095/data/songlist.json?search=$(querystring))),r=a.songlist,b=[],c="歌手:",d="歌名:",e="lid:",f="sid:",g=" ";if(y=="1"){x}else if(y!="null"){"Error!"}else{for(i=0;i<r.length-1;i++){b.push(i+1+"."+c+r[i].artist+g+d+r[i].title+g+e+r[i].list_id+g+f+r[i].song_id+g);b.length>0?b.join(' ').slice(0,400):'Error!!';}})

how output $(querystring $(1)) to %20, if $(1) have space?

e.g
input:precious%20you
output:precious%2520you
but i want precious%20you

input:precious you
output:precious
are you kidding me?

second,why i can’t send % & with $(querystring)?,that cause i can’t set more parameter to send, i think $(querystring) should more flexible to decide whether symbol need encode or not.

@932_frc

Continuing discussion from:
Send parameter to json & Querystring split


I set up two commands below, !songsearch and _songsearch which accept all the input parameters you mentioned in these other two topics. Copy and paste these into chat:

!addcom -cd=5 !songsearch -a=_songsearch $(eval a=decodeURIComponent(`$(querystring)`).split(`|`);if(a[0].trim()&&(a[1].trim()==`0`||a[1].trim()==`1`)){`${encodeURIComponent(a[0].trim())} ${a[1].trim()}`;}else{` `;})

!addcom -cd=5 _songsearch $(eval if(`$(2)`==`0`){a=$(urlfetch json http://ac1011.hopto.org:4095/data/songlist.json?search=$(1));b=[];for(i=0;i<a.songlist.length-1;i++){c=a.songlist[i];b.push(`${i+1}. 歌手: ${c.artist}, 歌名: "${c.title}", lid: ${c.list_id}, sid: ${c.song_id}`);}b.length>0?b.join(` | `).slice(0,400):`No songs found!`;}else if(`$(2)`==`1`){`http://ac1011.hopto.org:4095/data/songlist.json?search=$(1)`;}else{`Error!`;})

With this setup you can search song names without having to replace spaces with %20

Usage: !songsearch [song name to search] | [0 for non-full mode or 1 for full mode]

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.