This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

http geturl bracket issue [solved]

Help for those learning Tcl or writing their own scripts.
Post Reply
E
Elfriede
Halfop
Posts: 67
Joined: Tue Aug 07, 2007 4:21 am

http geturl bracket issue [solved]

Post by Elfriede »

Hi everyone :)

i do face a small problem, where i need some help :)

Code: Select all

       set token [::http::geturl http://api.tvmaze.com/shows/$shownumber?embed[]=nextepisode&embed[]=previousepisode -timeout 4000]
when i open this url in my browser everything is fine, but the eggdrop seems to have a problem with those brackets. Because saving the output to file will result in outputting the previous episode only. Im guessing this has something to do with those []. Anyone has an idea how to solve that?
thanks for helping
Last edited by Elfriede on Thu Oct 20, 2016 3:50 pm, edited 1 time in total.
User avatar
Madalin
Master
Posts: 310
Joined: Fri Jun 24, 2005 11:36 am
Location: Constanta, Romania
Contact:

Post by Madalin »

Use \[ and \] instead of [ and ]
E
Elfriede
Halfop
Posts: 67
Joined: Tue Aug 07, 2007 4:21 am

Post by Elfriede »

when i try that i get: Illegal characters in URL path
User avatar
Madalin
Master
Posts: 310
Joined: Fri Jun 24, 2005 11:36 am
Location: Constanta, Romania
Contact:

Post by Madalin »

$ into \$

or just use set token [::http::geturl "http://api.tvmaze.com/shows/$shownumber ... ousepisode" -timeout 4000]
E
Elfriede
Halfop
Posts: 67
Joined: Tue Aug 07, 2007 4:21 am

Post by Elfriede »

its not caused by the $
its [] but adding "" doesnt help either :/
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

[] are used for command substitutions, and will cause issues with your code. Further, http URI's can't contain literal [], so you'll have to use %-substitutions; replace [ with %91, and ] with %93

Edit:
Accidentally wrote the decimal values as opposed to the hexadecimal ones;
"[" => "%5b"
"]" => "%5d"

That said, using ::http::formatQuery is indeed a better approach, as suggested by OP
Last edited by nml375 on Thu Oct 20, 2016 5:25 pm, edited 1 time in total.
NML_375
E
Elfriede
Halfop
Posts: 67
Joined: Tue Aug 07, 2007 4:21 am

Post by Elfriede »

Code: Select all

http://api.tvmaze.com/shows/$shownumber?embed%91%93=nextepisode&embed%91%93=previousepisode
If i change like that; doesn't work :/

edit:

Thanks for all the help - could fix it by my own. If someone's interested:

Code: Select all

set test "http://api.tvmaze.com/shows/$shownumber?[::http::formatQuery embed\[\] nextepisode embed\[\] previousepisode]"
Post Reply