@@ -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 " \n You 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(" \n Are 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 " \n You 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(" \n Are 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 " \n Moving $episode ->{'filename '} to $self ->{'export_path'}/$nuv_file \n " ;
141- move($episode -> {' filename ' }, " $self ->{'export_path'}/$nuv_file " )
143+ print " \n Moving $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 " \n Copying $episode ->{'filename '} to $self ->{'export_path'}/$nuv_file \n " ;
168+ print " \n Copying $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 }
0 commit comments