Notes on the Script
The majority of what the script does is to convert one way of talking about folders to another. EyeTV refers to the folders where the recordings are stored as a "unique ID" of a "program." This is a floating point number (like 1.28438934), which has to be translated into the hexadecimal equivalent to find the directory name that corresponds to it in the EyeTV archive (I did this the simple way by passing it to Perl and having it do the conversion in a simple one-line program):
tell application "EyeTV" set thePrograms to programs set theRepository to repository url as string repeat with theProgram in thePrograms set theUniqueID to unique ID of theProgram set theDirName to (do shell script "perl -e 'printf \"%016x\"," & theUniqueID & "'") set thePath to theRepository & theDirName set thePOSIXPath to (POSIX path of thePath)...
At this point, I've got the POSIX path (like /Users/mcmahon/Library/EyeTV/000000007839af8) which will let me do the symbolic link later. I save this along with the program name, episode, etc., and then scan the EyeTV archive directory directly with the Finder, looking for the items that are folders (if we ran this program before, it's created symlinks which we want to skip). Now we scan the contents of each one of these directories, adding up the sizes of the files to see if we're still under the magic 4.34GB that will fit on a DVD created via the Finder.
Once we've got a DVD-full, we use
chose from list to display the list of programs we're going to back up, and then use code like this to copy the files to the DVD:
tell application "Finder" activate open disk theDisk end tell repeat with i from 1 to length of theFolders set theFolder to item i of theFolders set sourceFolder to alias (theFolder & ":") set targetFolder to alias (theDisk & ":") tell application "Finder" with timeout of (10 * minutes) seconds duplicate folder sourceFolder to targetFolder replacing yes end timeout end tell end repeat
Notice here that we have to talk about the folders as aliases. For safety, we then move the folders we just backed up to the Documents folder (talking about them as aliases again), and then do the work of actually setting up the symbolic links to the folders on the DVD:
-- the directory in the EyeTV Archive we're linking to the DVD set targetPOSIXPath to escapeSpaces(thePOSIXPath) -- use the disk name and directory name to create the name of the file on the backup set sourcePOSIXPath to "/Volumes/" & escapeSpaces(theDVD) & "/" & (theDirName) -- Symlink the DVD directory into the archive do shell script "ln -s " & sourcePOSIXPath & " " & targetPOSIXPath
Now we need to talk about them as files to the (Unix) shell, which means that the folder names can't contain any spaces; these confuse the shell into thinking that the filename ends at the space, which we don't want. The
escapeSpaces subroutine makes sure that any spaces in the filename are escaped with a backslash (
\) in front of them to keep the shell from getting confused.
I've simplified these excerpts for tutorial purposes; the actual program builds a big list of lists that contains all of the information from the EyeTV Archive and then spends most of the rest of the time filtering it and extracting data out of it.
This file archiving is a time-consuming process, and it will take some time to back up a large amount of video. But in the end, you've got backups of your recordings, with captioning intact, and disk space to record more.
Author's note: Elgato just released EyeTV 2.0. I haven't purchased this version yet, so the information in this article is verifiable for the previous version, EyeTV 1.8.4. But I don't see any reason why Elgato would change the archive structure for this update. If you have version 2 and can test these techniques, please post a comment with your outcome.
Joe McMahon is a test automation architect for Yahoo! Search. He has been working with Macs since the 512K got an 800K disk drive.
Return to the Mac DevCenter
EyeTV 2 makes (most) of this useless ... which is good!
2007-01-23 16:01:36 pemungkah [View]
Are DVDs the right media to archive with?
2006-02-20 11:01:20 DaveLentz [View]
Are DVDs the right media to archive with?
2006-02-20 11:06:30 DaveLentz [View]
2006-02-17 08:06:47 GrahamAJones [View]