<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.0.3" -->
<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/"
	>

<channel>
	<title>cyberrazor</title>
	<link>http://cyberrazor.com</link>
	<description>the cutting edge of technology</description>
	<pubDate>Fri, 07 Jul 2006 01:10:55 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.3</generator>
	<language>en</language>
			<item>
		<title>Scripting iTunes with Perl - Part 2</title>
		<link>http://cyberrazor.com/2006/07/06/scripting-itunes-with-perl-part-2/</link>
		<comments>http://cyberrazor.com/2006/07/06/scripting-itunes-with-perl-part-2/#comments</comments>
		<pubDate>Fri, 07 Jul 2006 00:17:25 +0000</pubDate>
		<dc:creator>pat</dc:creator>
		
	<dc:subject>Perl</dc:subject><dc:subject>artwork</dc:subject><dc:subject>code</dc:subject><dc:subject>itunes</dc:subject><dc:subject>perl</dc:subject><dc:subject>script</dc:subject><dc:subject>sdk</dc:subject><dc:subject>win32 ole</dc:subject>
		<guid isPermaLink="false">http://cyberrazor.com/2006/07/06/scripting-itunes-with-perl-part-2/</guid>
		<description><![CDATA[In my previous article, Scripting iTunes with Perl - Part 1, I demonstrated how the iTunes COM object can be used with Perl.  In this article I will be showing you how to catch events from iTunes.  The example script below catches the &#8216;OnPlayerPlayEvent&#8217; and then displays the cover art from the current [...]]]></description>
			<content:encoded><![CDATA[<p>In my previous article, <a href="/2006/07/06/scripting-itunes-with-perl-part-1/">Scripting iTunes with Perl - Part 1</a>, I demonstrated how the iTunes COM object can be used with Perl.  In this article I will be showing you how to catch events from iTunes.  The example script below catches the &#8216;OnPlayerPlayEvent&#8217; and then displays the cover art from the current track in a Tk window.</p>
<p><a id="more-7"></a></p>
<p>As a side note, I have written a script which does a little bit more.  After saving the image it is manipulated with GD and layered between two special PNG images (like &#8220;layers&#8221; in Photoshop).  Then the final image is uploaded to my personal blog.  I have omitted most of that code and leave this as an exercise for the reader.</p>
<div class="codesnip-container" >
<div class="codesnip">
<ol>
<li class="li1">
<div class="de1"><span class="kw2">use</span> strict;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">use</span> Win32::<span class="me2">OLE</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">use</span> Tk;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">use</span> Tk::<span class="me2">JPEG</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">my</span> <span class="re0">$iTunes_OLE</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">my</span> <span class="re0">$tkWin</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">my</span> <span class="re0">$tkPhoto</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">my</span> <span class="re0">$tmpFile</span> = <span class="st0">&#8216;C:<span class="es0">\i</span>mage.jpg&#8217;</span>; </div>
</li>
</ol>
</div>
</div>
<p>Include our necessary modules and define some global variables.</p>
<div class="codesnip-container" >
<div class="codesnip">
<ol>
<li class="li1">
<div class="de1"><span class="kw2">sub</span> cleanup <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;<a href="http://www.perldoc.com/perl5.6/pod/func/undef.html"><span class="kw3">undef</span></a> <span class="re0">$iTunes_OLE</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;Win32::<span class="me2">OLE</span>-&gt;<span class="me1">FreeUnusedLibraries</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;<a href="http://www.perldoc.com/perl5.6/pod/func/exit.html"><span class="kw3">exit</span></a><span class="br0">&#40;</span><span class="nu0">0</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">use</span> sigtrap <span class="st0">&#8216;handler&#8217;</span> =&gt; \&amp;cleanup, <span class="st0">&#8216;INT&#8217;</span>; </div>
</li>
</ol>
</div>
</div>
<p>The cleanup sub is called when an INT signal is trapped and will make sure our script exits gracefully.</p>
<div class="codesnip-container" >
<div class="codesnip">
<ol>
<li class="li1">
<div class="de1"><span class="kw2">sub</span> iTunesEvent <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;<span class="kw1">my</span> <span class="br0">&#40;</span><span class="re0">$iTunes</span>, <span class="re0">$event</span>, <span class="re0">@args</span><span class="br0">&#41;</span> = <span class="re0">@_</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;<span class="kw1">my</span> <span class="re0">$currTrack</span> = <span class="re0">$iTunes</span>-&gt;<span class="me1">CurrentTrack</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;<span class="kw1">if</span> <span class="br0">&#40;</span> <a href="http://www.perldoc.com/perl5.6/pod/func/defined.html"><span class="kw3">defined</span></a><span class="br0">&#40;</span><span class="re0">$currTrack</span><span class="br0">&#41;</span> &amp;&amp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="br0">&#40;</span><span class="re0">$event</span> eq <span class="st0">&#8216;OnPlayerPlayEvent&#8217;</span><span class="br0">&#41;</span> &amp;&amp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="br0">&#40;</span><span class="re0">$currTrack</span>-&gt;<span class="me1">Artwork</span>-&gt;<span class="me1">Count</span> &gt; <span class="nu0">0</span><span class="br0">&#41;</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="kw1">my</span> <span class="re0">$coverArt</span> = <span class="re0">$currTrack</span>-&gt;<span class="me1">Artwork</span>-&gt;<span class="me1">Item</span><span class="br0">&#40;</span><span class="nu0">1</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="re0">$coverArt</span>-&gt;<span class="me1">SaveArtworkToFile</span><span class="br0">&#40;</span><span class="re0">$tmpFile</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="kw1">my</span> <span class="re0">$tmpPhoto</span> = <span class="re0">$tkWin</span>-&gt;<span class="me1">Photo</span><span class="br0">&#40;</span><span class="st0">&#8216;img&#8217;</span>, -file =&gt; <span class="re0">$tmpFile</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="re0">$tkPhoto</span>-&gt;<span class="me1">destroy</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="re0">$tkPhoto</span> = <span class="re0">$tkWin</span>-&gt;<span class="me1">Label</span><span class="br0">&#40;</span>-image =&gt; <span class="re0">$tmpPhoto</span><span class="br0">&#41;</span>-&gt;<span class="me1">pack</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;<span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span> </div>
</li>
</ol>
</div>
</div>
<p>This subroutine is the event handler for our iTunes COM object.  It is called when an event is caught from iTunes.  Line #5 checks if the CurrentTrack is defined and that the CurrentTrack has at least one image.  It also checks to see if the event caught is the &#8216;OnPlayerPlayEvent&#8217;.  If these conditions are true then it saves the artwork and displays it in a Tk window.</p>
<div class="codesnip-container" >
<div class="codesnip">
<ol>
<li class="li1">
<div class="de1"><span class="re0">$tkWin</span> = MainWindow-&gt;<span class="me1">new</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$tkWin</span>-&gt;<span class="me1">title</span><span class="br0">&#40;</span><span class="st0">&#8220;iTunes Artwork&#8221;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$tkPhoto</span> = <span class="re0">$tkWin</span>-&gt;<span class="me1">Label</span><span class="br0">&#40;</span>-text =&gt; <span class="st0">&#8220;Play some music!&#8221;</span><span class="br0">&#41;</span>-&gt;<span class="me1">pack</span>; </div>
</li>
</ol>
</div>
</div>
<p>This creates our Tk window which let&#8217;s us view the album artwork after it has been saved.</p>
<div class="codesnip-container" >
<div class="codesnip">
<ol>
<li class="li1">
<div class="de1">Win32::<span class="me2">OLE</span>-&gt;<span class="me1">Initialize</span><span class="br0">&#40;</span>Win32::<span class="me2">OLE</span>::<span class="me2">COINIT_OLEINITIALIZE</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$iTunes_OLE</span> = Win32::<span class="me2">OLE</span>-&gt;<span class="me1">new</span><span class="br0">&#40;</span><span class="st0">&#8220;iTunes.Application&#8221;</span><span class="br0">&#41;</span> <span class="kw1">or</span> <a href="http://www.perldoc.com/perl5.6/pod/func/die.html"><span class="kw3">die</span></a> $!;</div>
</li>
<li class="li1">
<div class="de1">Win32::<span class="me2">OLE</span>-&gt;<span class="me1">WithEvents</span><span class="br0">&#40;</span><span class="re0">$iTunes_OLE</span>, \&amp;iTunesEvent<span class="br0">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
<p>This initializes OLE and turns on event handling.  Event handling is not considered stable in the most recent libwin32 release.  You can read more about it&#8217;s quirks <a href="http://search.cpan.org/~jdb/libwin32-0.26/OLE/lib/Win32/OLE.pm#Events">here</a>.</p>
<div class="codesnip-container" >
<div class="codesnip">
<ol>
<li class="li1">
<div class="de1"><span class="re0">$tkWin</span>-&gt;<span class="me1">waitVariable</span><span class="br0">&#40;</span>\<span class="re0">$iTunes_OLE</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">MainLoop;</div>
</li>
<li class="li1">
<div class="de1">Win32::<span class="me2">OLE</span>-&gt;<span class="me1">MessageLoop</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">cleanup; </div>
</li>
</ol>
</div>
</div>
<p>This code attempts to keep the Tk and OLE loops in synch.  First, Tk is told to include a non-blocking wait in it&#8217;s main loop which checks the iTunes_OLE variable for a change.  Then, the loops are started in sequence.  Finally, the cleanup handler is called in the case that an INT signal is not caught before both loops exit.</p>
<p>It should be apparent that there are many neat things you can do with the iTune COM interface, and as Apple continues to enhance the interface even more possibilities will exist!</p>
<p>Download: <a id="p9" href="http://cyberrazor.com/wp-content/uploads/2006/07/itunes_demo_part_2.txt" title="itunes_demo_part_2.pl">itunes_demo_part_2.pl</a>
</p>
<a href="http://cyberrazor.com/index.php?tag=artwork" rel="tag">artwork</a>, <a href="http://cyberrazor.com/index.php?tag=code" rel="tag">code</a>, <a href="http://cyberrazor.com/index.php?tag=itunes" rel="tag">itunes</a>, <a href="http://cyberrazor.com/index.php?tag=perl" rel="tag">perl</a>, <a href="http://cyberrazor.com/index.php?tag=script" rel="tag">script</a>, <a href="http://cyberrazor.com/index.php?tag=sdk" rel="tag">sdk</a>, <a href="http://cyberrazor.com/index.php?tag=win32_ole" rel="tag">win32 ole</a>]]></content:encoded>
			<wfw:commentRSS>http://cyberrazor.com/2006/07/06/scripting-itunes-with-perl-part-2/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Harsh Environments &#038; Dirty Computers</title>
		<link>http://cyberrazor.com/2006/07/06/harsh-environments-dirty-computers/</link>
		<comments>http://cyberrazor.com/2006/07/06/harsh-environments-dirty-computers/#comments</comments>
		<pubDate>Thu, 06 Jul 2006 18:39:54 +0000</pubDate>
		<dc:creator>pat</dc:creator>
		
	<dc:subject>Maintenance</dc:subject><dc:subject>air compressor</dc:subject><dc:subject>apple power macintosh</dc:subject><dc:subject>clean</dc:subject><dc:subject>compressed air</dc:subject><dc:subject>crud</dc:subject><dc:subject>environment</dc:subject><dc:subject>gunk</dc:subject><dc:subject>power supply</dc:subject>
		<guid isPermaLink="false">http://cyberrazor.com/2006/07/06/harsh-environments-dirty-computers/</guid>
		<description><![CDATA[Computers can accumulate a large amount of dust and gunk in harsh environments.  The pictures below are of an Apple Power Macintosh 8500.  This computer was bought new in 1996.  It was my primary computer in high school.  When I moved out of my parent&#8217;s house I set it up for [...]]]></description>
			<content:encoded><![CDATA[<p>Computers can accumulate a large amount of dust and gunk in harsh environments.  The pictures below are of an Apple Power Macintosh 8500.  This computer was bought new in 1996.  It was my primary computer in high school.  When I moved out of my parent&#8217;s house I set it up for them to use.  It spent a few years in a very dirty building; a building where dirty ethylene glycol is recycled into full strength automotive antifreeze.  I suspect that most of the gunk we found in the case is from being in that environment.</p>
<p>Believe it or not this computer was actually running fine in this condition!</p>
<p><a id="more-8"></a></p>
<p><a href="http://static.flickr.com/78/183308721_14cb24a685.jpg" rel="lightbox[post]" class="tt-flickr"><img src="http://static.flickr.com/78/183308721_14cb24a685_m.jpg" alt="" width="240" height="180" border="0" /></a> </p>
<p><a href="http://static.flickr.com/59/183308740_e209720837.jpg" rel="lightbox[post]" class="tt-flickr"><img src="http://static.flickr.com/59/183308740_e209720837_m.jpg" alt="" width="240" height="180" border="0" /></a> </p>
<p>After opening the case I spent about an hour blowing the crud off all of the components.  One can of compressed air didn&#8217;t cut it.  I had to use an air compressor on some of the less-sensitive components like the power supply and case.</p>
<p><a href="http://static.flickr.com/77/183308760_ee42b28277.jpg" rel="lightbox[post]" class="tt-flickr"><img src="http://static.flickr.com/77/183308760_ee42b28277_m.jpg" alt="" width="240" height="180" border="0" /></a> </p>
<p><a href="http://static.flickr.com/75/183308788_efc89f44b5.jpg" rel="lightbox[post]" class="tt-flickr"><img src="http://static.flickr.com/75/183308788_efc89f44b5_m.jpg" alt="" width="240" height="180" border="0" /></a> </p>
<p><a href="http://static.flickr.com/55/183308815_abf3264d3c.jpg" rel="lightbox[post]" class="tt-flickr"><img src="http://static.flickr.com/55/183308815_abf3264d3c_m.jpg" alt="" width="240" height="180" border="0" /></a> </p>
<p><a href="http://static.flickr.com/68/183308856_e288afeb0a.jpg" rel="lightbox[post]" class="tt-flickr"><img src="http://static.flickr.com/68/183308856_e288afeb0a_m.jpg" alt="" width="240" height="180" border="0" /></a> </p>
<p>Yuck.</p>
<p>The computer is now clean!  Sorry, I don&#8217;t have the requisite &#8220;after&#8221; pictures&#8230;
</p>
<a href="http://cyberrazor.com/index.php?tag=air_compressor" rel="tag">air compressor</a>, <a href="http://cyberrazor.com/index.php?tag=apple_power_macintosh" rel="tag">apple power macintosh</a>, <a href="http://cyberrazor.com/index.php?tag=clean" rel="tag">clean</a>, <a href="http://cyberrazor.com/index.php?tag=compressed_air" rel="tag">compressed air</a>, <a href="http://cyberrazor.com/index.php?tag=crud" rel="tag">crud</a>, <a href="http://cyberrazor.com/index.php?tag=environment" rel="tag">environment</a>, <a href="http://cyberrazor.com/index.php?tag=gunk" rel="tag">gunk</a>, <a href="http://cyberrazor.com/index.php?tag=power_supply" rel="tag">power supply</a>]]></content:encoded>
			<wfw:commentRSS>http://cyberrazor.com/2006/07/06/harsh-environments-dirty-computers/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Scripting iTunes with Perl - Part 1</title>
		<link>http://cyberrazor.com/2006/07/06/scripting-itunes-with-perl-part-1/</link>
		<comments>http://cyberrazor.com/2006/07/06/scripting-itunes-with-perl-part-1/#comments</comments>
		<pubDate>Thu, 06 Jul 2006 16:07:13 +0000</pubDate>
		<dc:creator>pat</dc:creator>
		
	<dc:subject>Perl</dc:subject><dc:subject>code</dc:subject><dc:subject>id3</dc:subject><dc:subject>itunes</dc:subject><dc:subject>perl</dc:subject><dc:subject>scripts</dc:subject><dc:subject>sdk</dc:subject><dc:subject>win32 ole</dc:subject>
		<guid isPermaLink="false">http://cyberrazor.com/2006/07/06/scripting-itunes-with-perl-part-1/</guid>
		<description><![CDATA[In this article I will explain how you can write Perl scripts which use the iTunes COM interface to control iTunes.  You can download the iTunes COM SDK here.  The SDK comes with excellent documentation and several example scripts.  In this article we&#8217;ll be focusing on using the COM interface with the [...]]]></description>
			<content:encoded><![CDATA[<p>In this article I will explain how you can write Perl scripts which use the iTunes COM interface to control iTunes.  You can download the iTunes COM SDK <a href="http://developer.apple.com/sdk/itunescomsdk.html">here</a>.  The SDK comes with excellent documentation and several example scripts.  In this article we&#8217;ll be focusing on using the COM interface with the Win32::OLE Perl module.</p>
<p>The iTunes COM SDK was fist released with iTunes 4.5 and has been updated and enhanced with every major point release since.  As I write this, the current COM interface version is 1.7, included in iTunes version 6.0.2.</p>
<p>The first script we that we&#8217;ll look at randomly selects tracks from your iTunes Library until it finds a track with artwork.  When the script finds a track with artwork it will save it to a jpeg file.</p>
<p><a id="more-6"></a></p>
<div class="codesnip-container" >
<div class="codesnip">
<ol>
<li class="li1">
<div class="de1"><span class="kw2">use</span> Win32::<span class="me2">OLE</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">my</span> <span class="re0">$iTunes</span> = Win32::<span class="me2">OLE</span>-&gt;<span class="me1">new</span><span class="br0">&#40;</span><span class="st0">&#8220;iTunes.Application&#8221;</span><span class="br0">&#41;</span> <span class="kw1">or</span> <a href="http://www.perldoc.com/perl5.6/pod/func/die.html"><span class="kw3">die</span></a> $!; </div>
</li>
</ol>
</div>
</div>
<p>First, we&#8217;ll include any necessary modules.  Then we will create a new iTunes COM object and store it in the $iTunes variable.  If the COM object cannot be created the script will exit with an error message.</p>
<div class="codesnip-container" >
<div class="codesnip">
<ol>
<li class="li1">
<div class="de1"><span class="kw1">my</span> <span class="re0">$tracks</span> = <span class="re0">$iTunes</span>-&gt;<span class="me1">LibraryPlaylist</span>-&gt;<span class="me1">Tracks</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">my</span> <span class="re0">$numTracks</span> = <span class="re0">$tracks</span>-&gt;<span class="me1">Count</span>; </div>
</li>
</ol>
</div>
</div>
<p>Next, we&#8217;ll grab a reference to the entire collection of tracks in the iTunes library.  The tracks collection also provides the Count method which will tell us how many tracks are in the collection, which we will call and store the result in $numTracks.</p>
<div class="codesnip-container" >
<div class="codesnip">
<ol>
<li class="li1">
<div class="de1"><span class="kw1">my</span> <span class="re0">$savedArt</span> = <span class="nu0">0</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">while</span> <span class="br0">&#40;</span><span class="re0">$savedArt</span> == <span class="nu0">0</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">my</span> <span class="re0">$currTrack</span> = <span class="re0">$tracks</span>-&gt;<span class="me1">Item</span><span class="br0">&#40;</span><a href="http://www.perldoc.com/perl5.6/pod/func/int.html"><span class="kw3">int</span></a><span class="br0">&#40;</span><a href="http://www.perldoc.com/perl5.6/pod/func/rand.html"><span class="kw3">rand</span></a><span class="br0">&#40;</span><span class="re0">$numTracks</span>+<span class="nu0">1</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span> <span class="re0">$currTrack</span>-&gt;<span class="me1">Artwork</span>-&gt;<span class="me1">Count</span> &gt; <span class="nu0">0</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">my</span> <span class="re0">$coverArt</span> = <span class="re0">$currTrack</span>-&gt;<span class="me1">Artwork</span>-&gt;<span class="me1">Item</span><span class="br0">&#40;</span><span class="nu0">1</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">my</span> <span class="re0">$filename</span> = <span class="st0">&#8220;C:<span class="es0">\\</span>itunes_cover.jpg&#8221;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$coverArt</span>-&gt;<span class="me1">SaveArtworkToFile</span><span class="br0">&#40;</span><span class="re0">$filename</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$savedArt</span> = <span class="nu0">1</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span> </div>
</li>
</ol>
</div>
</div>
<p>This code will randomly select a track from the collection and check to see if there is artwork in the tag.  If any artwork is found it will be saved to C:\itunes_cover.jpg and the program will exit the while loop.  [<strong>Note:</strong> the SaveArtworkToFile method requires an absolute path name.]</p>
<p>It&#8217;s a simple example, but we have learned how to use some of the various methods and properties exposed by the iTunes COM object.  In the next article we&#8217;ll learn how to capture events from iTunes.  Capturing events will allow your script to respond when a track begins or ends playing.</p>
<p>Download: <a id="p10" href="http://cyberrazor.com/wp-content/uploads/2006/07/itunes_demo_part_1.txt">itunes_demo_part_1.pl</a>
</p>
<a href="http://cyberrazor.com/index.php?tag=code" rel="tag">code</a>, <a href="http://cyberrazor.com/index.php?tag=id3" rel="tag">id3</a>, <a href="http://cyberrazor.com/index.php?tag=itunes" rel="tag">itunes</a>, <a href="http://cyberrazor.com/index.php?tag=perl" rel="tag">perl</a>, <a href="http://cyberrazor.com/index.php?tag=scripts" rel="tag">scripts</a>, <a href="http://cyberrazor.com/index.php?tag=sdk" rel="tag">sdk</a>, <a href="http://cyberrazor.com/index.php?tag=win32_ole" rel="tag">win32 ole</a>]]></content:encoded>
			<wfw:commentRSS>http://cyberrazor.com/2006/07/06/scripting-itunes-with-perl-part-1/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>An Introduction</title>
		<link>http://cyberrazor.com/2006/06/29/hello-world/</link>
		<comments>http://cyberrazor.com/2006/06/29/hello-world/#comments</comments>
		<pubDate>Thu, 29 Jun 2006 12:51:52 +0000</pubDate>
		<dc:creator>pat</dc:creator>
		
	<dc:subject>Uncategorized</dc:subject><dc:subject>asterisk</dc:subject><dc:subject>blog</dc:subject><dc:subject>itunes</dc:subject><dc:subject>parse recdescent</dc:subject><dc:subject>perl module</dc:subject><dc:subject>scripting</dc:subject><dc:subject>sip phones</dc:subject><dc:subject>technology related</dc:subject>
		<guid isPermaLink="false"></guid>
		<description><![CDATA[This is the first post on the blog.  I will be discussing technology-related topics here.  In the next few weeks I&#8217;ll be writing about Asterisk and SIP phones, the amazing Parse::RecDescent Perl module, and a how-to on scripting iTunes with Perl.

asterisk, blog, itunes, parse recdescent, perl module, scripting, sip phones, technology related]]></description>
			<content:encoded><![CDATA[<p>This is the first post on the blog.  I will be discussing technology-related topics here.  In the next few weeks I&#8217;ll be writing about Asterisk and SIP phones, the amazing Parse::RecDescent Perl module, and a how-to on scripting iTunes with Perl.
</p>
<a href="http://cyberrazor.com/index.php?tag=asterisk" rel="tag">asterisk</a>, <a href="http://cyberrazor.com/index.php?tag=blog" rel="tag">blog</a>, <a href="http://cyberrazor.com/index.php?tag=itunes" rel="tag">itunes</a>, <a href="http://cyberrazor.com/index.php?tag=parse_recdescent" rel="tag">parse recdescent</a>, <a href="http://cyberrazor.com/index.php?tag=perl_module" rel="tag">perl module</a>, <a href="http://cyberrazor.com/index.php?tag=scripting" rel="tag">scripting</a>, <a href="http://cyberrazor.com/index.php?tag=sip_phones" rel="tag">sip phones</a>, <a href="http://cyberrazor.com/index.php?tag=technology_related" rel="tag">technology related</a>]]></content:encoded>
			<wfw:commentRSS>http://cyberrazor.com/2006/06/29/hello-world/feed/</wfw:commentRSS>
		</item>
	</channel>
</rss>
