<?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>&#62;dade &#187; ruby</title>
	<atom:link href="http://www.creamdesign.it/blog/archives/category/coding/ruby/feed" rel="self" type="application/rss+xml" />
	<link>http://www.creamdesign.it/blog</link>
	<description>plans that either come to naught, or half a page of scribbled lines</description>
	<lastBuildDate>Sat, 30 Oct 2010 14:27:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Lyricwiki.org API ban workaround</title>
		<link>http://www.creamdesign.it/blog/archives/108</link>
		<comments>http://www.creamdesign.it/blog/archives/108#comments</comments>
		<pubDate>Tue, 04 Aug 2009 08:33:09 +0000</pubDate>
		<dc:creator>dade</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[iPod & iPhone]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.creamdesign.it/blog/?p=108</guid>
		<description><![CDATA[Lyrics can be fetched again from lyricwiki.org in spite of the ban of the API from major music producers. One more little victory of digital freedom]]></description>
			<content:encoded><![CDATA[<p>Lyrics can be fetched again from lyricwiki.org in spite of the ban of the API from major music producers. One more little victory of digital freedom!</p>
<p>Yesterday night I was so frustrated by my widget not working anymore that I had to find a solution. The workaround was very simple indeed: the lyricwiki.org lyrics pages have the author and the song title embedded in the URL of the page, with little or no difference from the previous REST method to access lyrics.</p>
<p>Check out the posts of the dashboard widget and the massive lyrics script for updates: I&#8217;m going to fix them soon so that they work again!</p>
<ul>
<li><a href="http://www.creamdesign.it/blog/archives/48">simple lyrics widget: dadelyrics</a></li>
<li><a href="http://www.creamdesign.it/blog/archives/37">massive iTunes lyrics download script</a></li>
</ul>
<p><span id="more-108"></span>The  only difference is that the output is now a full-fledged html page, and not the plain text of the lyrics. To strip the output some more ruby processing is required, basically a call to parse the DOM and extract the node with lyrics, plus some cleanup of the xhtml markup after the node is retrieved. But in more simple words <strong>it works again! </strong></p>
<p>Ruby has proven itself again simple, elegant and powerful: look at this one-liner:<br />
<code><br />
doc.root_node.find_first_recursive {|node| node.name == "div" and node.attributes["class"] == "lyricbox"}</code></p>
<p>It parses the html output and extracts the node with lyrics thanks to REXML, which comes bundles with ruby. Bliss!</p>
<p>Seems that the ban from music producer has little or no effect, unless they will decide to put down the site completely, but that is not likely to happen, fortunately.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.creamdesign.it/blog/archives/108/feed</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Too good to be true</title>
		<link>http://www.creamdesign.it/blog/archives/72</link>
		<comments>http://www.creamdesign.it/blog/archives/72#comments</comments>
		<pubDate>Mon, 03 Aug 2009 13:20:21 +0000</pubDate>
		<dc:creator>dade</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[iPod & iPhone]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.creamdesign.it/blog/?p=72</guid>
		<description><![CDATA[LyricWiki.org API has been shut due restrictions from major music publishers. The posts which offered the dadelyrics widget and the massive lyrics update scripts won't have files to download anymore. ]]></description>
			<content:encoded><![CDATA[<p>Just as I was planning an update for my lyrics and scripts based on lyricwiki.org I ran across this annoying message inside my widget dadelyrics:</p>
<div id="attachment_73" class="wp-caption aligncenter" style="width: 456px"><a href="http://www.creamdesign.it/blog/wp-content/uploads/2009/08/Picture-1.png"><img class="size-full wp-image-73" title="Banned service" src="http://www.creamdesign.it/blog/wp-content/uploads/2009/08/Picture-1.png" alt="lyrics API banned!" width="446" height="256" /></a><p class="wp-caption-text">lyricwiki.org REST service has been banned!</p></div>
<p>I guess this will be the end of the project, unless I can find a similar service. I think however it will always be playing the rat and the mouse between the majors and who offers lyrics APIs.</p>
<p>Fortunately I could download all the lyrics in my iTunes library prior to this with my massive lyrics ruby script!</p>
<p>Well, it&#8217;s time to update the two posts removing the download of the programs that used the lyricwiki interface. Shame!</p>
<ul>
<li><a href="http://www.creamdesign.it/blog/archives/48">simple lyrics widget: dadelyrics</a></li>
<li><a href="http://www.creamdesign.it/blog/archives/37">massive iTunes lyrics download script</a></li>
</ul>
<p>Let&#8217;s hope that new and brilliant services like the ones from lyricwiki won&#8217;t be censored anymore.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.creamdesign.it/blog/archives/72/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Massive iTunes lyrics update</title>
		<link>http://www.creamdesign.it/blog/archives/37</link>
		<comments>http://www.creamdesign.it/blog/archives/37#comments</comments>
		<pubDate>Fri, 17 Jul 2009 21:22:18 +0000</pubDate>
		<dc:creator>dade</dc:creator>
				<category><![CDATA[iPod & iPhone]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[iTunes]]></category>
		<category><![CDATA[Lyrics]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://www.creamdesign.it/blog/?p=37</guid>
		<description><![CDATA[A Ruby script to download and add the lyrics for multiple songs in iTunes. No more blank lyrics on the iPod!]]></description>
			<content:encoded><![CDATA[<div style="display: block; padding: 10px; border: 2px solid #afa; background-color: #efe; margin-bottom: 1.2em;"><strong>UPDATE</strong>: since there were some problems with appscript and the whole ruby script method wasn&#8217;t that user-friendly, I&#8217;ve made an osx app to do the work. You can find it <a href="http://www.creamdesign.it/blog/archives/280" target="_self">here</a></div>
<p>I recently found a fantastic website to get lyrics for songs: <a title="lyricwiki" href="http://lyricwiki.org/Main_Page">lyricwiki.org<br />
</a>No ads and plenty of lyrics available for free, even for italian artists or pretty unknown songs.<span style="text-decoration: line-through;"> I was also pleased to discover that the website offers an handy REST interface to fetch (or upload) lyrics from scripts </span> update: I found a workaround to retrieve the lyrics without the banned lyricwiki API: <a href="http://www.creamdesign.it/blog/archives/108">read more here</a>.</p>
<p>So I coded a script to fetch and update the lyrics for the selected songs in iTunes automatically. It cycles through all the selected songs and if it finds the lyrics on lyricwiki it puts them into the corresponding field of the iTunes track. I tested the script on my whole library and &#8211; after 5 minutes &#8211; most of my tracks had lyrics attached.</p>
<p><img class="aligncenter size-full wp-image-36" src="http://www.creamdesign.it/blog/wp-content/uploads/2009/07/Picture-3-copy.png" alt="massivelyrics" width="578" height="386" /> <span id="more-37"></span> For that massive update task I found applescript to be a very quirky programming language. The folks at <a title="appscript" href="http://appscript.sourceforge.net/index.html">appscript</a> realized this long before me and coded a ruby binding for the applescript object model.<br />
Ruby was far more intuitive, and definitely replaced the need for applescript.</p>
<p>If you want to run the script you should also have the appscript and the curb (for curl support) gems installed: type this into a terminal to be up and running:</p>
<p><code>sudo gem install rb-appscript<br />
sudo gem install curb</code></p>
<p>The script is available for download both as a plain .rb file and as a self-contained application (thanks to <a href="http://www.sveinbjorn.org/platypus">platypus</a>)</p>
<p><strong>Usage:</strong></p>
<ol>
<li>install the appscript and curb gems (one time)</li>
<li>open iTunes and select the songs you want to fetch lyrics for.<br />
hint: command-a selects all your library</li>
<li>execute the script:<br />
either launch the application<br />
or run <code>ruby MassiveLyrics.rb</code> inside a terminal</li>
</ol>
<p>If you feel that your iPod hasn&#8217;t been the same as before after having all your favorite songs with lyrics, contribute the lyrics they don&#8217;t have on <a title="lyricwiki" href="http://lyricwiki.org/Main_Page">lyricwiki.org</a>!</p>
<p><a href="http://www.creamdesign.it/blog/wp-content/uploads/2009/07/MassiveLyrics.rb">MassiveLyrics ruby script (OS X &#8211; win &#8211; linux)</a></p>
<div style="display: block; padding: 10px; border: 2px solid #afa; background-color: #efe; margin-bottom: 1.2em;"><strong>UPDATE</strong>: since there were some problems with appscript and the whole ruby script method wasn&#8217;t that user-friendly, I&#8217;ve made an osx app to do the work. You can find it <a href="http://www.creamdesign.it/blog/archives/280" target="_self">here</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.creamdesign.it/blog/archives/37/feed</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
	</channel>
</rss>

