]>
diplodocus.org Git - flac-archive/blob - fa-rip
8 B<fa-rip> - rip a CD for B<fa-flacd>
12 B<fa-rip> [B<-d> I<device>] [B<-t> I<track-count>]
24 use Getopt
::Long
qw(:config gnu_getopt no_ignore_case);
25 use POSIX
':sys_wait_h';
28 use MusicBrainz
::Client
::Simple
;
37 $status = WEXITSTATUS
($?);
39 die("$command exited $status");
42 } elsif (WIFSIGNALED
($?)) {
43 $status = WTERMSIG
($?);
44 die("$command signalled $status");
46 } elsif (WIFSTOPPED
($?)) {
47 $status = WSTOPSIG
($?);
48 die("$command stopped $status");
51 die("Major horkage on system($command): \$? = $? \$! = $!");
57 my $trackcount = shift;
60 push(@command, 'mkcue');
62 if (defined($trackcount)) {
63 push(@command, "-t $trackcount");
66 if (defined($device)) {
67 push(@command, $device);
70 push(@command, '> cue');
71 run_or_die
(join(' ', @command));
73 if (not defined($trackcount)) {
74 open(F
, 'cue') or die("open(cue): $!");
75 $trackcount = grep(/TRACK.*AUDIO/, <F
>);
84 my $trackcount = shift;
94 if (defined($device)) {
95 $mb = new MusicBrainz
::Client
::Simple
(device
=>$device);
97 $mb = new MusicBrainz
::Client
::Simple
;
100 @results = $mb->lookup_cd;
101 if (not $mb->success) {
105 open(F
, '>candidate-tags-0') or die("open('>candidate-tags-0'): $!");
106 print(F
"$_=\n") for ('ARTIST', 'ALBUM', 'DATE');
107 print(F
"TITLE=\n") for 1 .. $trackcount;
108 close(F
) or die("close('>candidate-tags-0'): $!");
110 for $album (@results) {
112 open(F
, ">candidate-tags-$i") or die("open(>candidate-tags-$i): $!");
114 print(F
'ARTIST=', $album->get_artist->get_name, "\n");
115 print(F
'ALBUM=', $album->get_name, "\n");
117 # MusicBrainz doesn't have dates yet; these are usually wrong anyway.
120 @tracks = $album->get_tracks;
121 for $j (1 .. $trackcount) {
122 if ($track = shift(@tracks)) {
123 $name = $track->get_name;
127 print(F
"TITLE=$name\n");
130 close(F
) or die("close(>candidate-tags-$i): $!");
136 my $trackcount = shift;
138 $device ||= '/dev/cdrom';
140 exec('cdparanoia', '-d', $device, "1-$trackcount", 'wav');
141 # exec prints its own error message so just
151 'device|d=s' => \
$CDDEV,
152 'tracks|t=i' => \
$trackcount,
153 'help|h|?' => \
$help,
155 $help and pod2usage
(-exitstatus
=>0, -verbose
=>1);
157 # File::Temp::tempdir calls die on error.
158 $tempdir = File
::Temp
::tempdir
('flac-archive.XXXXXXXXXX');
159 chdir($tempdir) or die("chdir($tempdir): $!");
161 $trackcount = mkcue
($CDDEV, $trackcount);
162 tags
($CDDEV, $trackcount);
163 rip
($CDDEV, $trackcount);
171 B<fa-rip> creates a temporary directory for storage of its
172 intermediate files, runs C<mkcue(1)> to create the "cue" file, uses
173 MusicBrainz to generate candidate tags files, and runs
174 C<cdparanoia(1)> to rip the CD to the "wav" file.
176 In order for this CD to be processed by B<fa-flacd>, you must create a
177 "tags" file. This is usually done by renaming one of the
178 candidate-tags files and deleting the others. Don't forget to fill in
179 the DATE tag in the selected candidate before renaming it. If
180 B<fa-rip> could not find any tag information from MusicBrainz, you'll
181 have to fill out the candidate-tags-0 template.
187 =item B<-d> [B<--device>] I<device>
189 Use I<device> as the CD-ROM device, instead of the default
190 "/dev/cdrom" or the environment variable CDDEV.
192 =item B<-t> [B<--tracks>] I<track-count>
194 Archive only the first I<track-count> tracks. This is handy for
195 ignoring data tracks.
205 B<fa-rip> uses this to rip audio and save the cuesheet for a CD. It
206 makes some effort to check some common device names for FreeBSD,
207 Linux, and NetBSD by default.
213 Written by Eric Gillespie <epg@pretzelnet.org>.
215 flac-archive is free software; you may redistribute it and/or modify
216 it under the same terms as Perl itself.
221 # cperl-indent-level: 4
222 # perl-indent-level: 4
223 # indent-tabs-mode: nil
226 # vi: set tabstop=4 expandtab: