Skip to content

Commit 1f4bccb

Browse files
committed
hopefully fix everything to work with svn mythtv and the new basename database field.
add support to ignore 1.6.3rc2 yuvdenoise
1 parent 1e268f0 commit 1f4bccb

File tree

5 files changed

+63
-56
lines changed

5 files changed

+63
-56
lines changed

trunk/export/ffmpeg.pm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ package export::ffmpeg;
3737
or push @{$self->{'errors'}}, 'You need yuvdenoise (part of mjpegtools) to use this exporter.';
3838
# Check the yuvdenoise version
3939
my $data = `cat /dev/null | yuvdenoise 2>&1`;
40-
if ($data =~ m/yuvdenoise version 1.6.3-rc1/i) {
41-
$self->{'denoise_error'} = 'yuvdenoise version 1.6.3rc1 is broken and cannot be used.';
40+
if ($data =~ m/yuvdenoise version 1.6.3-rc[12]/i) {
41+
$self->{'denoise_error'} = 'yuvdenoise version 1.6.3rc1 (and rc2) are broken and cannot be used.';
4242
}
4343
# Audio only?
4444
$self->{'audioonly'} = $audioonly;
@@ -134,7 +134,7 @@ package export::ffmpeg;
134134
if ($self->val('deint_in_yuvdenoise') && $self->val('deinterlace')) {
135135
$ffmpeg .= " -F";
136136
}
137-
$ffmpeg .= " 2> /dev/null | ";
137+
$ffmpeg .= ' | ';
138138
$videofifo = '-';
139139
$videotype = 'yuv4mpegpipe';
140140
}

trunk/export/generic.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ package export::generic;
6262
if (!$self->{'audioonly'}) {
6363
# Noise reduction?
6464
if ($self->{'denoise_error'}) {
65-
query_text($self->{'denoise_error'}."\nPress enter to continue.",
65+
query_text($self->{'denoise_error'}."\nNoise reduction has been disabled because of an error. Press enter to continue.",
6666
'', '');
6767
}
6868
else {

trunk/mythtv/recordings.pm

Lines changed: 57 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ package mythtv::recordings;
4949
print "Loading MythTV recording info.\n";
5050

5151
# Query variables we'll use below
52-
my ($sh, $sh2, $sh3, $q, $q2, $q3);
52+
my ($sh, $sh2, $sh3, $sh4, $q, $q2, $q3, $q4);
5353

5454
# Find the directory where the recordings are located
5555
$q = "SELECT data FROM settings WHERE value='RecordFilePrefix' AND hostname=?";
@@ -62,76 +62,83 @@ package mythtv::recordings;
6262

6363
# Grab all of the video filenames
6464
opendir(DIR, $video_dir) or die "Can't open $video_dir: $!\n\n";
65-
@Files = grep /\.nuv$/, readdir(DIR);
65+
@Files = grep /\.(?:mpg|nuv)$/, readdir(DIR);
6666
closedir DIR;
6767
die "No recordings found!\n\n" unless (@Files);
6868

6969
# Parse out the record data for each file
70-
$q = "SELECT title, subtitle, description, hostname, cutlist FROM recorded WHERE chanid=? AND starttime=? AND endtime=?";
71-
$q2 = "SELECT mark FROM recordedmarkup WHERE chanid=? AND starttime=? AND type=6 ORDER BY mark DESC LIMIT 1";
72-
$q3 = "SELECT mark FROM recordedmarkup WHERE chanid=? AND starttime=? AND type=9 ORDER BY mark DESC LIMIT 1";
70+
$q = 'SELECT * FROM recorded WHERE basename=?';
71+
$q2 = 'SELECT * FROM recorded WHERE chanid=? AND starttime=?';
72+
$q3 = 'SELECT type, mark FROM recordedmarkup WHERE chanid=? AND starttime=? AND type=6 ORDER BY type ASC, mark DESC LIMIT 1';
7373

7474
$sh = $dbh->prepare($q);
7575
$sh2 = $dbh->prepare($q2);
7676
$sh3 = $dbh->prepare($q3);
7777

7878
my $count;
7979
foreach my $file (@Files) {
80-
next unless ($file =~ /\.nuv$/);
80+
next unless ($file =~ /\.(?:mpg|nuv)$/);
8181
next if ($file =~ /^ringbuf/);
8282
$count++;
83-
# Print a progress dot
83+
# Info hash
84+
my %info;
85+
# Print the progress indicator
8486
print "\r", sprintf('%.0f', 100 * ($count / @Files)), '% ';
85-
# Pull out the various parts that make up the filename
86-
my ($channel,
87-
$syear, $smonth, $sday, $shour, $sminute, $ssecond,
88-
$eyear, $emonth, $eday, $ehour, $eminute, $esecond) = $file =~/^([a-z0-9]+)_(....)(..)(..)(..)(..)(..)_(....)(..)(..)(..)(..)(..)\.nuv$/i;
89-
# Found a bad filename?
90-
unless ($channel) {
91-
print "Unknown filename format: $file\n";
92-
next;
87+
# New db format? (no errors, since this query will break with mythtv < .19)
88+
$sh->execute($file);
89+
%info = %{$sh->fetchrow_hashref};
90+
# Nope
91+
unless ($info{'chanid'}) {
92+
# Pull out the various parts that make up the filename
93+
my ($channel, $starttime) = $file =~/^(\d+)_(\d{14})[_\.]/i;
94+
# Found a bad filename?
95+
unless ($channel) {
96+
print "Unknown filename format: $file\n";
97+
next;
98+
}
99+
# Execute the query
100+
$sh2->execute($channel, $starttime)
101+
or die "Could not execute ($q): $!\n\n";
102+
%info = %{$sh2->fetchrow_hashref};
93103
}
94-
# Execute the query
95-
$sh->execute($channel, "$syear$smonth$sday$shour$sminute$ssecond", "$eyear$emonth$eday$ehour$eminute$esecond")
96-
or die "Could not execute ($q): $!\n\n";
97-
my ($show, $episode, $description, $show_hostname, $cutlist) = $sh->fetchrow_array;
98104
# Skip shows without cutlists?
99-
next if (arg('require_cutlist') && !$cutlist);
105+
next if (arg('require_cutlist') && !$info{'cutlist'});
100106
# Unknown file - someday we should report this
101-
next unless ($show);
102-
$sh2->execute($channel, "$syear$smonth$sday$shour$sminute$ssecond")
103-
or die "Could not execute ($q2): $!\n\n";
104-
my ($lastgop) = $sh2->fetchrow_array;
105-
my $goptype = 6;
106-
107-
if( !$lastgop ) {
108-
$sh3->execute($channel, "$syear$smonth$sday$shour$sminute$ssecond")
109-
or die "Could not execute ($q3): $!\n\n";
110-
($lastgop) = $sh3->fetchrow_array;
111-
$goptype = 9;
112-
}
107+
next unless ($info{'chanid'});
108+
# Pull out GOP info for mpeg files
109+
$sh3->execute($info{'chanid'}, $info{'starttime'})
110+
or die "Could not execute ($q3): $!\n\n";
111+
($info{'goptype'}, $info{'lastgop'}) = $sh3->fetchrow_array;
112+
# Cleanup
113+
$info{'starttime_sep'} = $info{'starttime'};
114+
$info{'starttime_sep'} =~ s/\D+/-/sg;
115+
$info{'starttime'} =~ tr/0-9//cd;
116+
$info{'endtime'} =~ tr/0-9//cd;
113117
# Defaults
114-
$episode = 'Untitled' unless ($episode =~ /\S/);
115-
$description = 'No Description' unless ($description =~ /\S/);
118+
$info{'title'} = 'Untitled' unless ($info{'title'} =~ /\S/);
119+
$info{'subtitle'} = 'Untitled' unless ($info{'subtitle'} =~ /\S/);
120+
$info{'description'} = 'No Description' unless ($info{'description'} =~ /\S/);
116121
#$description =~ s/(?:''|``)/"/sg;
117-
push @{$Shows{$show}}, {'filename' => "$video_dir/$file",
118-
'channel' => $channel,
119-
'start_time' => "$syear$smonth$sday$shour$sminute$ssecond",
120-
'end_time' => "$eyear$emonth$eday$ehour$eminute$esecond",
121-
'start_time_sep' => "$syear-$smonth-$sday-$shour-$sminute-$ssecond",
122-
'show_name' => ($show or ''),
123-
'title' => ($episode or ''),
124-
'description' => ($description or ''),
125-
'hostname' => ($show_hostname or ''),
126-
'cutlist' => ($cutlist or ''),
127-
'lastgop' => ($lastgop or 0),
128-
'goptype' => ($goptype or 0),
129-
'showtime' => generate_showtime($syear, $smonth, $sday, $shour, $sminute, $ssecond),
130-
# This field is too slow to populate here, so it will be populated in ui.pm on-demand
131-
'finfo' => undef
132-
};
122+
push @{$Shows{$info{'title'}}}, {'filename' => "$video_dir/$file",
123+
'channel' => $info{'chanid'},
124+
'start_time' => $info{'starttime'},
125+
'end_time' => $info{'endtime'},
126+
'start_time_sep' => $info{'starttime_sep'},
127+
'show_name' => $info{'title'},
128+
'title' => $info{'subtitle'},
129+
'description' => $info{'description'},
130+
'hostname' => ($info{'hostname'} or ''),
131+
'cutlist' => ($info{'cutlist'} or ''),
132+
'lastgop' => ($info{'lastgop'} or 0),
133+
'goptype' => ($info{'goptype'} or 0),
134+
'showtime' => generate_showtime(split(/-/, $info{'starttime_sep'})),
135+
# This field is too slow to populate here, so it will be populated in ui.pm on-demand
136+
'finfo' => undef
137+
};
133138
}
134139
$sh->finish();
140+
$sh2->finish();
141+
$sh3->finish();
135142
print "\n";
136143

137144
# We now have a hash of show names, containing an array of episodes

trunk/nuvexport

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# $Author$
66

77
# Version
8-
$VERSION = '0.2 0.20050917.svn';
8+
$VERSION = '0.2 0.20050919.svn';
99

1010
# Autoflush buffers
1111
$|++;

trunk/nuvexport.spec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
Name: nuvexport
66
Version: 0.2
7-
Release: 0.20050917.svn
7+
Release: 0.20050919.svn
88
License: GPL
99
Summary: mythtv nuv video file conversion script
1010
URL: http://forevermore.net/nuvexport/

0 commit comments

Comments
 (0)