Page 1 of 4

SCRIPT keyword for urlopen

Posted: Tue Mar 31, 2015 11:12 am
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

Re: SCRIPT keyword for urlopen

Posted: Tue Mar 31, 2015 12:25 pm
by thomasrapp
What do you mean by "a script" in this context? Do you have an example?

Re: SCRIPT keyword for urlopen

Posted: Tue Mar 31, 2015 10:21 pm
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

Re: SCRIPT keyword for urlopen

Posted: Wed Apr 01, 2015 8:53 am
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?

Re: SCRIPT keyword for urlopen

Posted: Wed Apr 01, 2015 11:36 am
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.

Re: SCRIPT keyword for urlopen

Posted: Wed Apr 01, 2015 2:41 pm
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

Re: SCRIPT keyword for urlopen

Posted: Wed Apr 01, 2015 3:22 pm
by Raziel
That's another bug in Odyssey, then :-)

Re: SCRIPT keyword for urlopen

Posted: Wed Apr 08, 2015 10:14 am
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?

Re: SCRIPT keyword for urlopen

Posted: Wed Apr 08, 2015 12:26 pm
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 :-)

Re: SCRIPT keyword for urlopen

Posted: Wed Apr 08, 2015 2:05 pm
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