SCRIPT keyword for urlopen

AmigaOS users can make feature requests in this forum.
User avatar
Raziel
Posts: 1170
Joined: Sat Jun 18, 2011 4:00 pm
Location: a dying planet

Re: SCRIPT keyword for urlopen

Post by Raziel »

JosDuchIt wrote:@Raziel http.lh contains only this line (not commented out)
ClientName="GetVideo" ClientPath="DH0:Utilities/Getvideo/playyTubeOdyss.py" CMDFORMAT="%s"
I have tried "*%s*" and '"%s'" without success.ight now i am testig under OS4.1 Update 6
, but it is the same under OS4.1FE
The only other thing for testing i can think of is, that you add some sort of "echo" line to print the url before it gets send to Odyssey.

This way you can check what actual line is being sent and where the error might come from.
People are dying.
Entire ecosystems are collapsing.
We are in the beginning of a mass extinction.
And all you can talk about is money and fairytales of eternal economic growth.
How dare you!
– Greta Thunberg
JosDuchIt
Posts: 291
Joined: Sun Jun 26, 2011 5:47 pm
Contact:

Re: SCRIPT keyword for urlopen

Post by JosDuchIt »

@raziel

the python print() statements are not seen when i use urlopen, they are when i launcht the script directly

6.Amiga OS 4:Utilities/Getvideo> urlopen http://www.amigawiki.com/
6.Amiga OS 4:Utilities/Getvideo> playytubeodyss.py http://www.amigawiki.com/
1
arexx
arexx.dorexx('ODYSSEY.1', 'OPEN NAME ' http://www.amigawiki.com/

I did insert requesters that pop up in both cases.
asl.MessageBox("ytube", "arexx.dorexx('ODYSSEY.1', 'OPEN NAME ' " + url, "OK")

It is not clear if it is an ODyssey or an urlopen issue.


I think i would like to re-ask for a SCRIPT keyword for urlopen that makes debugging a script easier (see the print statement)
and while at it,
- not to have to hit the return key every time you chenge e field in url prefs
- have some feedback in urlprefs of where the pref files are ocated (envarc:launch-handler/URL)


Hidden Text - Click to Show :
import os, string, sys, arexx, asl

if len(sys.argv) == 2:
url = sys.argv[1]
else:
exit()

os.chdir('dh0:Utilities/getVideo')

if url.find('embed') > 0 or url.find('watch') > 0:
os.system('Getvideo.rexx "' + url + '" play')
exit()
os.chdir('DH1:Internet/Odyssey1.23')
try:
ports = os.getports()
ports = " ".join(ports)
# print ports
except AttributeError:
# The getports function wasn't present so we call the REXX
# equivalent.
(rc,rc2,ports) = arexx.dorexx("REXX","return show('P')")
# print(rc)
if rc != 0:
# We couldn't even call REXX something seriously up here
# Bail out with a requester.
ErrorExit("Couldn't Find ARexx!")
#return ports
else:
# print ports
rc,rc2,odyss = arexx.dorexx('REXX',"return show('P','ODYSSEY.1')")
print(odyss)
if odyss == '1':
print("arexx")
# the port exists the port tackles www; w
# url = '"' + url + '"'
asl.MessageBox("ytube", "arexx.dorexx('ODYSSEY.1', 'OPEN NAME ' " + url, "OK")
print("arexx.dorexx('ODYSSEY.1', 'OPEN NAME ' " + url)
arexx.dorexx('ODYSSEY.1', 'OPEN NAME ' + url)
else:
# print("DOS")
if url[0:3] == "www":
# print('RUN appdir:Odyssey http:// ' + url)
os.system('RUN appdir:Odyssey http:// ' + url)
else:
# print('RUN appdir:Odyssey ' + url)
os.system('RUN appdir:Odyssey ' + url)
User avatar
Raziel
Posts: 1170
Joined: Sat Jun 18, 2011 4:00 pm
Location: a dying planet

Re: SCRIPT keyword for urlopen

Post by Raziel »

JosDuchIt wrote:@raziel
I think i would like to re-ask for a SCRIPT keyword for urlopen that makes debugging a script easier (see the print statement)
and while at it,
- not to have to hit the return key every time you chenge e field in url prefs
We had that before, didn't we? ;-)

I don't think they'll fix something that ain't broken :-)
- have some feedback in urlprefs of where the pref files are ocated (envarc:launch-handler/URL)
Have you also tried to set https.lh and http://www.lh to the same setting as your http.lh in url prefs?
(Just so we rule out anything)
People are dying.
Entire ecosystems are collapsing.
We are in the beginning of a mass extinction.
And all you can talk about is money and fairytales of eternal economic growth.
How dare you!
– Greta Thunberg
JosDuchIt
Posts: 291
Joined: Sun Jun 26, 2011 5:47 pm
Contact:

Re: SCRIPT keyword for urlopen

Post by JosDuchIt »

@Raziek
Have you also tried to set https.lh and http://www.lh to the same setting as your http.lh in url prefs?
yes

i think i'll try to convert to an arexx script & report on that
JosDuchIt
Posts: 291
Joined: Sun Jun 26, 2011 5:47 pm
Contact:

Re: SCRIPT keyword for urlopen

Post by JosDuchIt »

@Raziel
Results of my trials:

wether with a dos script an arexx script or a py script AND using "%s" as the argument for the script in urlOpen


- launching the script directely for shell on
http://interactief.standaard.be/optiext ... JGYiZtjzdb
works
- referring to it through urlopen AND using "%s" as the argument for the script in urlOpen will NOT work

This is not an ODYSSEY problem, (it occurs with your script to the same problem occurs for IBROWSE as well

The script used for IBrowse is derived from your
s
Hidden Text - Click to Show :
/*
*/
PARSE ARG URL
OPTIONS RESULTS
/* Check for and add missing http://, otherwise Odyssey won't load any page */
IF POS("http",URL) = 0 THEN
   URL="http://"URL
ENDIF
say URL
/* Check for Odyssey running, if yes, just open the site on a new webpage */
IF POS("IBROWSE", SHOW(PORTS)) > 0 THEN DO
ADDRESS IBROWSE
SAY "port exists"
SHOW
'GOTOURL URL='||URL
EXIT 0
END

/* If not, run IBROWSE and then open the site */
ADDRESS COMMAND "WBRun APPDIR:IBROWSE "

DO FOREVER
IF POS("IBROWSE", SHOW(PORTS)) > 0 THEN DO
ADDRESS IBROWSE
SHOW
ADDRESS COMMAND "Wait 2"
'GOTOURL URL='||URL
EXIT 0
END
END
ClientName="IBSCRIPT" ClientPath="DH0:Utilities/Getvideo/playHTML_IB.rxx" CMDFORMAT="%s"

6.Amiga OS 4:Utilities/Getvideo> urlopen "http://interactief.standaard.be/optiext ... JGYiZtjzdb"
6.Amiga OS 4:Utilities/Getvideo> playHTML_IB.rxx "http://interactief.standaard.be/optiext ... JGYiZtjzdb"
"http://interactief.standaard.be/optiext ... JGYiZtjzdb"
port exists
6.Amiga OS 4:Utilities/Getvideo>

Please note
- the absence when using urlopen of output
- i tested commenting out the 2 "say" statements : same result
User avatar
Raziel
Posts: 1170
Joined: Sat Jun 18, 2011 4:00 pm
Location: a dying planet

Re: SCRIPT keyword for urlopen

Post by Raziel »

Well, i'm sorry, but all i can say is it works with my script here :-)

I just did this command and haven't changed a thing in my setup.
Shell> urlopen "http://interactief.standaard.be/optiext ... JGYiZtjzdb"
It opens the page just fine in Odyssey...don't know about IBrowse, never used it.


The only advice i could give at this point is to start from scratch.
Write the simplest script that assumes Odyssey is already running and only addresses the port and opens a new url (even give the url hardcoded in the first step)

Only then, if it works like you want it to, start to add stuff, like checking if Odyssey is running and such.

And most importantly, always try with urlopen, so you don't end up with hours of work and you are stuck at the same point.

Something seems to be interfering in your system...you need to find out what it is...and please keep posting your findings here...this is very intruiging, i want to know what caused your trouble :-)
People are dying.
Entire ecosystems are collapsing.
We are in the beginning of a mass extinction.
And all you can talk about is money and fairytales of eternal economic growth.
How dare you!
– Greta Thunberg
JosDuchIt
Posts: 291
Joined: Sun Jun 26, 2011 5:47 pm
Contact:

Re: SCRIPT keyword for urlopen

Post by JosDuchIt »

@Raziel

it is very intriguing and very frustrating
It is clear that a script working when called from urlopen will not necessarily work when launched as a script


For odyssey and arexx script i noted

OPEN NEWPAGE NAME '"'URL'"' /// works with urlopen & not directly from script (protection bit set =S)
'OPEN NEWPAGE NAME '||URL /// does not work with urlopen but does directly from script

For IBrowse i noted
"GOTOURL URL="||URL works from script , not when called from urlopen
GOTOURL URL='"'URL'"' does not work in both cases

From the snoopy trace i read
GOTOURL URL='"'URL'"'
00023 : urlopen : -----> RunCommand(0x17155B7D "urlopen",,""http://interactief.standaard.be/optiext ... ension.dll
00043 : URL/launch-handler 53.38 : o.k. = SystemTagList("DH0:Utilities/Getvideo/playHTML_IB.rxx interactief.standaard.be/optiext/optie
00124 : RX : -----> RunCommand(0x1715593D "RX",,"DH0:Utilities/Getvideo/playHTML_IB.rxx interactief.standaard.be
00139 : urlopen : o.k. = Open("URL: http://interactief.standaard.be/optiext ... EItndmwcAt
00164 : urlopen : <----- RunCommand(0x17155B7D "urlopen",,""http://interactief.standaard.be/optiext ... ension.dll
00173 : RX : <----- RunCommand(0x1715593D "RX",,"DH0:Utilities/Getvideo/playHTML_IB.rxx interactief.standaard.be

the http:// part is "eaten" in this case, why not when using ODYSSEY ?? & nearly the same script??


I am hating the url prefs profoundly by now.: in every third change, i forget the return :(((
User avatar
Raziel
Posts: 1170
Joined: Sat Jun 18, 2011 4:00 pm
Location: a dying planet

Re: SCRIPT keyword for urlopen

Post by Raziel »

I see now what you mean...

It just opens a blank page when using openurl with the url given NOT in quotes (when given IN quotes it opens up fine).
Your site is actually a referrer which, on loading, should send you to the real site...

I'm not sure if this is a bug in openurl...it looks like it...Snoopy doesn't really help, but something is going on

Edit:
Actually...the snoopy log DOES show something...the actualy command used to open the URL doesn't have any quotes around the url sent...that may probably be it.

openurl seems to eat the given quotes which leads ultimately to certain websites not working

Unfortunately i'm not able to "fix" this behaviour in my script because openurl will circumvent every try
People are dying.
Entire ecosystems are collapsing.
We are in the beginning of a mass extinction.
And all you can talk about is money and fairytales of eternal economic growth.
How dare you!
– Greta Thunberg
JosDuchIt
Posts: 291
Joined: Sun Jun 26, 2011 5:47 pm
Contact:

Re: SCRIPT keyword for urlopen

Post by JosDuchIt »

@Raziel
I think i have a break through?.

In short use
"*"http://%s*"" instead of "%s" when using a script
(that is fior http.lh, similar for other pref files)
At least here the script called directly or via urlpen, do get the same full "url" wheras
with "%s"
script use directly gets http://thissite.com
and called from urlopen gets thissite.com

debugging starts to be possible then.
A big drawback form urlopen is that debug print statements (echo DOS, say arecxx, print() python) are never seen.

Requestchoice can be seen in a DOS script called from urlopen, but not when called from an arexx script or a python script (alternative here asl.MessageBox("url", url, "OK"))

It would be nice if the urlopen doc gave some more info on the commandline format. ( why are the examples as given? what are the quotes an astersisks for)
The "standard" examples given, just open an other Browser, that's why we are looking for scropts that can open the url on tha active browser & active tab.
User avatar
Raziel
Posts: 1170
Joined: Sat Jun 18, 2011 4:00 pm
Location: a dying planet

Re: SCRIPT keyword for urlopen

Post by Raziel »

There's alittle checkbox on every URL prefs tabon the lower left.

Checking it will give you the exact commandline that will be executed before execution.

Unfortunately that still doesn't explain why Odyssey interprets the given url wrong as it's perfectly fine in the DEBUG output (i can even copy the exact same command and it works) :-(
Stupid, strange errors...
People are dying.
Entire ecosystems are collapsing.
We are in the beginning of a mass extinction.
And all you can talk about is money and fairytales of eternal economic growth.
How dare you!
– Greta Thunberg
Post Reply