-
Notifications
You must be signed in to change notification settings - Fork 5
/
nuvexport
executable file
·175 lines (154 loc) · 5.79 KB
/
nuvexport
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#!/usr/bin/perl -w
#
# $Date$
# $Revision$
# $Author$
# Version
$VERSION = '0.2 0.20051019.svn';
# Autoflush buffers
$|++;
# Set up the signal handlers
BEGIN {
$SIG{'INT'} = sub { print "\n"; exit; };
$SIG{'QUIT'} = sub { print "\n"; exit; };
# Annoy people running as root
if ($< < 1) {
print "You are running nuvexport as root -- this is not advised.\nPress ENTER if you really want to do this.\n";
<STDIN>;
}
}
# Add a couple of include paths so we can load the various export and gui modules
use English;
use File::Basename;
use lib dirname($ENV{'_'} or $PROGRAM_NAME), '/usr/share/nuvexport', '/usr/local/share/nuvexport';
# Load the myth and nuv utilities, and connect to the database
use nuv_export::shared_utils;
use nuv_export::cli;
use nuv_export::ui;
use mythtv::recordings;
# Make sure that we have mythtranscode installed
find_program('mythtranscode')
or die "You need mythtranscode in order to use nuvexport.\n\n";
# Load the exporters based on which suite was selected above
if ($export_prog eq 'transcode') {
find_program('transcode')
or die "You need transcode in order to use nuvexport in --transcode mode\n";
# transcode - doesn't seem to work for many MPEG recordings these days
require export::transcode::XviD;
require export::transcode::SVCD;
require export::transcode::VCD;
require export::transcode::DVCD;
require export::transcode::DVD;
}
elsif ($export_prog eq 'ffmpeg') {
find_program('ffmpeg')
or die "You need ffmpeg in order to use nuvexport in --ffmpeg mode\n";
# ffmpeg - seems to work better and is the default
require export::ffmpeg::XviD;
require export::ffmpeg::SVCD;
require export::ffmpeg::VCD;
require export::ffmpeg::DVCD;
require export::ffmpeg::DVD;
require export::ffmpeg::DivX;
require export::ffmpeg::ASF;
require export::ffmpeg::MP3;
require export::ffmpeg::PSP;
}
elsif ($export_prog eq 'mencoder') {
find_program('mencoder')
or die "You need mencoder in order to use nuvexport in --mencoder mode\n";
# ffmpeg - seems to work better and is the default
require export::mencoder::XviD;
}
# Load the other export modules
require export::MPEG2_cut;
require export::NUV_SQL;
# Load the ui
load_cli_args();
# Now that we've loaded the cli args, we can define the exporters
if ($export_prog eq 'transcode') {
push @Exporters, export::transcode::XviD->new;
push @Exporters, export::transcode::SVCD->new;
push @Exporters, export::transcode::VCD->new;
push @Exporters, export::transcode::DVCD->new;
push @Exporters, export::transcode::DVD->new;
}
elsif ($export_prog eq 'ffmpeg') {
push @Exporters, export::ffmpeg::XviD->new;
push @Exporters, export::ffmpeg::SVCD->new;
push @Exporters, export::ffmpeg::VCD->new;
push @Exporters, export::ffmpeg::DVCD->new;
push @Exporters, export::ffmpeg::DVD->new;
push @Exporters, export::ffmpeg::DivX->new;
push @Exporters, export::ffmpeg::ASF->new;
push @Exporters, export::ffmpeg::MP3->new;
push @Exporters, export::ffmpeg::PSP->new;
}
elsif ($export_prog eq 'mencoder') {
push @Exporters, export::mencoder::XviD->new;
}
push @Exporters, export::MPEG2_cut->new;
push @Exporters, export::NUV_SQL->new;
# Show the version?
if (arg('version')) {
print "nuvexport version: $VERSION\n";
exit;
}
# Print the help - for now, this is just perldoc
if (defined arg('help')) {
require nuv_export::help;
}
# Load the recordings, and the $video_dir variable
load_recordings();
# Which exporter to use
$exporter = query_exporters($export_prog);
# Load episodes from the commandline (and display/quit if this is search-only)
@episodes = load_cli_episodes();
# Gather the episodes we want to transcode (unless we have them from the cli already)
@episodes = &load_episodes(@episodes) unless ($is_cli);
# Gather data for this exporter
$exporter->gather_settings();
# Encode right here?
if (arg('noserver')) {
foreach my $episode (@episodes) {
# Keep track of when we started
if ($DEBUG) {
print "\n--------------------------------",
"\nTo encode: ", $episode->{'show_name'};
print ': ', $episode->{'title'} if ($episode->{'title'});
print "\nUse the following commands:\n";
}
else {
print "\nNow encoding: ", $episode->{'show_name'};
print ': ', $episode->{'title'} if ($episode->{'title'});
print "\nEncode started: ".localtime()."\n";
}
my $start = time();
# Encode
$exporter->export($episode);
# Remove tmpfiles
wipe_tmpfiles();
# Report how long the encode lasted
print "\nEncode finished: ".localtime()."\n" unless ($DEBUG);
my $seconds = time() - $start;
my $timestr = '';
# How many hours?
my $hours = int($seconds / 3600);
$timestr .= $hours.'h ' if ($hours > 0);
$seconds = $seconds % 3600;
# Minutes
my $minutes = int($seconds / 60);
$timestr .= $minutes.'m ' if ($minutes > 0);
$seconds = $seconds % 60;
# Generate a nice
$timestr .= $seconds.'s' if ($seconds > 0 || $timestr eq '');
# Notify the user
print "Encode lasted: $timestr\n" unless ($DEBUG);
}
}
# Store in the DB
else {
}
# Exit gracefully
exit;
# vim:ts=4:sw=4:ai:et:si:sts=4