SCRIPT keyword for urlopen

AmigaOS users can make feature requests in this forum.
JosDuchIt
Posts: 291
Joined: Sun Jun 26, 2011 5:47 pm
Contact:

SCRIPT keyword for urlopen

Post by JosDuchIt »

I have been trying with no success to make urlopen accept a script
Is this possible?

If not an urlopen keyword SCRIPT to make thiis possible would be much appreciated
User avatar
thomasrapp
Posts: 310
Joined: Sat Jun 18, 2011 11:22 pm

Re: SCRIPT keyword for urlopen

Post by thomasrapp »

What do you mean by "a script" in this context? Do you have an example?
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:I have been trying with no success to make urlopen accept a script
Is this possible?

If not an urlopen keyword SCRIPT to make thiis possible would be much appreciated
Do you mean something like this?

URL Preferences
Active - Client Name - Client Path - Commandline Format
Check - Odyssey - Path-to-my:Script.rx - "%s"

And the script looking like this:

Code: Select all

/*
*/
PARSE ARG URL

/* Check for and add missing http://, otherwise Odyssey won't load any page */
IF POS("http",URL) = 0 THEN
	URL="http://"URL
ENDIF

/* Check for Odyssey running, if yes, just open the site on a new webpage */
IF POS("ODYSSEY", SHOW(PORTS)) > 0 THEN DO
	ADDRESS ODYSSEY.1
	SHOW
	OPEN NEWPAGE NAME '"'URL'"'
	EXIT 0
END

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

DO FOREVER
	IF POS("ODYSSEY", SHOW(PORTS)) > 0 THEN DO
		ADDRESS ODYSSEY.1
		SHOW
		ADDRESS COMMAND "Wait 2"
		OPEN NAME '"'URL'"'
		EXIT 0
	END
END
Works if you set the script flag on your script and let it run in "Shell" mode
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, something in this style, actually was a python script, checking if the URL was from a YouTube video, then passing the URL to getvideo.
Worked ok from YAM.Had problems to make it work with urlopen
As you confirm it must be possible, i'll try again
thanks

This is the script (inspired by broadblues)
import os, string, sys, arexx

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

os.chdir('dh0:Utilities/getVideo')
x = url.find("<EMPTY>en:")
if x == 19:
url = url[:x] + url[x+14:]
elif 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')")
if odyss == '1':
print("arexx")
# the port exists the port tackles www;
arexx.dorexx('ODYSSEY.1', 'OPEN NAME ' + url)
else:
if url[0:3] == "www":
os.system('appdir:Odyssey http ' + url)
else:
os.system('appdir:Odyssey http ' + url[7:])


it works with one peculiarity

whereas i can launch
7.Amiga OS 4:Utilities/Getvideo> playyTubeOdyss.py www.amigans.net correctly (ODYSSEY being open)

double clicking on the url (in a yam message) does work for http://www.amigans but not for www.amigans.be (ODYSSEY being open)

I can of course modify the script to take this into account, still strange, an urlopen issue?
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 »

double clicking on the url (in a yam message) does work for http://www.amigans but not for http://www.amigans.be (ODYSSEY being open)

I can of course modify the script to take this into account, still strange, an urlopen issue?
Nope.

As you can see in my script i had to add a workaround for the very same problem.
/* Check for and add missing http://, otherwise Odyssey won't load any page */
IF POS("http",URL) = 0 THEN
   URL="http://"URL
ENDIF
Odyssey is the culprit, as it seems it can't cope with web addresses missing the http:// part while being given through it's AREXX port, i.e. "OPEN NAME url".

As you are addressing Odyssey aswell through it's AREXX port you are suffering the same limitation.
I can see that you also add the http part, but it seems you do it too late in your script and you miss the "://" which might be enough to make Odyssey blow.

You may want to add the "http://" part in front of any url *before* you send it through Odyssey's AREXX port or start it from scratch.
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,

There was a problem with my URL Prefs, for www.lh

after correcting this my script works oK so odyssey arexx's port seems to accept www.etc URL's
ODYSSEY however doesn't accept these from the command line though.

One thing that may also have interfered is using
www.amigans.net for testing with arexx
it opens on
http://amigans.net not on http://www.amigans.net
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 »

That's another bug in Odyssey, then :-)
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

In my script playYTubeOdyss.py i have the line

arexx.dorexx('ODYSSEY.1', 'OPEN NAME ' + url)

this does work from the shell directly for "complex" URL('s that fail generally with arexx
7.Amiga OS 4:Utilities/Getvideo> playYTubeOdyss.py http://aanbodinfo.com/mail/display.php? ... =16&N=2398
but not for
7.Amiga OS 4:Utilities/Getvideo> urlopen http://aanbodinfo.com/mail/display.php? ... =16&N=2398

You seem to take this into account in your script using

 OPEN NEWPAGE NAME '"'URL'"'

I tried to copy this under python

url = '"' + url + '"'
arexx.dorexx('ODYSSEY.1', 'OPEN NAME ' + url)

but this does not work
Any suggestion?
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

In my script playYTubeOdyss.py i have the line

arexx.dorexx('ODYSSEY.1', 'OPEN NAME ' + url)

this does work from the shell directly for "complex" URL('s that fail generally with arexx
7.Amiga OS 4:Utilities/Getvideo> playYTubeOdyss.py http://aanbodinfo.com/mail/display.php? ... =16&N=2398
but not for
7.Amiga OS 4:Utilities/Getvideo> urlopen http://aanbodinfo.com/mail/display.php? ... =16&N=2398

You seem to take this into account in your script using

 OPEN NEWPAGE NAME '"'URL'"'

I tried to copy this under python

url = '"' + url + '"'
arexx.dorexx('ODYSSEY.1', 'OPEN NAME ' + url)

but this does not work
Any suggestion?
Oh, fishing in the mist here as i don't know how to script in Python.

But you probably need to add the quotation marks to the command that opens the new page.
Adding them to the url might be misinterpreted.

Plus the ' is a special char used in AREXX, not sure if it would be interpreted right as that when it comes as string.

Something like this maybe?
arexx.dorexx('ODYSSEY.1', 'OPEN NAME ' + '"'url'"')

EDIT: Wait a sec, i see (unfortunately skipped the two links where you pointing out urlopen) that your script itself works, but it refuses to when using urlopen.

Lets see your urlopen prefs then :-)
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 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
Post Reply