Skip to content

Instantly share code, notes, and snippets.

@allthingscode
Created January 28, 2011 21:57
Show Gist options
  • Save allthingscode/801078 to your computer and use it in GitHub Desktop.
Save allthingscode/801078 to your computer and use it in GitHub Desktop.
This is a template script for downloading TiVo files and decoding them.
#!/bin/bash
#
tivo_ip='192.168.1.1'
mak='1234567890'
in_dir='/path/to/videos/tivo_files/in'
out_dir='/path/to/videos/tivo_files/out'
useragent='Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1'
curl_opt="-v --location-trusted --digest -u tivo:${mak} -c cookies.txt --insecure"
# =============================================================================
# Download tivo programs
for url in 'program_name?rest&of&url'; do
file_name=${url##*/}
file_name=${file_name%%\?*}
file_name=$(echo $file_name | sed -e 's/%20/_/g')
in_path="${in_dir}/${file_name}"
#echo $in_path
full_url="http://${tivo_ip}:80/download/${url}"
curl $curl_opt -A "$useragent" -o "$in_path" "$full_url"
done
sleep 5
# Strip tivo DRM
for ITEM in `find "$in_dir" -type f -iname '*.tivo' | sed -e 's/ /[SPACE]/g'` ; do
# unescape spaces
declare FILEPATH
FILEPATH=`echo $ITEM | sed -e 's/\[SPACE\]/ /g'`
if [ -r "$FILEPATH" ] ; then
file_name=${FILEPATH##*/}
tivodecode -n -m $mak -o "${out_dir}/${file_name}.mpg" "$FILEPATH"
sleep 5
mv "$FILEPATH" "${in_dir}/${file_name}.bak"
fi
done
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment