Author Topic: Dundee Satellite Receiving Station Image Download  (Read 3999 times)

Ruyton

  • Gentle Breeze
  • **
  • Posts: 38
    • ISHROPSH19
    • Shotatton Weather
  • Station Details: Davie Vantage Vue
Dundee Satellite Receiving Station Image Download
« 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
Gary - Shrewsbury UK


WCDev

  • WeatherCat Developer
  • Administrator
  • Storm
  • *****
  • Posts: 2911
    • CW9739
    • ISCOTLAN25
    • Trixology
  • Station Details: Main Station: Vantage Pro-2, 24hr fars, solar, soil/leaf station, extra temp stations, no U.V. WeatherLink IP.
Re: Dundee Satellite Receiving Station Image Download
« Reply #1 on: March 25, 2016, 09:52:19 AM »
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.

Ruyton

  • Gentle Breeze
  • **
  • Posts: 38
    • ISHROPSH19
    • Shotatton Weather
  • Station Details: Davie Vantage Vue
Re: Dundee Satellite Receiving Station Image Download
« Reply #2 on: March 26, 2016, 09:49:28 AM »
Many thanks, I'll have a play with download and FTP and see if I can get anywhere.
Gary - Shrewsbury UK


Ruyton

  • Gentle Breeze
  • **
  • Posts: 38
    • ISHROPSH19
    • Shotatton Weather
  • Station Details: Davie Vantage Vue
Re: Dundee Satellite Receiving Station Image Download
« Reply #3 on: March 26, 2016, 03:57:14 PM »
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
Gary - Shrewsbury UK


Ruyton

  • Gentle Breeze
  • **
  • Posts: 38
    • ISHROPSH19
    • Shotatton Weather
  • Station Details: Davie Vantage Vue
Re: Dundee Satellite Receiving Station Image Download
« Reply #4 on: March 26, 2016, 05:19:17 PM »
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
Gary - Shrewsbury UK


elagache

  • Global Moderator
  • Storm
  • *****
  • Posts: 6494
    • DW3835
    • KCAORIND10
    • Canebas Weather
  • Station Details: Davis Vantage Pro-2, Mac mini (2018), macOS 10.14.3, WeatherCat 3
Nicely done! (Re: Dundee Satellite Receiving Station Image Download)
« Reply #5 on: March 26, 2016, 09:32:20 PM »
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]

Ruyton

  • Gentle Breeze
  • **
  • Posts: 38
    • ISHROPSH19
    • Shotatton Weather
  • Station Details: Davie Vantage Vue
Re: Dundee Satellite Receiving Station Image Download
« Reply #6 on: March 27, 2016, 05:11:09 PM »
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.
Gary - Shrewsbury UK


xairbusdriver

  • Storm
  • *****
  • Posts: 3126
    • EW7115 (E7115)
    • KTNGERMA20
    • Mid-South Weather
  • Station Details: Davis VP2 wireless + remote Anemometer/2014 Mac min - 10.15.7/WC 3.0.5
Re: Dundee Satellite Receiving Station Image Download
« Reply #7 on: March 27, 2016, 06:52:45 PM »
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.
THERE ARE TWO TYPES OF COUNTRIES
Those that use metric = #1 Measurement system
And the United States = The Banana system


Ruyton

  • Gentle Breeze
  • **
  • Posts: 38
    • ISHROPSH19
    • Shotatton Weather
  • Station Details: Davie Vantage Vue
Re: Dundee Satellite Receiving Station Image Download
« Reply #8 on: March 28, 2016, 10:28:45 AM »
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
Gary - Shrewsbury UK


WCDev

  • WeatherCat Developer
  • Administrator
  • Storm
  • *****
  • Posts: 2911
    • CW9739
    • ISCOTLAN25
    • Trixology
  • Station Details: Main Station: Vantage Pro-2, 24hr fars, solar, soil/leaf station, extra temp stations, no U.V. WeatherLink IP.
Re: Dundee Satellite Receiving Station Image Download
« Reply #9 on: March 28, 2016, 02:05:08 PM »
Very nice  [tup]

Ruyton

  • Gentle Breeze
  • **
  • Posts: 38
    • ISHROPSH19
    • Shotatton Weather
  • Station Details: Davie Vantage Vue
Re: Dundee Satellite Receiving Station Image Download
« Reply #10 on: March 28, 2016, 03:00:29 PM »
Meteosat Channel 4 (infrared 3.48 - 4.36 ?m) updating hourly  ;D
Gary - Shrewsbury UK