There's a neat program in the contribs dir that creates symlinks with human readable names for all the nuvs in the tv directory. If you create a cron job to run this thing periodically, the links will always be up to date, and makes playing files outside of myth pretty easy. If you export the dir with nfs or samba, other computers (even M$ computers) can play the videos.
I modified the file slightly and have attached my version below. The original occasionally made not so pretty names when the show name had special characters, so I tweaked that. Also, it destroyed all the links at the start, then recreated them all. If I was watching a show on my desktop, mplayer would terminate because the link went away. So I modifed the script to only create new links, and to only destroy invalid links.
Here is what I did. If you want different paths, you must edit the file accordingly. Please be cautious, because this script deletes files.
If something is set up wrong, it could delete something you really want!!
To be extra cautious, I've commented out the "unlink" line at the bottom of the file and added a print line that will print what files would be removed. When you are satisfied that the script is working properly, move the comment from the real unlink line to the print line.
Also, if you've changed the root password to mysql this will need to be tweaked.
su
#mkdir /tv
#mkdir /tv/pretty
#chown mythtv:mythv /tv
#chown mythtv:mythtv /tv/pretty
#exit
touch /tv/mythlink.sh
chmod a+x /tv/mythlink.sh
vi (or what ever editor you like) /tv/mythlink.sh and add the code below:
Code:
#!/bin/sh
# mythlink.sh - Symlinks mythtv files to more readable version in /tv/pretty
# by Dale Gass
# modified by Dave M. for slightly prettier names and doesn't destroy/recreate valid links.
# (I found a windows box watching a recording would terminate playback if the link was removed)
mysql -uroot mythconverg -B --exec "select chanid,starttime,endtime,title,subtitle from recorded;" >/tmp/mythlink.$$
perl -w -e '
my $mythpath= "/myth/tv";
my $altpath= "/tv/pretty";
if (!-d $altpath) {
mkdir $altpath or die "Failed to make directory: $altpath\n";
}
opendir(DIR, $altpath) or die "cannot opendir $altpath: $!";
while (defined($file = readdir(DIR))) {
next if $file =~ /^\.\.?$/; # skip . and ..
@dirlist = (@dirlist,$file);
}
closedir(DIR);
<>;
while (<>) {
chomp;
my ($chanid,$start,$end,$title,$subtitle) = split /\t/;
$subtitle = "" if(!defined $subtitle);
my $ofn = "${chanid}_${start}_${end}.nuv";
do { print "Skipping $mythpath/$ofn\n"; next } unless -e "$mythpath/$ofn";
$start =~ /^....(........)/;
my $nfn = "$1_${title}_${subtitle}";
$nfn =~ s/&/+/g;
$nfn =~ s/\047//g;
$nfn =~ s/[^+0-9a-zA-Z_-]+/_/g;
$nfn =~ s/_$//g;
$goodfile{$nfn} = 1;
if (!-e "$altpath/$nfn"){
print "Creating $nfn\n";
symlink "$mythpath/$ofn", "$altpath/$nfn" or die "Failed to create symlink $altpath/$nfn: $!";
}
}
# remove symlinks that are not pointed at valid files in the database
foreach $fname (@dirlist) {
# switch the comment to the second line after you
# are satisfied that it would not delete a good file.
#unlink "$altpath/$fname" unless $goodfile{$fname};
print "I want to unlink $altpath/$fname\n" unless $goodfile{$fname};
}
' /tmp/mythlink.$$
rm /tmp/mythlink.$$
Now run it:
/tv/mythlink.sh
It should create a bunch of symbolic links under /tv/pretty. If you delete a recording in mythtv and run it again, it should want to delete the link.
Now to run it in a cron job so that the links will always be up to date. I run it at 5 and 35 minutes after every hour, you can set up the cron job differently.
As user mythtv,
crontab -e
(now add the following lines with vi commands and then type :wq! in the editor)
Code:
# run tvpretty script at 5 and 35 after every hour
5,35 * * * * nice -n 19 /tv/mythlink.sh
If you run crontab -l, you should see the lines. That's it!