<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <title>opensoul.org - Bending iTunes to my will with RubyOSA: take 1 Changes</title>
  <id>tag:opensoul.org,2009:/2007/6/30/bending-itunes-to-my-will-with-rubyosa-take-1/changes</id>
  <generator uri="http://mephistoblog.com" version="0.8.0">Mephisto Drax</generator>
  <link href="http://opensoul.org/2007/6/30/bending-itunes-to-my-will-with-rubyosa-take-1/changes.xml" rel="self" type="application/atom+xml"/>
  <link href="/2007/6/30/bending-itunes-to-my-will-with-rubyosa-take-1" rel="alternate" type="text/html"/>
  <updated>2007-06-30T11:22:09Z</updated>
  <entry xml:base="http://opensoul.org/">
    <author>
      <name>brandon</name>
    </author>
    <id>tag:opensoul.org,2007-06-30:312:2</id>
    <published>2007-06-30T11:15:52Z</published>
    <updated>2007-06-30T11:22:09Z</updated>
    <link href="http://opensoul.org/2007/6/30/bending-itunes-to-my-will-with-rubyosa-take-1" rel="alternate" type="text/html"/>
    <title>Bending iTunes to my will with RubyOSA: take 1</title>
<content type="html">&lt;p&gt;A couple months ago I &lt;a href=&quot;/2007/4/17/moving-podcast-tracks-into-your-itunes-library&quot;&gt;expressed my frustration about iTunes not letting me move podcast files into my library&lt;/a&gt;.  Several people commented with suggestions, such as converting the &lt;span class=&quot;caps&quot;&gt;ID3&lt;/span&gt; tag to an older version, re-importing the track, and then converting the &lt;span class=&quot;caps&quot;&gt;ID3&lt;/span&gt; tag back to 2.4.  This is definitely better than the solution I had found, but still a pain.&lt;/p&gt;


	&lt;p&gt;I tried to find a scriptable solution, but iTunes doesn&#8217;t expose, though AppleScript, the ability to change the &lt;span class=&quot;caps&quot;&gt;ID3&lt;/span&gt; tag version or the mystical &lt;span class=&quot;caps&quot;&gt;ID3&lt;/span&gt; tag attribute that tells iTunes that it&#8217;s a podcast.&lt;/p&gt;


	&lt;p&gt;So, I&#8217;ve turned to Ruby.  Though a little introspection and experimentation with &lt;a href=&quot;http://ID3lib-ruby.rubyforge.org/&quot;&gt;ID3lib-ruby&lt;/a&gt;, I&#8217;ve figured out that it is the &lt;a href=&quot;http://id3lib.sourceforge.net/id3/id3v2com-00.html#tco&quot;&gt;&lt;code&gt;CTO&lt;/code&gt;&lt;/a&gt; (Content Type) ID3v2 tag set to &#8220;Podcast&#8221; that iTunes is using to put the files in the Podcasts folder. Clearing the &lt;code&gt;CTO&lt;/code&gt; tag and readding the track in iTunes will move it into the Library.&lt;/p&gt;


	&lt;p&gt;So, with &lt;a href=&quot;http://rubyosa.rubyforge.org&quot;&gt;RubyOSA&lt;/a&gt;, I&#8217;ve written a little script that will loop through the selected tracks in iTunes and clear the &lt;code&gt;CTO&lt;/code&gt; ID3 tag.&lt;/p&gt;


&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;require 'rubygems'
require 'rbosa'
require 'ID3lib'

itunes = OSA.app('itunes')
itunes.selection.get.each do |track|
  if track.is_a?(OSA::Itunes::Track)
    location = URI.decode(URI.parse(track.location.__data__('furl')).path)
    tag = ID3Lib::Tag.new(location)
    tag.content_type = nil
    tag.update!
  end
end&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;There are a few remaining problems that I would like to tackle:&lt;/p&gt;


	&lt;ol&gt;
	&lt;li&gt;I can&#8217;t figure out how to delete and add the track through RubyOSA.  There is a delete method on the track, but doesn&#8217;t appear to do anything.&lt;/li&gt;
		&lt;li&gt;I want the script to display a dialog confirming the actions about to take place.&lt;/li&gt;
		&lt;li&gt;I want to be able to execute the script from the Scripts menu in iTunes, which appears to involve installing &lt;a href=&quot;http://homepage.mac.com/philip_aker/osa/osa.html&quot;&gt;&lt;span class=&quot;caps&quot;&gt;OSA&lt;/span&gt; Components&lt;/a&gt;.&lt;/li&gt;
	&lt;/ol&gt;


	&lt;p&gt;Overall, this has been a fun experiment (and a reason to play with RubyOSA).  I&#8217;m looking forward to Leopard when this is all built in!&lt;/p&gt;</content>  </entry>
  <entry xml:base="http://opensoul.org/">
    <author>
      <name>brandon</name>
    </author>
    <id>tag:opensoul.org,2007-06-30:311:1</id>
    <updated>2007-06-30T11:15:52Z</updated>
    <link href="http://opensoul.org/2009/3/5/bending-itunes-to-my-will-with-rubyosa-take-1" rel="alternate" type="text/html"/>
    <title>Bending iTunes to my will with RubyOSA: take 1</title>
<content type="html">&lt;p&gt;A couple months ago I &lt;a href=&quot;/2007/4/17/moving-podcast-tracks-into-your-itunes-library&quot;&gt;expressed my frustration about iTunes not letting me move podcast files into my library&lt;/a&gt;.  Several people commented with suggestions, such as converting the &lt;span class=&quot;caps&quot;&gt;ID3&lt;/span&gt; tag to an older version, re-importing the track, and then converting the &lt;span class=&quot;caps&quot;&gt;ID3&lt;/span&gt; tag back to 2.4.  This is definitely better than the solution I had found, but still a pain.&lt;/p&gt;


	&lt;p&gt;I tried to find a scriptable solution, but iTunes doesn&#8217;t expose, though AppleScript, the ability to change the &lt;span class=&quot;caps&quot;&gt;ID3&lt;/span&gt; tag version or the mystical &lt;span class=&quot;caps&quot;&gt;ID3&lt;/span&gt; tag attribute that tells iTunes that it&#8217;s a podcast.&lt;/p&gt;


	&lt;p&gt;So, I&#8217;ve turned to Ruby.  Though a little introspection and experimentation with &lt;a href=&quot;http://ID3lib-ruby.rubyforge.org/&quot;&gt;ID3lib-ruby&lt;/a&gt;, I&#8217;ve figured out that it is the &lt;a href=&quot;http://id3lib.sourceforge.net/id3/id3v2com-00.html#tco&quot;&gt;&lt;code&gt;CTO&lt;/code&gt;&lt;/a&gt; (Content Type) ID3v2 tag set to &#8220;Podcast&#8221; that iTunes is using to put the files in the Podcasts folder. Clearing the &lt;code&gt;CTO&lt;/code&gt; tag and readding the track in iTunes will move it into the Library.&lt;/p&gt;


	&lt;p&gt;So, with &lt;a href=&quot;http://rubyosa.rubyforge.org&quot;&gt;RubyOSA&lt;/a&gt;, I&#8217;ve written a little script that will loop through the selected tracks in iTunes and clear the &lt;code&gt;CTO&lt;/code&gt; ID3 tag.&lt;/p&gt;


&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;require 'rubygems'
require 'rbosa'
require 'ID3lib'

itunes = OSA.app('itunes')
itunes.selection.get.each do |track|
  if track.is_a?(OSA::Itunes::Track)
    location = URI.decode(URI.parse(track.location.__data__('furl')).path)
    tag = ID3Lib::Tag.new(location)
    tag.content_type = nil
    tag.update!
  end
end&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;There are a few remainint problems that I would like to tackle:&lt;/p&gt;


	&lt;ol&gt;
	&lt;li&gt;I can&#8217;t figure out how to delete and add the track through RubyOSA.  There is a delete method on the track, but doesn&#8217;t appear to do anything.&lt;/li&gt;
		&lt;li&gt;I want the script to display a dialog confirming the actions about to take place.&lt;/li&gt;
		&lt;li&gt;I want to be able to execute the script from the Scripts menu in iTunes, which appears to involve installing &lt;a href=&quot;http://homepage.mac.com/philip_aker/osa/osa.html&quot;&gt;&lt;span class=&quot;caps&quot;&gt;OSA&lt;/span&gt; Components&lt;/a&gt;.&lt;/li&gt;
	&lt;/ol&gt;


	&lt;p&gt;Overall, this has been a fun experiment (and a reason to play with RubyOSA).  I&#8217;m looking forward to Leopard when this is all built in!&lt;/p&gt;</content>  </entry>
</feed>
