Compare with Previous | Blame | View Log
#!/bin/bash
# compass4ipod.sh - Grab the video of CBC's Compass newscast for Prince Edward
# Island and convert for iPod viewing.
#
# Version: 0.5, October 16, 2009
# Author: Peter Rukavina (mailto:peter@rukavina.net)
# Copyright: Copyright (c) 2009 by Reinvented Inc.
# License: http://www.fsf.org/licensing/licenses/gpl.txt GNU Public Licens
#
# For additional information and documentation, see:
#
# http://ruk.ca/content/compass-your-ipod
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or (at
# your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA
# Set this to the number of seconds you want to record (60 seconds x 15 minutes = 900 seconds)
STOPTIME=900
# What's the URL from the cbc.ca/pei for watching the Compass video?
COMPASS=http://www.cbc.ca/ondemand/compass.asx
# Get today's date: we'll save the video file as Compass-YYYY-MM-DD.mp4
TODAY=`date "+%Y-%m-%d"`
# Make sure that VLC is installed
if [ -e "/Applications/VLC.app/Contents/MacOS/VLC" ]
then
# Grab the Compass stream from the CBC website and transcode to MP4
# If this doesn't work, you can add debugging by adding '-vvv' to the arguments for VLC.
/Applications/VLC.app/Contents/MacOS/VLC -I dummy $COMPASS --sout='#transcode{width=320,canvas-height=240,vcodec=mp4v,vb=768,acodec=mp4a,ab=96,channels=2}:duplicate{dst=std{access=file,mux=mp4,dst="/tmp/Compass-'$TODAY'.mp4"}}' --stop-time=$STOPTIME vlc://quit
# Add the resulting file to iTunes
/usr/bin/osascript -e 'tell application "iTunes" to add POSIX file "/tmp/Compass-'$TODAY'.mp4"'
# Delete the file once it's been added to iTunes
/bin/rm /tmp/Compass-$TODAY.mp4
else
echo "ERROR: You need to install VLC from http://www.videolan.org/vlc/"
fi