-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsplice.pl
executable file
·190 lines (144 loc) · 5.17 KB
/
splice.pl
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
#!/usr/bin/perl
#
# (c) Steven Scholnick <[email protected]>
#
# splice is published under MIT.
use strict;
use warnings;
use lib '.';
use Cwd;
use Getopt::Long;
use Pod::Usage;
use Splice::Engine;
use Splice::PTapes;
use Splice::ResourceFile;
use Splice::CheckLabelFile;
use Splice::Parameters;
use Splice::Utilities;
use Splice::ITunesEngine;
our $VERSION = '2.6.1';
# start of main...
{
my %prefs;
my $rcFilePath = getResourceFilePath(".splicerc", "splice.rc");
if ($rcFilePath) {
%prefs = new Splice::ResourceFile( $rcFilePath )->getAllValues();
}
else {
warnMessage( "No resource file found\n" );
}
GetOptions(
'1column!' => \$prefs{oneColumn},
'8mm' => sub { $prefs{type} = "8mm" },
'addinfo=s' => \$prefs{add_info},
'cassette' => sub { $prefs{type} = "cassette" },
'dat' => sub { $prefs{type} = "DAT" },
'filler!' => \$prefs{fillerTitle},
'flap=s' => \$prefs{flap},
'font=s' => \$prefs{font},
'itunes=s' => \$prefs{itunesPlaylist},
'jewelcase' => sub { $prefs{type} = "cd" },
'help' => \&help,
'number!' => \$prefs{numberEachSong},
'mix!' => \$prefs{useTimes},
'postscript!' => \$prefs{postscript},
'slim!' => \$prefs{slim},
'size=s' => \$prefs{fontSize},
'stdout!' => \$prefs{stdout},
'times!' => \$prefs{useTimes},
'title!' => \$prefs{printTitles},
'version' => \&version,
'width=s' => \$prefs{wrapWidth},
) or help();
$prefs{wrapWidth} = 9999 if $prefs{oneColumn};
$prefs{inFile} = scalar(@ARGV) == 0 ? $prefs{inFile} : $ARGV[0];
dieMessage("Input file $prefs{inFile} not found\n") if (! -e $prefs{inFile} && ! $prefs{itunesPlaylist});
Splice::Parameters::getInstance()->setData(%prefs);
my $engine = undef;
if ($prefs{itunesPlaylist}) {
$prefs{inFile} = getItunesOutputPath(\%prefs);
$engine = new Splice::ITunesEngine(%prefs);
}
else {
$engine = new Splice::Engine(%prefs);
}
$engine->readFile( $prefs{inFile} );
if ($prefs{stdout}) {
print $engine->asInputData();
exit 0;
}
runPtapes($engine->getAllLabels(),\%prefs);
exit 0;
}
sub getItunesOutputPath {
my $prefs = shift;
my $directory = expandPath($prefs->{'itunes.output.directory'});
$directory = $ENV{HOME} if ! $directory;
my $inputFile = $prefs->{itunesPlaylist};
$inputFile =~ s/ /_/g;
$inputFile = normalizeText($inputFile,0);
return "$directory/$inputFile";
}
sub runPtapes { # runs ptapes to create the PS and (if required) the PDF files
my $labels = shift;
my $prefs = shift;
my $ptapes = new Splice::PTapes(
data => $labels,
filePath => $prefs->{inFile},
ps2pdfPath => $prefs->{ps2pdfPath},
pdfViewPath => $prefs->{pdfViewPath},
psViewPath => $prefs->{psViewPath}
);
$ptapes->setAdditionalInfoFontSize( $prefs->{add_info} ) if (defined $prefs->{add_info} );
$ptapes->setSongFontSize( $prefs->{fontSize} ) if (defined $prefs->{fontSize} );
$ptapes->setFlapFontSize( $prefs->{flap} ) if (defined $prefs->{flap} );
$ptapes->setFont( $prefs->{font} ) if (defined $prefs->{font} );
$ptapes->setPostscript( $prefs->{postscript} ) if (defined $prefs->{postscript} );
$ptapes->generateLabel();
}
sub version {
print "splice : Version $VERSION\n";
pod2usage(-verbose=>99,-exitvalue=>1,-sections=>[ qw(COPYRIGHT)] );
}
sub help {
pod2usage(-verbose=>99,-exitvalue=>1,-sections=>[ qw(OPTIONS)] );
}
__END__
=head1 NAME
splice - label maker
=head1 SYNOPSIS
splice [Options] [Input Song File]
=head1 DESCRIPTION
Splice is a label maker for: CDs, DAT tapes, 8mm tapes, and analog cassette tapes. It is primarily
intended for live music, but it can be used for any label need. The setlists are stored in a simple textual fashion
(see below) consisting of a header, the songs, and an optional trailer. The setlist format is designed to both easy
to use (both by splice and the person creating the setlist) and easy to read.
=head1 OPTIONS
--1column : one column, (implies -w9999)
--8mm : 8mm cassette labels
--addinfo <size> : additional information font size
--cassette : cassette labels
--dat : dat labels
--filler : produce a title for the filler
--flap <size> : flap font size
--font <font> : change the default font
--help : this help screen
--itunes <playlist> : Read the songs from the specified iTunes playlist
--jewelcase : jewel case labels (default)
--mix : Create a mix disc (synonym for --times)
--number : Number each song
--postscript : generate a PS file only (do not generate a PDF file)
--size <size> : font size
--slim : Single CD labels for "slim" cases
--stdout : Print out the input data (really only useful with --itunes)
--times : every other song is a time field
--title : generate a title at the top of the setlist
--version : prints version
--width <width> : song wrap width
=head1 SEE ALSO
splice Online at L<https://github.com/scholnicks/splice/wiki>
=head1 AUTHOR
Steven Scholnick <[email protected]>
=head1 COPYRIGHT
(c) Steven Scholnick <[email protected]> 2000 -
splice is published under MIT.