<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Doug&#039;s AppleScripts for iTunes &#187; Snippets</title>
	<atom:link href="http://dougscripts.com/itunes/category/snippets/feed/" rel="self" type="application/rss+xml" />
	<link>http://dougscripts.com</link>
	<description>AppleScripts for iTunes</description>
	<lastBuildDate>Thu, 09 Feb 2012 15:10:46 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='dougscripts.com' port='80' path='/itunes/?rsscloud=notify' registerProcedure='' protocol='http-post' />
		<item>
		<title>Create Shortcut Keys to Select Libraries</title>
		<link>http://dougscripts.com/itunes/2011/01/create-shortcut-keys-to-select-libraries/</link>
		<comments></comments>
		<pubDate>Thu, 27 Jan 2011 15:26:40 +0000</pubDate>
		<dc:creator>dougscripts</dc:creator>
				<category><![CDATA[AppleScript Syntax]]></category>
		<category><![CDATA[Snippets]]></category>
		<category><![CDATA[Tips and Info]]></category>

		<guid isPermaLink="false">http://dougscripts.com/itunes/?p=1208</guid>
		<description><![CDATA[There are no shortcut keys to select the Music, Podcast, TV Shows, and other libraries. But you can use AppleScript to create some. Here&#8217;s how:
What you&#8217;ll end up doing is creating a small script for each of the libraries you&#8217;ll want to access. Here&#8217;s the script for the Music library:

tell application "iTunes"
	try
		set view of front [...]]]></description>
			<content:encoded><![CDATA[<p>There are no shortcut keys to select the Music, Podcast, TV Shows, and other libraries. But you can use AppleScript to create some. Here&#8217;s how:</p>
<p><span id="more-1208"></span>What you&#8217;ll end up doing is creating a small script for each of the libraries you&#8217;ll want to access. Here&#8217;s the script for the Music library:</p>
<pre style="margin-bottom:1em;">
<b>tell</b> <span style="color:blue;">application</span> "iTunes"
	<b>try</b>
		<b>set</b> <span style="color:purple;">view</span> <b>of</b> <b>front</b> <span style="color:blue;">browser</span> <span style="color:blue;">window</span> <b>to</b> (<b>get</b> <b>some</b> <span style="color:blue;">playlist</span> <b>whose</b> <span style="color:purple;">special</span> <span style="color:purple;">kind</span> <b>is</b> Music)
	<b>end</b> <b>try</b>
<b>end</b> <b>tell</b>

<a href="applescript://com.apple.scripteditor?action=new&#038;script=tell application %22iTunes%22%0D%09try%0D%09%09set view of front browser window to %28get some playlist whose special kind is Music%29%0D%09end try%0Dend tell" title="Click to open in AppleScript Editor. Works via most modern Mac browsers."><img src="http://dougscripts.com/itunes/pix/clickscriptsmall.jpg" alt="" /></a>
</pre>
<p>Some might suggest using this syntax instead:</p>
<pre style="margin-bottom:1em;">
		<b>set</b> <span style="color:purple;">view</span> <b>of</b> <b>front</b> <span style="color:blue;">browser</span> <span style="color:blue;">window</span> <b>to</b> <span style="color:blue;">playlist</span> "Music"
</pre>
<p>That&#8217;s fine, too. I just prefer using <strong>special kind</strong> to avoid any ambiguity. Save that as &#8220;select_music.scpt&#8221; in your ~/Library/iTunes/Scripts/ folder so it will appear in the iTunes Script menu. Now, assign the script a &#8220;Command-1&#8243; <a href="http://dougscripts.com/itunes/itinfo/shortcutkeys.php">keyboard shortcut</a>. </p>
<p>I think you can see where this is going. You&#8217;ll create a &#8220;select-movies.scpt&#8221; and assign it &#8220;Command-2&#8243;, and so on. The <strong>special kind</strong> parameters for other libraries are <strong>Books</strong>, <strong>iTunes U</strong>, <strong>Movies</strong>, <strong>Podcasts</strong>, and <strong>TV Shows</strong>. For other libraries you may have to use the name parameter.</p>
<hr/><small><a href="http://dougscripts.com/itunes/dougsupdated.rss" title="Take me to your reader">30 Most Recent RSS Feed</a> | <a href="http://dougscripts.com/itunes/scripts/scriptcount.php?sortBy=Name&op=y">Script Stats Page</a> by <a href="http://dougscripts.com/itunes/scripts/scriptcount.php?sortBy=Name&op=y">Name</a>, <a href="http://dougscripts.com/itunes/scripts/scriptcount.php?sortBy=Most Recent&op=y">Most Recent</a>, <a href="http://dougscripts.com/itunes/scripts/scriptcount.php?sortBy=Download Count&op=y">Download Count</a></small>]]></content:encoded>
			</item>
		<item>
		<title>Updated Spareparts Section</title>
		<link>http://dougscripts.com/itunes/2010/03/updated-spareparts-section/</link>
		<comments></comments>
		<pubDate>Sat, 13 Mar 2010 18:20:31 +0000</pubDate>
		<dc:creator>dougscripts</dc:creator>
				<category><![CDATA[Managing Artwork]]></category>
		<category><![CDATA[Snippets]]></category>

		<guid isPermaLink="false">http://dougscripts.com/itunes/?p=938</guid>
		<description><![CDATA[A Correspondent via the AppleScript Users email list detected a problem with a script snippet of mine regarding grabbing the artwork data from an iTunes track with iTunes 9 and Snow Leopard. That very day I also had updated Export Artwork with a fix for a similar issue. At any rate, the snippet resides in [...]]]></description>
			<content:encoded><![CDATA[<p>A Correspondent via the AppleScript Users <a href="http://lists.apple.com/archives/AppleScript-Users/2010/Mar/msg00133.html">email list</a> detected a problem with a script snippet of mine regarding grabbing the artwork data from an iTunes track with iTunes 9 and Snow Leopard. That very day I also had updated <a href="http://dougscripts.com/itunes/scripts/ss.php?sp=exportartwork" title="Save the display artwork of the selected track to a file">Export Artwork</a> with a fix for a similar issue. At any rate, the snippet resides in the <a href="http://dougscripts.com/itunes/scripts/spareparts.php">Spare Parts</a> section and, to be more exact, <a href="http://dougscripts.com/itunes/scripts/spareparts.php#1070">the updated snippet with the fix is here</a>.</p>
<hr/><small><a href="http://dougscripts.com/itunes/dougsupdated.rss" title="Take me to your reader">30 Most Recent RSS Feed</a> | <a href="http://dougscripts.com/itunes/scripts/scriptcount.php?sortBy=Name&op=y">Script Stats Page</a> by <a href="http://dougscripts.com/itunes/scripts/scriptcount.php?sortBy=Name&op=y">Name</a>, <a href="http://dougscripts.com/itunes/scripts/scriptcount.php?sortBy=Most Recent&op=y">Most Recent</a>, <a href="http://dougscripts.com/itunes/scripts/scriptcount.php?sortBy=Download Count&op=y">Download Count</a></small>]]></content:encoded>
			</item>
		<item>
		<title>Re-Posting Stream Startup Script</title>
		<link>http://dougscripts.com/itunes/2009/08/re-posting-stream-startup-script/</link>
		<comments></comments>
		<pubDate>Tue, 11 Aug 2009 14:44:05 +0000</pubDate>
		<dc:creator>dougscripts</dc:creator>
				<category><![CDATA[AppleScript]]></category>
		<category><![CDATA[Managing Tracks]]></category>
		<category><![CDATA[Missing Menu Commands]]></category>
		<category><![CDATA[Snippets]]></category>
		<category><![CDATA[iTunes]]></category>

		<guid isPermaLink="false">http://dougscripts.com/itunes/wpfol/?p=22</guid>
		<description><![CDATA[A couple few days ago I posted a script here that would ping the Radio Paradise stream until its server accepted the connection, suppressing the error dialog that would appear when a connection was denied. Well, that was the wrong version of the script. Here is the correct version, and the one I fire up [...]]]></description>
			<content:encoded><![CDATA[<p>A couple few days ago I posted a script here that would ping the Radio Paradise stream until its server accepted the connection, suppressing the error dialog that would appear when a connection was denied. Well, that was the wrong version of the script. Here is the correct version, and the one I fire up every morning. You must select a radio stream track <em>first</em>, <em>then</em> run the script:</p>
<pre style="margin-bottom:1em;">
<b>tell</b> application "iTunes"
	<b>if</b> selection <b>is</b> {} <b>then</b> <b>return</b>
	<b>set</b> <span style="color:blue;">strm</span> <b>to</b> (item 1 <b>of</b> selection)
	<b>if</b> (<b>get</b> class <b>of</b> <span style="color:blue;">strm</span>) <b>is</b> <b>not</b> URL track <b>then</b> <b>return</b>
	<b>repeat</b>
		<b>try</b>
			play <span style="color:blue;">strm</span>
			<b>exit</b> <b>repeat</b>
		<b>on</b> <b>error</b> <span style="color:blue;">m</span> number <span style="color:blue;">n</span>
			delay 15
		<b>end</b> <b>try</b>
	<b>end</b> <b>repeat</b>
<b>end</b> <b>tell</b>

<a href="applescript://com.apple.scripteditor?action=new&#038;script=tell application %22iTunes%22%0D%09if selection is {} then return%0D%09set strm to %28item 1 of selection%29%0D%09if %28get class of strm%29 is not URL track then return%0D%09repeat%0D%09%09try%0D%09%09%09play strm%0D%09%09%09exit repeat%0D%09%09on error m number n%0D%09%09%09delay 15%0D%09%09end try%0D%09end repeat%0Dend tell" title="Open in Script Editor. Works via most modern Mac browsers."><img src="pix/clickscriptsmall.jpg" alt="" /></a>
</pre>
<p>The earlier script used the <strong>open location</strong> command, errors from which could not be defeated with the <strong>try</strong> block.</p>
<hr/><small><a href="http://dougscripts.com/itunes/dougsupdated.rss" title="Take me to your reader">30 Most Recent RSS Feed</a> | <a href="http://dougscripts.com/itunes/scripts/scriptcount.php?sortBy=Name&op=y">Script Stats Page</a> by <a href="http://dougscripts.com/itunes/scripts/scriptcount.php?sortBy=Name&op=y">Name</a>, <a href="http://dougscripts.com/itunes/scripts/scriptcount.php?sortBy=Most Recent&op=y">Most Recent</a>, <a href="http://dougscripts.com/itunes/scripts/scriptcount.php?sortBy=Download Count&op=y">Download Count</a></small>]]></content:encoded>
			</item>
		<item>
		<title>Missing Menu and Spare Parts Sections</title>
		<link>http://dougscripts.com/itunes/2009/04/missing-menu-and-spare-parts-sections/</link>
		<comments></comments>
		<pubDate>Thu, 09 Apr 2009 16:04:53 +0000</pubDate>
		<dc:creator>dougscripts</dc:creator>
				<category><![CDATA[AppleScript]]></category>
		<category><![CDATA[Missing Menu Commands]]></category>
		<category><![CDATA[Snippets]]></category>
		<category><![CDATA[iTunes]]></category>

		<guid isPermaLink="false">http://dougscripts.com/itunes/wpfol/?p=75</guid>
		<description><![CDATA[Some visitors may have noticed a few changes to the site&#8217;s formatting. The main challenge with a site like this is trying to make it easy to find something, but too many links were making every page more cluttered than it needed to be. So I got rid a lot of the links that cluttered [...]]]></description>
			<content:encoded><![CDATA[<p>Some visitors may have noticed a few changes to the site&#8217;s formatting. The main challenge with a site like this is trying to make it easy to find something, but too many links were making every page more cluttered than it needed to be. So I got rid a lot of the links that cluttered the left column; in fact, I got rid of the left column altogether. Most navigation can be done via the menu-like links in the header of each page.<br/><br/>I have tidied up the <a href="http://dougscripts.com/itunes/scripts/missingmenu.php">Missing Menu Commands page</a> and added a <a href="http://dougscripts.com/itunes/scripts/spareparts.php">Spare Parts page</a> that lists a few helpful iTunes AppleScript routines and handlers for script-makers. I&#8217;ll continue to add to this page.<br/><br/>Finally, I dislike the way Amazon MP3s sometimes download with &#8221; (Album Version)&#8221; at the end of their titles. Here&#8217;s a simple script, <a href="http://dougscripts.com/itunes/scripts/missingmenu.php#1064">Remove (Album Version)</a>, that will delete that text from the selected tracks.</p>
<hr/><small><a href="http://dougscripts.com/itunes/dougsupdated.rss" title="Take me to your reader">30 Most Recent RSS Feed</a> | <a href="http://dougscripts.com/itunes/scripts/scriptcount.php?sortBy=Name&op=y">Script Stats Page</a> by <a href="http://dougscripts.com/itunes/scripts/scriptcount.php?sortBy=Name&op=y">Name</a>, <a href="http://dougscripts.com/itunes/scripts/scriptcount.php?sortBy=Most Recent&op=y">Most Recent</a>, <a href="http://dougscripts.com/itunes/scripts/scriptcount.php?sortBy=Download Count&op=y">Download Count</a></small>]]></content:encoded>
			</item>
	</channel>
</rss>

