Mar 142012
 

This is just a quick and dirty script to delete MythTV recordings that had been previously transcoded and moved to the stream directory, but have since been autoexpired out of MythTV. This is an issue because trying to pull data outta the MythTV recording database about a recording that has been deleted causes an error because the entry isn’t there anymore. All it does is loop through each file in the stream directory and if it doesn’t exist in /var/lib/mythtv/recordings/ it gets deleted.

Contents of:
/usr/local/bin/mythexpire.pl

Advertisement:
#!/usr/bin/perl -w
use Fcntl; #The Module
#Checks the myth recording directory for .mp4 files that don't have a corresponding .mpg. If found, it deletes them and generates a new feed

#Change below to your myth recordings directory
$directory = "/var/lib/mythtv/recordings";
$streamdirectory = "/var/www/stream";
$s = "";
$deletedfile = "";

foreach $f (<$streamdirectory/*>) {
$f =~ s/^\/var\/www\/stream\///;
    if ( $f =~ /\.mp4$/ ){
                $s = $directory . "\/". $f;
                $s =~ s/\.mp4$//;
                if (!( -e $s )){
                        $deletedfile = $streamdirectory . "\/" . $f;
                        $deletedfile =~ s/\.mp4$//;
                        print $deletedfile . "\n";
                        `rm -f $deletedfile.*`;
                        $deleted = "true";
                }
        }
}

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)