Yet another meteo script update

korábbi időjárásscript aktualizált verziója, régi és friss Growl-ra, fixált curl hívással:

	by Gabor PENOFF (//
	release 20111215_161716
	- before run you need to Enable Access for Assistive Devices in SysPrefs/Universal Access
	- install Growl to get non-modal notification dialogs
	- 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 ""
set myURLs to {¬
	"|jpg", ¬
	"|jpg", ¬
	"|jpg", ¬
	"|gif", ¬
	"|jpg", ¬
	"|jpg", ¬
	"|jpg", ¬
	"|jpg", ¬
	"|jpg", ¬
	"|jpg", ¬
	"|jpg", ¬
	"|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 " & (POSIX path of fullDir) & "..."
tell me to notifyWithGrowl(myScriptID, myNotification)
	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"
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
	--set myFile to ((path to temporary items) as string) & "url_access_file.xml"
	--«event aevtdwnl» thisURL given «class fdst»:file myFile, «class rplc»:«constant erplyes »
	do shell script "curl -L \"" & thisURL & "\" -o \"" & (POSIX path of myFile) & "\""
	set i to i + 1
end repeat
--end tell
-- display images using full-featured QuickLook window:
tell application "Finder"
	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 49 using {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()
		do shell script "ls /Library/PreferencePanes/Growl.prefPane/"
		return true
	on error
			do shell script "ls -d /Applications/"
			return true
		on error
			return false
		end try
	end try
end growlInstalled
-- Growl notifier:
on notifyWithGrowl(myApp, myText)
	set myIconApp to "SYSTEM:Users:fns:Documents:Scripts:meteo"
	set notificationID to myApp & ".default"
	if growlInstalled() then
		tell application "Growl"
			-- 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
		-- skip alert if no Growl installed
		--display alert "Growl is not installed"
	end if
end notifyWithGrowl
Lustáknak zip-be csomagolt, script app-ba fordított, szuperszexi trn weather ikonos verzió leech erre.]]>

Leave a Reply

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