Sep 27 2006

How to list your audiobooks in iTunes’ Audiobooks pseudo-category

Update: With iTunes 8, moving tracks into the Audiobooks category is now trivial: Go into the track’s file information (Ctrl-I or Apple-I) and change the dropdown item on the Options tab. However, if you want to rip audiobook CDs and convert tracks to chapters, the following may still be use.

One of the reasons I distrust the new version of iTunes (see Why I hate iTunes 7) is the utter uselessness of its new Library structure. In particular, its new Audiobooks category seems to be locked off from any books you’ve ripped yourself. Setting the Genre type of each file to “Audiobooks” isn’t enough.

Nudged by a comment from Rob, I did some digging around, and it appears that audio files will show up in the Audiobooks section if they’re bookmarkable MPEG Layer 4 files — or, in iTunes parlance, “Protected AAC files”.

On a Windows PC, it may be possible to get your AAC files — which should end in the extension .m4a — simply by renaming them so that the extension is .m4b (I can’t vouch for this, though, as I’m working on a Mac).

Macs are slightly trickier to deal with, anyway, as files have an internally-held file type, which must also be altered. However, I did find a couple of scripts on Doug’s Scripts which help.

  • Make Bookmarkable converts your AAC-encoded files to their bookmarkable version, then updates their iTunes entry so that they move to the Audiobooks section.
  • Join Together allows you to combine multiple files from the iTunes Library, optionally placing chapter marks and track artwork at the appropriate sections. However, this script requires QuickTime Pro and Apple’s ChapterTool command-line utility. It can also be very slow if you don’t check the “Passthrough” option in the QuickTime settings part of the dialog.

A bonus of both scripts is that your recordings will also show up under the iPod’s own Audiobooks category. Bear in mind though that, unlike the standard Music folders, it doesn’t group tracks by album. So if you decide to use Make Bookmarkable, or don’t have Quicktime Pro, you could end up with lots of individual files showing up. In that case, you could consider re-importing the original audio from CD, grouping data tracks to encode as a single file.


Sep 22 2006

Why I hate iTunes 7

Okay, “hate” is too strong a word — that’s the sensationalist subeditor in me, I guess. But there was something bugging me about the latest update, and I couldn’t quite put my finger on it.

I knew that it wasn’t the new, drab, grey look — it wouldn’t have been my choice, admittedly; also, it’s a shame that Apple, who impressed me when I became a Mac OSX convert with their User Interface Guidelines, do more than any other company to repeatedly flout them.

The new album view and the CoverFlow view are nice as far as they go, so it wasn’t that. I have to admit I don’t care for the restyled iTunes Music Store, and am infuriated that, in all the talk of Apple selling full-length movies to America, very few people have noticed that they’ve stopped selling even short films to us in the UK. But I only tend to use the store for a small amount of time iTunes is running, so I knew that couldn’t be what was irritating me so.

That’s when it hit me. It’s because my own library is now structured according to how Apple want to sell me stuff.

The iTunes library structureMovies and TV shows are what Apple is pushing in a big way — to American audiences, anyway. Now that short films have been lost to the ether, the only video content you can buy from the iTunes Store are music videos — and they get pushed into the generic ‘Music’ category. iTunes adds a ‘Music Videos’ smart playlist automatically, but why should it need to? It would be far better to mirror the way my iPod structures its library, with Videos having separate subcategories depending on the type of video content.

At least with video content that I have loaded in myself, I can change the Video Kind parameter of each film so that it appears in the appropriate category. However, any audiobooks that I’ve bought on CD and ripped to MP3 remain firmly stuck in “Music”. The Audiobooks category remains firmly the preserve of iTunes Store purchases, it seems — in other words, completely useless. Yes, I can switch both it and iPod Games off in iTunes’ preferences. But I’d much rather be able to add my own content to it.

It’s this twisted attitude — structuring iTunes according how they want to sell to us, rather than making it as easy to use as possible and inspiring us to buy — that really pisses me off.

It’s ironic, really. The MiniStore was another way in which Apple tried to convert normal iTunes usage into a sales tool, but that’s been severely relegated in version 7. There’s no button to activate or deactivate it any more, and the shortcut key has disappeared; hopefully the whole feature will go the same way in version 8. But the philosophy behind it seems to be present still. And that, I really do hate.


Sep 4 2006

New Rails feature: simply_helpful

UPDATE: Thanks to everybody who’s linking to this blog post, especially the mighty DHH himself. It’s worth pointing out that simply_helpful development is proceeding apace. Some of the bugs mentioned have been fixed; there are additional helpers that aren’t covered here; and, as a plugin that’s very, very new, simply_helpful may well change at short notice.

UPDATE 2: The company I work for is looking for Rails developers who are also comfy maintaining PHP code. View our job ad for more. (Done. Look forward to our first big public Rails app sometime in the summer!)

UPDATE 3: DHH linked to me again — thanks David, and welcome to all you hundreds of new visitors!

A new plugin appeared in the Rails SVN overnight, it seems. Named simply_helpful, the intention seems to be to simplify some of the most common uses of helper functions.

I suspect that these changes have been implemented as a plugin so that they don’t impinge on anybody running Edge Rails until they’re 100% stable and 100% backwards-compatible. So, if you want to explore the changes right now, you’ll have to install the plugin in your project yourself:

script/plugin install simply_helpful

With the new plugin installed, some basic helpers get simplified. For example, in my index.rhtml for my Venues controller, I used to have:

<table>
  <tr><th>Name</th> <th>City</th> <th>Postcode</th></tr>
  < %= render :partial => 'venue', :collection => @venues %>
</table>

An aside: that’s a greatly simplified version of the table; I’ve cut out a lot of stuff that would get in the way of seeing what simply_helpful is doing.

But, given that Rails can tell that my @venues array is populated with Venue instances, the new helper doesn’t need me to explicitly name the partial I’m using:

<table>
  <tr><th>Name</th> <th>City</th> <th>Postcode</th></tr>
  < %= render :partial => @venues %>
</table>

So the :collection key becomes redundant (we’re passing an Array, so a collection can be assumed), as does the naming of the partial component itself — simply_helpful automatically derives the location from the passed objects’ class — in this case, as it’s a collection of Venue objects, the partial in question is assumed to be venues/_venue.rhtml.

Along with the collection partials rendering as outlined above, you also get the following (from what my limited Ruby-brain can tell from deciphering the as-yet-undocumented code):

DOM ID attributes

<%= dom_id(object, prefix = nil) %>

Will provide an HTML ID attribute value for an onscreen object based on the object’s class and database ID. For example, dom_id(@person), where @person is a Person instance with a database ID of 123 would return person_123. If the object hasn’t been saved to the database yet, the id will be new_object_name.

By tying this feature into enhancements for RJS helpers, it means that you can now directly link DOM objects on the page to the data objects they represent. The following are now identical in meaning:

page[:person_123]
page[dom_id(@person)]
page[@person]

Pretty nifty.

DOM Class names

<%= dom_class(object) %>

Creates a CSS class name based on the object’s class — so a ProductionType object would get a DOM class of production_type.

On its own, this new function maybe isn’t as exciting as the dom_id and render improvements, but it’s used in the next feature, and it’s encouraging good practice by having clear, readable and consistent class names for your DOM objects.

Form blocks

The new form_for syntax combines with the new Restful Routes, to greatly simplify the form setup:

  • The form’s action points to an update or create action, depending on whether your object has previously been saved.
  • The form will automatically get a DOM id of new_object or edit_object_# (where object is the object’s class name, and # is its database ID), depending on whether it’s a new form or not
  • The form will also automatically get a class name of either new_object or edit_object (again, where object is your object’s class name)

This means that calls to form_for get massively simplified. For example, this line would now work for both new and existing Venue instances:

<% form_for @venue do |f| %>
...

For an existing venue object, that would produce:

<form action="http://localhost:3000/venues/123" class="edit_venue" id="edit_venue_123" method="post">
<input name="_method" type="hidden" value="put" />

whereas the same line of code would, for a new venue object, produce:

<form action="http://localhost:3000/venues" class="new_venue" id="new_venue" method="post">
<input name="_method" type="hidden" value="post" />

Unfortunately, as of right this second (revision 5050), it’s a teensy bit broken. There’s an assumption of an :html option hash being present, so I could only get it to work by changing the above line to < % form_for @venue, :html => {} do |f| %> (this is now fixed).

It also doesn’t support custom form builders yet, which I’m using in my project to automatically attach labels to fields, and to visually demarcate required fields from optional ones (I fixed this! Yay me! :-) )

But then, simply_helpful is less than a day old — these bugs will get ironed out pretty quickly. And when they do, Rails will have yet another way in which it encourages you to write simpler, better code, in a way that’s 100% backwards-compatible.

Credit where it’s due: this post by Marcel Molina Jr. helped me figure out my way round the plugin code.