Monthly Archives: February 2017

Fixing the Mastered for iTunes Droplet

Sleep Studies, the band I play with, is in the process of finishing up our next EP. One of the (many) things I’m neurotic about is making sure the masters will translate as well as possible. I’ve written about how I use afclip to examine the master audio files for headroom; another thing I do is run the masters through the Apple’s Master for iTunes Droplet. This is distributed as part of the Mastered for iTunes program.

The Master for iTunes Droplet accepts your lossless files and returns .m4a files that mirror the files the iTunes backend will generate, so you can preview what your content in the store will sound like.

Well, it used to do this until Mac OS X 10.10 Yosemite was released.

The droplet is just a wrapper around an AppleScript file, and it’s easy to examine the script by dragging the entire droplet to the Script Editor application. The problem, it turns out, is just a trivial bug. On lines 62 and 109 you’ll find this chunk of code:

set systemVersion to system version of (get system info)
if systemVersion is less than "10.6" then
    log ("ITUNESMASTERINGDROPLET: incompatible system version")
    display alert SYSTEM_CHECK_ERROR_TITLE message SYSTEM_CHECK_ERROR_MESSAGE as warning buttons {CANCEL_BUTTON_TITLE} default button 1
    log ("ITUNESMASTERINGDROPLET: shutting down")
    error number -128
end if

It’s the if systemVersion is less than "10.6" then part that is troublesome — this is just a string comparison, not a numeric comparison. Starting with Yosemite (10.10), this conditional started doing the wrong thing. “10.10” is in fact less than “10.6” when comparing as strings. The fix is pretty easy, too. The incomparable Michael Tsai laid out a solution on Stack Overflow, which I’ve implemented here:

set systemVersion to system version of (get system info)
considering numeric strings
    set systemVersionNewEnough to systemVersion ≥ 10.6
end considering
if systemVersionNewEnough is false then
    log ("ITUNESMASTERINGDROPLET: incompatible system version")
    display alert SYSTEM_CHECK_ERROR_TITLE message SYSTEM_CHECK_ERROR_MESSAGE as warning buttons {CANCEL_BUTTON_TITLE} default button 1
    log ("ITUNESMASTERINGDROPLET: shutting down")
    error number -128
end if

While I was at it, I wanted to fix the other issue with the Apple-distributed version of the droplet: it isn’t code signed. Because of this, when you download the droplet, Gatekeeper informs you that the application can’t be run.

Sal Soghoian’s MacOSXAutomation site has instructions for signing AppleScript Droplets. They’re easy to follow — the only snag I ran into was that I tried to use my iPhone developer certificate to sign the droplet, and that doesn’t help with Gatekeeper. I had to request a new “Developer ID Application”1 certificate to get things working.

With that, the version of the droplet linked below includes fixes for:

  • Droplet returning an error on Mac OS X 10.10 and later
  • Gatekeeper returning an issue with an unknown developer

I’ve filed a bug report with Apple reflecting these issues — it would be ideal if they fixed the versions they’re distributing. It’s rdar://30067799 if you’re interested in reading it.

Download the fixed Master for iTunes Droplet

On May 22, 2017, Apple released an update for the Master for iTunes Droplet that resolves these bugs. You can read more here, or download the new version here. Now that there’s an official version from Apple, I’ve removed the download link to my unofficial release.


  1. I did this via Xcode 8.2.1 — from the Preferences -> Accounts -> View Details screen, I used the Create button to get the certificate. 

A Custom Recent Posts Widget

One consequence of adding a Microblog feed to this site was that a lot of post IDs were showing up in the Recent Posts widget. It turns out that if a post is missing a title, the widget falls back to just displaying the ID number. Sad!

It turns out that customizing the widget was fairly straightforward. Since I already have a child theme set up, all I had to do was copy the widget class into the child theme, make my tweaks, and add a few lines to my functions.php file.

The functions.php changes were incredibly straightforward. I added the following lines:

// Include Recent Posts Excluding Category widget
include("class-wp-widget-recent-posts-exclude-cat.php");
add_action( 'widgets_init', function(){
    register_widget( 'WP_Widget_Recent_Posts_Exclude_Cat' );
});

… where class-wp-widget-recent-posts-exclude-cat.php is the class of my new widget.

You can see the custom version of the widget on Github. The essence of the changes I made was to add one more filter to the code that retrieves the list of posts:

$r = new WP_Query( apply_filters( 'widget_posts_args', array(
            'posts_per_page'      => $number,
            'no_found_rows'       => true,
            'post_status'         => 'publish',
            'ignore_sticky_posts' => true,
            'cat'                 => $exclude_cat
        ) ) );

The last condition, 'cat' => $exclude_cat, is the one I added. If you pass a negative value to the cat filter, that becomes a category exclusion. In my case, I want to exclude the Micro category, which has an ID of 104, so $exclude_cat = -104.

WordPress Child Theme

Just under a year ago, I wrote about the changes I made to the WordPress TwentyTwelve theme to remove the comment RSS feeds from the site headers. As I was adding the new Microblog RSS feed to the header, I decided to see if I could migrate my modifications into a child theme.

The big advantage of creating a child theme, instead of modifying the parent (original) theme, is that when there is an update available to the parent theme your modifications won’t be lost.

My original modifications required changes to two files:

  1. functions.php:

    • Comment out the line that adds in all feeds:

      // add_theme_support( 'automatic-feed-links' );
      
    • Add in a filter to remove the post comment feeds:

      function disablePostCommentsFeedLink($for_comments) {
          return;
      }
      add_filter('post_comments_feed_link','disablePostCommentsFeedLink');
      
  2. header.php:

    • Added in links to the main RSS feed (since they were removed from functions.php).

To migrate the changes to a child theme, I reverted my version of the TwentyTwelve theme to its original state. You can find my child theme on Github, and you can see the torturous path I took to develop it in the commit history.

My first attempt involved duplicating the entire header.php file, with my changes, into the child theme, and I gave up on figuring out how to comment out add_theme_support( 'automatic-feed-links' ); from the child.

For the second attempt, I tried to achieve the commenting out of add_theme_support( 'automatic-feed-links' ); by removing the function calling it from the after_theme_setup hook. I struggled with figuring out what hook to attach the removal to, and consulted the Actions Run During a Typical Request list in the Codex. Ultimately I attached the removal function to the same after_theme_setup hook, but with a priority of 0:

add_action( 'after_setup_theme', 'child_remove_parent_function_twentytwelve_setup', 0 );

Once I had that working, I stumbled onto the feed_links_show_comments_feed filter, which greatly simplified the whole endeavor. The filter removes both the master comment feed and post comment feeds, which was my entire original objective. I was able to strike both the header.php file and the effort to comment out add_theme_support( 'automatic-feed-links' ); in functions.php.

I was able to accomplish the removal of the comment RSS feeds in my child theme with just this in my functions.php file1:

// disable comment feeds (this seems to disable main and post comment feeds)
add_filter( 'feed_links_show_comments_feed', '__return_false' );

The only thing left to do was add back in the Microblog RSS feed, which I injected into the wp_head hook2 (this, too, is in functions.php):

// Add in microblog feed to header
function microblog_feed() {
    echo '
<link rel="alternate" type="application/rss+xml" title="Jeff Vautin &raquo; Microblog Feed" href="/micro.xml" />
';
}
add_action('wp_head', 'microblog_feed');

I ended up with the same functionality I had before, but in just a handle of lines of code, nicely contained in a child theme. Feel free to fork it for your own use!


  1. Beyond the boilerplate needed to create a child theme

  2. I took inspiration from this Stack Overflow answer

Dakota Access Pipeline

The Army Corps of Engineers is accepting public comments on their plan to grant the easement required to complete the Dakota Access Pipeline. The Notice of Intent indicates that the public comment period runs through February 20, 2017. Comments can be sent to Mr. Gib Owen.

I used a few minutes of this snowy, lazy morning to send the following feedback:

Mr. Owen,

I’m writing to request that Dakota Access, LLC, NOT be granted an easement to cross Lake Oahe.

Because the proposed easement is only one half-mile upstream from the Standing Rock Sioux Tribe’s reservation, any spill would have a substantial impact on their land. As we have seen already in 2017, these pipelines have a substantial likelihood of leaking, and tremendous capacity for damage when a leak occurs. The following articles support this claim:

Report: Kinder Morgan’s pipeline spill in South Carolina bigger than estimated http://savannahnow.com/news/2017-02-03/report-kinder-morgans-pipeline-spill-south-carolina-bigger-estimated This article details a gasoline pipeline spill of more than 500,000 galloons, still seeping into creeks in South Carolina.

Iowa oil spill underscores pipeline risks day after Trump revives major projects https://www.theguardian.com/environment/2017/jan/25/oil-spill-iowa-trump-keystone-dakota-access-pipeline An oil pipeline has leaked 138,600 gallons in Iowa in January.

Oil Pipeline Spills 53,000 Gallons on First Nations Land http://www.ecowatch.com/oil-pipeline-spill-first-nations-2211497739.html Also in January, a Canadian pipeline leaked 200,000L of oil onto Native American lands.

These articles highlight the inability to guarantee the integrity of these pipelines. I urge the Army Corps of Engineers to seek an alternative location for the Dakota Access pipeline.

Thank you,

Jeff Vautin

<Address>
<Phone>
<Email>

Please consider submitting a comment!