#! /usr/bin/perl -w

# (C) Copyright Craig Sanders <cas@taz.net.au> 2009, 2013
#
# This script is licensed under the terms of the GNU General Public
# License version 3 (or later, at your option).

# run like so:
#   myth-list-titles.sh -r simpsons | grep -E '\.(nuv|mpg)' | awk -F'|' '{print $6}' | tail -20 | myth-delete-recording.pl
# or:
#   myth-list-titles.sh -r simpsons --basename-only | myth-delete-recording.pl

use MythTV;

$Myth = new MythTV();

# take args from both stdin and from the command line.

# if stdin is not a terminal, it must be a pipe or redirection so push
# lines from stdin onto ARGV.  assume one line per file basename.
if (! -t STDIN) {
  while(<>) { push @ARGV, chomp };
};

foreach my $basename (@ARGV) {
  print "deleting $basename\n" ;
  my $file = $Myth->new_recording($basename);
  $Myth->backend_command(['FORCE_DELETE_RECORDING', $file->to_string()], '0');
};

