Meteo script update

itt, magyar billentyűzethez itt, a forrás meg alant (a script a ~/Pictures könyváradban létre fog hozni egy delme-meteo nevű foldert, amibe a leszippantott képeket menti. Ezt a foldert törli és létrehozza minden alkalommal újra és újra.):

(*
	Meteo
	by Gabor PENOFF (//fns.pappito.com)
	release 20100516-1002
	Requirements:
	- before run you need to Enable Access for Assistive Devices in SysPrefs/Universal Access
	- install Growl from http://growl.info to get non-modal notification dialogs
	Usage:
	- just run the script
	That's all.
*)
set myScriptID to "Meteo" -- ID for Growl display
-- set date variables:
set myYear to get text 1 thru 4 of (year of (current date) as string)
set myMonth to month of (current date) as number
if myMonth < 10 then set myMonth to "0" & myMonth as string
set myDay to day of (current date)
if myDay < 10 then set myDay to "0" & myDay as string
set myHour to hours of (current date)
if myHour < 10 then set myHour to "0" & myHour as string
set myMinute to "00"
set tmpDir to "delme-meteo"
set myFilePrefix to "delme-met-"
set tIdokepStart to "http://www.idokep.hu/arch_kep.php?kep="
set myURLs to {¬
	"http://img.koponyeg.hu/img/15napos/" & myYear & "/" & myMonth & "/1_" & myYear & "-" & myMonth & "-" & myDay & "grafikon.png|png", ¬
	"http://terkep.idokep.hu/kep.php?kep=mix|jpg", ¬
	"http://terkep.idokep.hu/kep.php?kep=hoterkep2&regio=hu1680|jpg", ¬
	"http://terkep.idokep.hu/kep.php?kep=felhokep2&regio=hu1680|jpg", ¬
	"http://terkep.idokep.hu/kep.php?kep=szelterkep2_anim|gif", ¬
	"http://terkep.idokep.hu/kep.php?kep=szelterkep2&regio=hu1680|jpg", ¬
	"http://terkep.idokep.hu/kep.php?kep=legnyomasterkep|jpg", ¬
	"http://feny.idokep.hu/kep.php?kep=csap24|jpg", ¬
	"http://feny.idokep.hu/kep.php?kep=csap1|jpg", ¬
	"http://feny.idokep.hu/kep.php?kep=aqua|jpg", ¬
	"http://terkep.idokep.hu/kep.php?kep=rh|jpg", ¬
	"http://terkep.idokep.hu/kep.php?kep=uv|jpg", ¬
	"http://terkep.idokep.hu/kep.php?kep=pollen0|jpg"}
set rootDir to (path to home folder as string) & "Pictures"
tell application "Finder" to set fullDir to rootDir & ":" & tmpDir -- save fullDir
set myNotification to "Downloading METEO images to " & fullDir & "..."
tell me to notifyWithGrowl(myScriptID, myNotification)
try
	tell application "Finder" to delete fullDir
end try
tell application "Finder" to make new folder at alias rootDir with properties {name:tmpDir}
-- download files:
tell application "URL Access Scripting"
	set i to 1
	repeat with myURL in myURLs
		set thisURL to (text 1 thru ((offset of "|" in myURL) - 1) of myURL)
		set thisExt to (text ((offset of "|" in myURL) + 1) thru (length of myURL) of myURL)
		set the myFile to fullDir & ":" & myFilePrefix & i & "." & thisExt
		download thisURL to file myFile replacing yes
		set i to i + 1
	end repeat
end tell
-- display images using full-featured QuickLook window:
tell application "Finder"
	activate
	open folder fullDir
	set current view of front Finder window to list view
end tell
tell application "System Events"
	key code 0 using {command down} -- cmd+a
	key code 6 using {command down, option down} -- cmd+opt+y; y is 16 for US, 6 for Hungarians :)
end tell
-- that would be the callback after QuickLook:
--tell application "Finder"
--	activate
--	set current view of front Finder window to v
--	close front Finder window
--end tell
-- display images using a very limited (dumb) QuickLook window:
--do shell script "qlmanage -p  " & (POSIX path of fullDir) & "/* >& /dev/null"
-- GrowlCheck:
on growlInstalled()
	try
		do shell script "ls /Library/PreferencePanes/Growl.prefPane/"
		return true
	on error
		return false
	end try
end growlInstalled
-- Growl notifier:
on notifyWithGrowl(myApp, myText)
	set myIconApp to "Preview"
	set notificationID to myApp & ".default"
	if growlInstalled() then
		tell application "GrowlHelperApp"
			-- list of notification types
			set the ANL to {notificationID}
			-- list of enabled notifications
			set the DNL to {notificationID}
			-- register script
			register as application myApp all notifications ANL default notifications DNL icon of application myIconApp
			-- send notification
			notify with name notificationID title myApp description myText application name myApp
		end tell
	else
		-- skip alert if no Growl installed
		--display alert "Growl is not installed"
	end if
end notifyWithGrowl
]]>

4 thoughts on “Meteo script update

  1. _flex

    eFi, azt tudod hogyan kell AppleScript-ből JSTalk-os szkriptet +hívni?
    Lehetne csinálni 1 Dropletet, ami 1 képből megcsinálja a CurvedDropShadow-os képet.
    Te hogyan csinálod? mindig kézzel? Kép be Acorn-ba, majd kézzel JSTalk/Run? és Save As?

    Reply
  2. Freddy

    Szivesen csinalnek en magam is ilyeneket meg hasonlokat, de ehhez jo lenne egy alapos help. Van otlet?

    Reply
  3. eFi Post author

    _flex: én úgy csinálom, hogy Acornra rádob kép, majd elindítom az app-nak forgatott JSTalk scriptet, ami legyártja a képet. Nem a legszebb, de erre volt idő/türelem.
    A droplet vagy egy service az adott image-hez még szebb lenne – lehet, hogy neki is állok.
    Sajna Gus kevés doksit ad a JSTalkhoz.
    Freddy: AppleScript examples google, vagy AppleScript – The definitive guide paperbook.

    Reply
  4. Pingback: Yet another meteo script update « eFi.blog

Leave a Reply

Your email address will not be published. Required fields are marked *