Trixology
WeatherCat => WeatherCat Integration => Topic started by: Ruyton on March 24, 2016, 11:02:04 AM
-
I have a free account with Dundee Satellite Receiving Station, but downloading of images requires a username and password.
The site gives the option of downloading a cookie so that you can access the pictures without entering these every time, but pasting the image link into the WeatherCat imagery channels in Preferences obviously doesn't work as the username and passwrd aren't being submitted.
Is there any way to view the Dundee images in WeatherCat?
Gary
Shrewsbury UK
Davies Vantage VUE & WeatherCat
-
As you've found out, not really - it needs straight access at a URL and can't manage any security.
The only thing I can think of is to periodically download it with something else, then FTP it to somewhere WeatherCat can access it.
-
Many thanks, I'll have a play with download and FTP and see if I can get anywhere.
-
OK, this seems to work :)
This is Applescript exported as an Application and set to keep running rather than stopping after one run. The script passes the username and password to the Dundee Satellite Receiving website along with the URL. The latest full-disk image is downloaded to a folder on the desktop and the address of that image is entered in the WeatherCat imagery preferences. The repeat is set to 3600 seconds (one hour) to see how that plays out.
I can't really take credit for this, as some Googling found bits of script that I could put together to do the job. The username and password are obviously as per your account. I'm not uploading this anywhere, just displaying it in my WeatherCat imagery window, so I don't think that it will upset the Dundee station as all it's doing is automating what I might do in my browser.
If anybody can improve on this script or point out any pitfalls, then please do.
---------------------
on idle
set {tUrl, dFolder} to {"http://username:password@www.sat.dundee.ac.uk/xrit/latest/latest_MSG_2_S4_grid.jpg ", "~/Desktop/Weather_Sat/"}
set {oAStid, AppleScript's text item delimiters} to {AppleScript's text item delimiters, "/"}
set fName to (last text item of tUrl) as string
set AppleScript's text item delimiters to oAStid
do shell script ("mkdir -p " & dFolder & "; curl -A/--user-agent " & tUrl & " >> " & (dFolder & fName))
return 3600
end idle
-
Simplified it a bit.
I'm not entirely sure that this is overwriting the previous downloaded image, more testing needed.
------
on idle
do shell script ("curl -A/--user-agent " & "http://username:password@www.sat.dundee.ac.uk/xrit/latest/latest_MSG_2_S4_grid.jpg " & " >> " & ("~/Desktop/Weather_Sat/" & "latest_MSG_2_S4_grid.jpg "))
return 3600
end idle
-
Dear Ruyton and WeatherCat scripters,
OK, this seems to work :)
This is Applescript exported as an Application and set to keep running rather than stopping after one run. The script passes the username and password to the Dundee Satellite Receiving website along with the URL. The latest full-disk image is downloaded to a folder on the desktop and the address of that image is entered in the WeatherCat imagery preferences. The repeat is set to 3600 seconds (one hour) to see how that plays out.
This looks like a perfectly reasonable solution! The only suggestion, if desired, is to add a few comments about what these lines are doing. Even if you think you are only writing this AppleScript for yourself, you still might thank yourself should something need to be changed a year or two from now. When I look at my own AppleScripts I'm amazed I actually succeeded in writing them! [biggrin]
Congratulations! [tup]
Cheers, Edouard [cheers1]
-
I'm not quite there yet, the new downloaded image won't overwrite the current image, so I need to change my script to delete the old one before the new one is grabbed. Looks easy enough, I'll have a play tomorrow.
-
Only a minimalist AS user, but if I understand what you need/want, perhaps I can help.
Question: Do I understand that you are downloading the images to your own computer and then uploading them to your site? If "yes", continue reading. If "no", ignore the rest of the post! [lol]
You obviously don't want to just keep adding a new (probably rather large) file, so you really need to have the last one over-writen by the next one. [rolleyes2] I would suggest simply renaming the image file, while it's accessible by AS, to the same name before uploading it to your site. That should guarantee only the last image is available; the new file will automatically over-write the old one.
I would assume that you are letting WC do the grunt (FTP) work, also. WC will automatically upload just about anything for you if you simply add that something to the list of "Additional Files". You can also specify how often that uploading should be done.
-
I think that I've just about cracked it. Rather than renaming the existing file, I'm just deleting it before the newer file is downloaded. The download is set every hour and WC 'grabs' the image from the folder every 30 minutes (although this could be set to one hour too as there is only going to be a nano-second when there isn't a jpg file to be read by WC.
No upload to anywhere so no FTP needed, just viewable in in the WC Imagery window with animation also being available. I probably wouldn't incur the wrath of the Dundee Receiving Station if I did upload the odd image to my website, but if I decide to do that I'll check with them first. The images are provided free, but registration is required to view them.
So, the script:
1. Deletes any .jpg images in my /Desktop/Weather_Sat/ folder
2. Downlads the latest full-disk image from the Dundee Satellite Receiving Station, passing the username and password with the URL
3. Waits 3600 seconds before doing it over again.
Weathercat > Preferences > Imagery has the location of the file in /Desktop/Weather_Sat/ and displays it in the Imagery Window.
That's it, that's all I wanted to do. The only complication was the requirement to send a username and password otherwise I wouldn't need the script at all :)
------
on idle
tell application "Finder"
delete (every item of folder ("Weather_Sat") whose name ends with ".jpg")
end tell
do shell script ("curl http://username:password@www.sat.dundee.ac.uk/xrit/latest/latest_MSG_4_S4_grid.jpg >> ~/Desktop/Weather_Sat/latest_MSG_4_S4_grid.jpg ")
return 3600
end idle
-
Very nice [tup]
-
Meteosat Channel 4 (infrared 3.48 - 4.36 ?m) updating hourly ;D