Create a personal podcast via Folder Actions

Apr 23, '10 07:30:00AM

Contributed by: Lutzifer

This hint allows you to create your own personal podcast channel for iTunes using Folder Actions and either web sharing or a file sharing service like Dropbox. Here is how you can do it.

  1. Create a folder inside the Sites folder in your home directory (if you want to use web sharing), or withing your Dropbox/Public (for Dropbox users) folder, and call it myPodcast or something similar.
  2. Create a text file inside the Folder containing the following code, and call it myPodcast.rss:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
    <channel>
    <description>My personal podcast</description>
    <link>http://www.nolink.com</link>
      <title>My Podcasts/title>
    <pubDate> Wed, 21 Apr 2010 10:35:02 +0200 </pubDate>
    
    </channel></rss>
  3. Open AppleScript Editor, paste the following code, and save the script under Library » Scripts » Folder Action Scripts:
    on adding folder items to this_folder after receiving added_items
      set the_folder to POSIX path of this_folder
    
      -- Adapt the set base_url part to match the url of either your web sharing
      -- address and the folder or your public dropbox folder and the subfolder.
      -- You can get the url by using the "get public link" function on the dropbox home page.
      set base_url to "http://dl.dropbox.com/u/XXXXXXX/myPodcast/" as string
      
      repeat with i from 1 to the count of added_items
        
        set this_item to (item i of added_items) as alias
        tell application "Finder"
          set theName to the name of this_item as string
        end tell
        
        set theUrl to do shell script "python -c 'import sys, urllib; print urllib.quote(sys.argv[1])' " & quoted form of (theName)
        
        tell application "Finder"
          do shell script "cd " & (the quoted form of the_folder as string) & ";export LANG=EN_US;echo \"$(head -n 6 podcast.rss)\" >> newPodcast.rss;echo \"<pubDate> $(date +\"%a, %d %b %Y %H:%M:%S %z\") </pubDate>\" >> newPodcast.rss;tail -n $(($(wc -l < podcast.rss) - 7 )) podcast.rss | head -n $(($(wc -l < podcast.rss) - 8)) >> newPodcast.rss;echo \"<item><title>" & (theName as string) & "</title><enclosure type=\\\"audio/mpeg\\\" length=\\\"$(ls -al $" & (quoted form of theName as string) & "| awk '{print $5}')\\\" url=\\\"" & base_url & theUrl & "\\\"/></item>\" >> newPodcast.rss;tail -n 2 podcast.rss >> newPodcast.rss;rm podcast.rss;mv newPodcast.rss podcast.rss;"
        end tell
        
      end repeat
      
    end adding folder items to
  4. Control-click on the folder you created, and choose Configure Folder Actions from the pop-up menu. In the next dialog, choose the above script as Folder Action.
  5. Open iTunes and add a new Podcast. Insert the above base_url and add myPodcast.rss
Now just drop any music file into the myPodcast Folder. In case of Dropbox, wait until everything is synchronized. When you update your Podcasts in iTunes, it should download the file like in every other podcast.

From now on, you can use your personal podcast to keep track of where you are in longer audio files, like radio recordings. It also works with iTunes-compatible video files.

[robg adds: I haven't tested this one. If you're not a Dropbox user and you'd like to thank Lutzifer for this hint, you can sign up using his Dropbox referral link. This will get him a bit of extra Dropbox storage space.]

Comments (8)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20100421153627718