Last active
December 16, 2015 05:09
-
-
Save Jacob640/5382907 to your computer and use it in GitHub Desktop.
Update Expired iTunes Podcasts fork
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(*This fork of Doug Adams's script will hide iTunes if it not running when the script is called and | |
fixes the issue wherby podcasts not set to automatically update were nonetheless updated anyway *) | |
(* | |
"Update Expired Podcasts" for iTunes | |
written by Doug Adams | |
dougadams@mac.com | |
v2.2 dec 12, 2011 | |
-- exits if iTunes isn't running when launched (perhaps handy when running via launchd or other automatic launching scheme) | |
v2.1 sep 4, 2010 | |
-- maintenance release | |
-- minor finesses | |
v2.0 aug 13, 2008 | |
-- compatible with iTunes 7.7.1 | |
v1.0 feb 15, 2007 | |
-- initial release | |
Get more free AppleScripts and info on writing your own | |
at Doug's AppleScripts for iTunes | |
http://dougscripts.com | |
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. | |
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. | |
Get a copy of the GNU General Public License by writing to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
or visit http://www.gnu.org/copyleft/gpl.html | |
*) | |
set iTunesRunning to checkItunesIsActive() | |
tell application "iTunes" | |
launch | |
end tell | |
tell application "iTunes" | |
with timeout of 300 seconds | |
set podcast_playlist to some playlist whose special kind is Podcasts | |
-- filter multiple names | |
set each_podcast to {} | |
try | |
set each_podcast to my get_discrete_list_of(get album of every track of podcast_playlist) | |
end try | |
-- update the podcasts | |
if each_podcast is not {} then | |
repeat with this_podcast in each_podcast | |
set the_podcast to (some track of podcast_playlist whose album contains this_podcast) | |
if (get class of the_podcast) is list then set the_podcast to item 1 of the_podcast | |
-- updatePodcast the_podcast | |
end repeat | |
end if | |
updateAllPodcasts | |
end timeout | |
end tell | |
if iTunesRunning is not true then | |
tell application "System Events" | |
set visible of process "iTunes" to false | |
end tell | |
end if | |
delay 10 | |
if iTunesRunning is not true then | |
tell application "iTunes" | |
quit | |
end tell | |
end if | |
to get_discrete_list_of(list1) | |
script a | |
property list1ref : list1 | |
end script | |
set list2 to {} | |
script b | |
property list2ref : list2 | |
end script | |
repeat with i from 1 to length of list1 | |
set this_item to item i of a's list1ref | |
considering case | |
if this_item is not "" and this_item is not in b's list2ref then set end of list2 to this_item | |
end considering | |
end repeat | |
return b's list2ref | |
end get_discrete_list_of | |
to checkItunesIsActive() | |
if application "iTunes" is running then | |
return true | |
end if | |
return false | |
end checkItunesIsActive | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment