Skip to content

Commit 17b12a0

Browse files
committed
Checking in local changes that bring nuvexport up to date with the perl bindings, and such that it actually USES the perl bindings now.
1 parent 1c71cde commit 17b12a0

File tree

16 files changed

+321
-283
lines changed

16 files changed

+321
-283
lines changed

nuvexport/export/NUV_SQL.pm

Lines changed: 41 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -52,26 +52,29 @@ package export::NUV_SQL;
5252
# Gather settings from the user
5353
sub gather_settings {
5454
my $self = shift;
55-
# Let the user know what's going on
56-
print "\nYou have chosen to extract the .nuv.\n"
57-
."This will extract it from the MythTV database into .nuv and .sql \n"
58-
."files to import into another MythTV installation.\n\n";
59-
# Make sure the user knows what he/she is doing
60-
$self->{'delete'} = query_text("Do you want to remove it from this server when finished?",
61-
'yesno',
62-
$self->{'delete'} ? 'Yes' : 'No');
63-
# Make EXTRA sure
64-
if ($self->{'delete'}) {
65-
$self->{'delete'} = query_text("\nAre you ".colored('sure', 'bold').' you want to remove it from this server?',
55+
# Only ask for data if we're actually extracting a file
56+
if (!arg('only_save_info')) {
57+
# Let the user know what's going on
58+
print "\nYou have chosen to extract the .nuv.\n"
59+
."This will extract it from the MythTV database into .nuv and .sql \n"
60+
."files to import into another MythTV installation.\n\n";
61+
# Make sure the user knows what he/she is doing
62+
$self->{'delete'} = query_text("Do you want to remove it from this server when finished?",
6663
'yesno',
67-
'No');
64+
$self->{'delete'} ? 'Yes' : 'No');
65+
# Make EXTRA sure
66+
if ($self->{'delete'}) {
67+
$self->{'delete'} = query_text("\nAre you ".colored('sure', 'bold').' you want to remove it from this server?',
68+
'yesno',
69+
'No');
70+
}
71+
# Create a directory with the show name
72+
$self->{'create_dir'} = query_text('Store exported files in a directory with the show name?',
73+
'yesno',
74+
$self->{'create_dir'} ? 'Yes' : 'No');
6875
}
6976
# Load the save path, if requested
7077
$self->{'path'} = query_savepath($self->val('path'));
71-
# Create a
72-
$self->{'create_dir'} = query_text('Create a directory with the show name?',
73-
'yesno',
74-
$self->{'create_dir'} ? 'Yes' : 'No');
7578
}
7679

7780
sub export {
@@ -86,17 +89,17 @@ package export::NUV_SQL;
8689
$self->{'export_path'} = $self->{'path'};
8790
}
8891
# Load the three files we'll be using
89-
my $txt_file = basename($episode->{'filename'}, '.nuv') . '.txt';
90-
my $sql_file = basename($episode->{'filename'}, '.nuv') . '.sql';
91-
my $nuv_file = basename($episode->{'filename'});
92+
my $txt_file = basename($episode->{'local_path'}, '.nuv') . '.txt';
93+
my $sql_file = basename($episode->{'local_path'}, '.nuv') . '.sql';
94+
my $nuv_file = basename($episode->{'local_path'});
9295
# Create a txt file with descriptive info in it
9396
open(DATA, ">$self->{'export_path'}/$txt_file") or die "Can't create $self->{'export_path'}/$txt_file: $!\n\n";
94-
print DATA ' Show: ', $episode->{'show_name'}, "\n",
95-
' Episode: ', $episode->{'title'}, "\n",
97+
print DATA ' Show: ', $episode->{'title'}, "\n",
98+
' Episode: ', $episode->{'subtitle'}, "\n",
9699
' Recorded: ', $episode->{'showtime'}, "\n",
97100
'Description: ', wrap($episode->{'description'}, 64,'', '', "\n "), "\n",
98101
"\n",
99-
' Orig. File: ', $episode->{'filename'}, "\n",
102+
' Orig. File: ', $episode->{'local_path'}, "\n",
100103
' Type: ', $episode->{'finfo'}{'video_type'}, "\n",
101104
' Dimensions: ', $episode->{'finfo'}{'width'}.'x'.$episode->{'finfo'}{'height'}, "\n",
102105
;
@@ -108,9 +111,9 @@ package export::NUV_SQL;
108111
# Load and save the related database info
109112
print DATA "USE mythconverg;\n\n";
110113
foreach $table ('recorded', 'oldrecorded', 'recordedmarkup', 'recordedseek') {
111-
$q = "SELECT * FROM $table WHERE chanid=? AND starttime=?";
114+
$q = "SELECT * FROM $table WHERE chanid=? AND starttime=FROM_UNIXTIME(?)";
112115
$sh = $dbh->prepare($q);
113-
$sh->execute($episode->{'channel'}, $episode->{'start_time'})
116+
$sh->execute($episode->{'chanid'}, $episode->{'starttime'})
114117
or die "Count not execute ($q): $!\n\n";
115118
my $count = 0;
116119
my @keys = undef;
@@ -137,18 +140,22 @@ package export::NUV_SQL;
137140
close DATA;
138141
# Rename/move the file
139142
if ($self->{'delete'}) {
140-
print "\nMoving $episode->{'filename'} to $self->{'export_path'}/$nuv_file\n";
141-
move($episode->{'filename'}, "$self->{'export_path'}/$nuv_file")
143+
print "\nMoving $episode->{'local_path'} to $self->{'export_path'}/$nuv_file\n";
144+
move($episode->{'local_path'}, "$self->{'export_path'}/$nuv_file")
142145
or die "Couldn't move specified .nuv file: $!\n\n";
146+
#
147+
# @todo: Call the backend to delete the recording, rather than doing it
148+
# manually, since this table list is no longer ANYWHERE near complete.
149+
#
143150
# Remove the entry from recordedmarkup
144-
$q = 'DELETE FROM recordedmarkup WHERE chanid=? AND starttime=?';
151+
$q = 'DELETE FROM recordedmarkup WHERE chanid=? AND starttime=FROM_UNIXTIME(?)';
145152
$sh = $dbh->prepare($q);
146-
$sh->execute($episode->{'channel'}, $episode->{'start_time'})
153+
$sh->execute($episode->{'chanid'}, $episode->{'starttime'})
147154
or die "Could not execute ($q): $!\n\n";
148155
# Remove this entry from the database
149-
$q = 'DELETE FROM recorded WHERE chanid=? AND starttime=? AND endtime=?';
156+
$q = 'DELETE FROM recorded WHERE chanid=? AND starttime=FROM_UNIXTIME(?)';
150157
$sh = $dbh->prepare($q);
151-
$sh->execute($episode->{'channel'}, $episode->{'start_time'}, $episode->{'end_time'})
158+
$sh->execute($episode->{'chanid'}, $episode->{'starttime'})
152159
or die "Could not execute ($q): $!\n\n";
153160
# Tell the other nodes that changes have been made
154161
$q = 'UPDATE settings SET data="yes" WHERE value="RecordChanged"';
@@ -158,14 +165,14 @@ package export::NUV_SQL;
158165
}
159166
# Copy the file
160167
else {
161-
print "\nCopying $episode->{'filename'} to $self->{'export_path'}/$nuv_file\n";
168+
print "\nCopying $episode->{'local_path'} to $self->{'export_path'}/$nuv_file\n";
162169
# use hard links when copying within a filesystem
163-
if ((stat($episode->{'filename'}))[0] == (stat($self->{'path'}))[0]) {
164-
link($episode->{'filename'}, "$self->{'export_path'}/$nuv_file")
170+
if ((stat($episode->{'local_path'}))[0] == (stat($self->{'path'}))[0]) {
171+
link($episode->{'local_path'}, "$self->{'export_path'}/$nuv_file")
165172
or die "Couldn't hard link specified .nuv file: $!\n\n";
166173
}
167174
else {
168-
copy($episode->{'filename'}, "$self->{'export_path'}/$nuv_file")
175+
copy($episode->{'local_path'}, "$self->{'export_path'}/$nuv_file")
169176
or die "Couldn't copy specified .nuv file: $!\n\n";
170177
}
171178
}

nuvexport/export/ffmpeg.pm

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ package export::ffmpeg;
3030
use nuv_export::cli;
3131
use nuv_export::ui;
3232
use mythtv::recordings;
33+
use MythTV;
3334

3435
# In case people would rather use yuvdenoise to deinterlace
3536
add_arg('deint_in_yuvdenoise|deint-in-yuvdenoise!', 'Deinterlace in yuvdenoise instead of ffmpeg');
@@ -197,7 +198,11 @@ package export::ffmpeg;
197198

198199
# Here, we have to fork off a copy of mythtranscode (Do not use --fifosync with ffmpeg or it will hang)
199200
my $mythtranscode_bin = find_program('mythtranscode');
200-
$mythtranscode = "$NICE $mythtranscode_bin --showprogress -p $episode->{'transcoder'} -c $episode->{'channel'} -s $episode->{'start_time_sep'} -f \"/tmp/fifodir_$$/\"";
201+
$mythtranscode = "$NICE $mythtranscode_bin --showprogress"
202+
." -p '$episode->{'transcoder'}'"
203+
." -c '$episode->{'chanid'}'"
204+
." -s '".unix_to_myth_time($episode->{'recstartts'})."'"
205+
." -f \"/tmp/fifodir_$$/\"";
201206
$mythtranscode .= ' --honorcutlist' if ($self->{'use_cutlist'});
202207
$mythtranscode .= ' --fifosync' if ($self->{'audioonly'} || $firstpass);
203208

nuvexport/export/ffmpeg/MP3.pm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,12 @@ package export::ffmpeg::MP3;
8383
# Execute ffmpeg
8484
$self->SUPER::export($episode, '.mp3');
8585
# Now tag it
86-
my $safe_title = shell_escape($episode->{'title'});
87-
my $safe_channel = shell_escape($episode->{'channel'});
86+
my $safe_subtitle = shell_escape($episode->{'subtitle'});
87+
my $safe_channel = shell_escape($episode->{'callsign'}.', '.$episode->{'channame'});
8888
my $safe_description = shell_escape($episode->{'description'});
89-
my $safe_show_name = shell_escape($episode->{'show_name'});
89+
my $safe_title = shell_escape($episode->{'title'});
9090
my $safe_outfile = shell_escape($self->get_outfile($episode, '.mp3'));
91-
my $command = "id3tag -A $safe_title -a $safe_channel -c $safe_description -s $safe_show_name $safe_outfile";
91+
my $command = "id3tag -A $safe_subtitle -a $safe_channel -c $safe_description -s $safe_title $safe_outfile";
9292
system($command);
9393
}
9494

nuvexport/export/ffmpeg/MP4.pm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,9 @@ package export::ffmpeg::MP4;
194194
$self->{'out_fps'} = ($self->{'width'} > 320 || $self->{'height'} > 288) ? 29.97 : 23.97;
195195
}
196196
# Embed the title
197-
$safe_title = $episode->{'show_name'};
198-
if ($episode->{'title'} ne 'Untitled') {
199-
$safe_title .= ' - '.$episode->{'title'};
197+
$safe_title = $episode->{'title'};
198+
if ($episode->{'subtitle'} ne 'Untitled') {
199+
$safe_title .= ' - '.$episode->{'subtitle'};
200200
}
201201
my $safe_title = shell_escape($safe_title);
202202
# Build the common ffmpeg string

nuvexport/export/ffmpeg/PSP.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ package export::ffmpeg::PSP;
166166
$self->{'out_aspect'} = 1.3333;
167167
$self->{'aspect_stretched'} = 1;
168168
# Build the ffmpeg string
169-
my $safe_title = shell_escape($episode->{'show_name'}.' - '.$episode->{'title'});
169+
my $safe_title = shell_escape($episode->{'title'}.' - '.$episode->{'subtitle'});
170170
$self->{'ffmpeg_xtra'} = ' -b ' . $self->{'v_bitrate'}
171171
.' -bufsize 65535'
172172
.' -ab 32 -acodec aac'

nuvexport/export/ffmpeg/XviD.pm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,9 @@ package export::ffmpeg::XviD;
135135
# Make sure we have the framerate
136136
$self->{'out_fps'} = $episode->{'finfo'}{'fps'};
137137
# Embed the title
138-
$safe_title = $episode->{'show_name'};
139-
if ($episode->{'title'} ne 'Untitled') {
140-
$safe_title .= ' - '.$episode->{'title'};
138+
$safe_title = $episode->{'title'};
139+
if ($episode->{'subtitle'} ne 'Untitled') {
140+
$safe_title .= ' - '.$episode->{'subtitle'};
141141
}
142142
my $safe_title = shell_escape($safe_title);
143143
# Build the common ffmpeg string

nuvexport/export/generic.pm

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ package export::generic;
188188
# Nothing?
189189
die "Can't find mythcommflag.\n" unless ($mythcommflag);
190190
# Generate the cutlist
191-
system("$NICE $mythcommflag --gencutlist -c $episode->{'channel'} -s $episode->{'start_time_sep'}");
191+
system("$NICE $mythcommflag --gencutlist -c '$episode->{'chanid'}' -s '".unix_to_myth_time($episode->{'recstartts'})."'");
192192
}
193193

194194
# Check for a duplicate filename, and return a full path to the output filename
@@ -206,12 +206,11 @@ package export::generic;
206206
if ($outfile = $self->val('filename')) {
207207
# Generate a list
208208
my %field;
209-
($field{'f'} = ($episode->{'filename'} or '')) =~ s/%/%%/g;
210-
($field{'c'} = ($episode->{'channel'} or '')) =~ s/%/%%/g;
211-
($field{'a'} = ($episode->{'start_time'} or '')) =~ s/%/%%/g;
212-
($field{'b'} = ($episode->{'end_time'} or '')) =~ s/%/%%/g;
213-
($field{'t'} = ($episode->{'show_name'} or '')) =~ s/%/%%/g; # title
214-
($field{'s'} = ($episode->{'title'} or '')) =~ s/%/%%/g; # subtitle/episode
209+
($field{'c'} = ($episode->{'chanid'} or '')) =~ s/%/%%/g;
210+
($field{'a'} = ($episode->{'showtime'} or '')) =~ s/%/%%/g;
211+
($field{'b'} = ($episode->{'endtime'} or '')) =~ s/%/%%/g;
212+
($field{'t'} = ($episode->{'title'} or '')) =~ s/%/%%/g; # title
213+
($field{'s'} = ($episode->{'subtitle'} or '')) =~ s/%/%%/g; # subtitle/episode
215214
($field{'h'} = ($episode->{'host'} or '')) =~ s/%/%%/g;
216215
($field{'m'} = ($episode->{'showtime'} or '')) =~ s/%/%%/g;
217216
($field{'d'} = ($episode->{'description'} or '')) =~ s/%/%%/g;
@@ -222,14 +221,14 @@ package export::generic;
222221
}
223222
# Default format
224223
else {
225-
if ($episode->{'show_name'} ne 'Untitled' and $episode->{'title'} ne 'Untitled') {
226-
$outfile = $episode->{'show_name'}.' - '.$episode->{'title'};
224+
if ($episode->{'title'} ne 'Untitled' and $episode->{'subtitle'} ne 'Untitled') {
225+
$outfile = $episode->{'title'}.' - '.$episode->{'subtitle'};
227226
}
228-
elsif($episode->{'show_name'} ne 'Untitled') {
229-
$outfile = $episode->{'show_name'};
227+
elsif($episode->{'title'} ne 'Untitled') {
228+
$outfile = $episode->{'title'};
230229
}
231230
elsif($episode ne 'Untitled') {
232-
$outfile = $episode->{'title'};
231+
$outfile = $episode->{'subtitle'};
233232
}
234233
else {
235234
$outfile = 'Untitled';
@@ -309,6 +308,29 @@ package export::generic;
309308
}
310309
}
311310

311+
# Save program details
312+
sub save_txt_details {
313+
my $self = shift;
314+
my $episode = shift;
315+
my $outfile = $self->get_outfile($episode, '.txt');
316+
# Some clean versions of the various fields
317+
my $clean_desc = $episode->{'description'};
318+
$clean_desc =~ tr/\n/ /;
319+
my $clean_subtitle = $episode->{'subtitle'};
320+
$clean_subtitle = '' if ($clean_subtitle eq 'Untitled');
321+
# Save the file
322+
print "Saving details to: $outfile\n";
323+
open(DATA, ">$outfile") or die "Can't create $outfile: $!\n";
324+
print DATA <<EOF;
325+
title: $episode->{'title'}
326+
subtitle: $clean_subtitle
327+
description: $clean_desc
328+
channel: $episode->{'callsign'}, $episode->{'channame'}
329+
airdate: $episode->{'showtime'}
330+
EOF
331+
close DATA;
332+
}
333+
312334
# This subroutine forks and executes one system command - nothing fancy
313335
sub fork_command {
314336
my $command = shift;

nuvexport/export/mencoder.pm

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,19 @@ package export::mencoder;
8585
}
8686
# Here, we have to fork off a copy of mythtranscode (need to use --fifosync with mencoder? needs testing)
8787
my $mythtranscode_bin = find_program('mythtranscode');
88-
$mythtranscode = "$NICE $mythtranscode_bin --showprogress -p $episode->{'transcoder'} -c $episode->{'channel'} -s $episode->{'start_time_sep'} -f \"/tmp/fifodir_$$/\"";
88+
$mythtranscode = "$NICE $mythtranscode_bin --showprogress"
89+
." -p '$episode->{'transcoder'}'"
90+
." -c '$episode->{'chanid'}'"
91+
." -s '".unix_to_myth_time($episode->{'recstartts'})."'"
92+
." -f \"/tmp/fifodir_$$/\"";
8993
# On no-audio encodes, we need to do something to keep mythtranscode's audio buffers from filling up available RAM
9094
# $mythtranscode .= ' --fifosync' if ($skip_audio);
9195
# let mythtranscode handle the cutlist
9296
$mythtranscode .= ' --honorcutlist' if ($self->{'use_cutlist'});
9397
}
9498
# Figure out the input files
9599
if ($episode->{'finfo'}{'is_mpeg'} && !$self->{'use_cutlist'}) {
96-
$mencoder .= " -idx $episode->{'filename'} ";
100+
$mencoder .= ' -idx '.shell_safe($episode->{'local_path'});
97101
}
98102
else {
99103
$mencoder .= " -noskip -idx /tmp/fifodir_$$/vidout -audiofile /tmp/fifodir_$$/audout "

nuvexport/export/transcode.pm

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,11 @@ package export::transcode;
226226
}
227227
# Here, we have to fork off a copy of mythtranscode (no need to use --fifosync with transcode -- it seems to do this on its own)
228228
my $mythtranscode_bin = find_program('mythtranscode');
229-
$mythtranscode = "$NICE $mythtranscode_bin --showprogress -p $episode->{'transcoder'} -c $episode->{'channel'} -s $episode->{'start_time_sep'} -f \"/tmp/fifodir_$$/\"";
229+
$mythtranscode = "$NICE $mythtranscode_bin --showprogress"
230+
." -p '$episode->{'transcoder'}'"
231+
." -c '$episode->{'chanid'}'"
232+
." -s '".unix_to_myth_time($episode->{'recstartts'})."'"
233+
." -f \"/tmp/fifodir_$$/\"";
230234
# On no-audio encodes, we need to do something to keep mythtranscode's audio buffers from filling up available RAM
231235
# $mythtranscode .= ' --fifosync' if ($skip_audio);
232236
# Let mythtranscode handle the cutlist?
@@ -245,7 +249,7 @@ package export::transcode;
245249
}
246250
# Is an mpeg
247251
else {
248-
$transcode .= " -i $episode->{'filename'} -x ";
252+
$transcode .= ' -i '.shell_safe($episode->{'local_path'}).' -x ';
249253
if ($episode->{'finfo'}{'mpeg_stream_type'} eq 'mpegpes') {
250254
$transcode .= 'vob';
251255
}

0 commit comments

Comments
 (0)