<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:at="http://www.sixapart.com/ns/at"
    xmlns:icbm="http://postneo.com/icbm"
    xmlns:rvw="http://purl.org/NET/RVW/0.2/"
    xmlns:media="http://search.yahoo.com/mrss">
    <channel>
        <title>bricas’ blog</title>
        <link>http://bricas.vox.com/library/posts/tags/ubuntu/page/1/</link>
        <description></description>
        <language>en</language>
        <generator>Vox</generator>
        <lastBuildDate>Fri, 25 Apr 2008 22:56:47 -0300</lastBuildDate>
        <copyright>Copyright 2008</copyright>
        <docs>http://blogs.law.harvard.edu/tech/rss</docs> 
        <category domain="http://bricas.vox.com/tags/">ubuntu</category>  
 
        <item>
            <title>Import Amarok stats into Rhythmbox</title>
            <link>http://bricas.vox.com/library/post/import-amarok-stats-into-rhythmbox.html?_c=feed-rss-full</link>   
            <author>nobody@vox.com(Brian)</author>
            <comments>http://bricas.vox.com/library/post/import-amarok-stats-into-rhythmbox.html?_c=feed-rss-full</comments>
            <guid isPermaLink="true">http://bricas.vox.com/library/post/import-amarok-stats-into-rhythmbox.html?_c=feed-rss-full</guid> 
            <pubDate>Fri, 25 Apr 2008 22:56:47 -0300</pubDate>         
            
            <description>    &lt;p&gt;I&amp;#39;ve been using Ubuntu since Dapper was released. As Hardy is the next LTS release, I decided now would be a good time to blow the whole thing away and start fresh. At the same time, I thought I could give rid of some KDE-based software I&amp;#39;ve been using and stick to a strictly Gnome environment.&lt;/p&gt;&lt;p&gt;I&amp;#39;ve been using Amarok as my media player, but, as stated above, that doesn&amp;#39;t jive with a pure Gnome setup. By default Rhythmbox is installed. I can import all of my tunes in no problem, but I&amp;#39;m missing some play stats.&lt;/p&gt;&lt;p&gt;Given my old Amarok database, which is just an SQLite database, and a Rhythmbox database, which is a simple XML file, with freshly imported tunes I was able to write a script to pull out some of my old data including: rating, import date, last play date and play count. NB: Rhythmbox ratings don&amp;#39;t understand half-star ratings, though it doesn&amp;#39;t complain.&lt;/p&gt;&lt;p&gt;Usage: import.pl rhythmdb.xml collection.db&lt;/p&gt;&lt;p&gt;use strict;&lt;br /&gt;use warnings;&lt;/p&gt;&lt;p&gt;use XML::Simple;&lt;br /&gt;use DBI;&lt;br /&gt;use URI;&lt;/p&gt;&lt;p&gt;my $xml = shift;&lt;br /&gt;my $data = XMLin( $xml, KeepRoot =&amp;gt; 1, ForceContent =&amp;gt; 1 );&lt;/p&gt;&lt;p&gt;my $dbh = DBI-&amp;gt;connect( &amp;#39;dbi:SQLite:dbname=&amp;#39; . shift, undef, undef );&lt;br /&gt;my $sth = $dbh-&amp;gt;prepare( &amp;#39;select rating, playcounter, createdate, accessdate from statistics where url = ?;&amp;#39; );&lt;/p&gt;&lt;p&gt;for my $row ( @{ $data-&amp;gt;{ rhythmdb }-&amp;gt;{ entry } } ) {&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; my $mp3 = URI-&amp;gt;new( $row-&amp;gt;{ location }-&amp;gt;{ content } );&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160; next unless $mp3-&amp;gt;scheme eq &amp;#39;file&amp;#39;;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160; $sth-&amp;gt;execute( &amp;#39;.&amp;#39; . $mp3-&amp;gt;file );&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160; my $dbrow = $sth-&amp;gt;fetchrow_hashref;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; $row-&amp;gt;{ rating }-&amp;gt;{ content } = $dbrow-&amp;gt;{ rating } / 2;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; $row-&amp;gt;{ &amp;#39;play-count&amp;#39;}-&amp;gt;{ content } =&amp;#160; ( $row-&amp;gt;{ &amp;#39;play-count&amp;#39;}-&amp;gt;{ content } || 0 ) + $dbrow-&amp;gt;{ &amp;#39;playcounter&amp;#39; };&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; $row-&amp;gt;{ &amp;#39;first-seen&amp;#39; }-&amp;gt;{ content } = $dbrow-&amp;gt;{ &amp;#39;createdate&amp;#39; };&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; $row-&amp;gt;{ &amp;#39;last-seen&amp;#39; }-&amp;gt;{ content } = $dbrow-&amp;gt;{ &amp;#39;accessdate&amp;#39; };&lt;br /&gt;}&lt;/p&gt;&lt;p&gt;XMLout( $data, KeepRoot =&amp;gt; 1, XMLDecl =&amp;gt; 1, OutputFile =&amp;gt; $xml );&lt;/p&gt;     &lt;p style=&quot;clear:both;&quot;&gt; 
    &lt;a href=&quot;http://bricas.vox.com/library/post/import-amarok-stats-into-rhythmbox.html?_c=feed-rss-full#comments&quot;&gt;Read and post comments&lt;/a&gt;   |   
    &lt;a href=&quot;http://www.vox.com/share/6a00d09e62f541be2b00e398f39e5f0005?_c=feed-rss-full&quot;&gt;Send to a friend&lt;/a&gt; 
&lt;/p&gt;
 
            </description> 
            <category domain="http://bricas.vox.com/tags/">perl</category> 
            <category domain="http://bricas.vox.com/tags/">ubuntu</category>   
        </item> 
    </channel>
</rss>

