]>
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>]
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 print"$_\n" for ('cdparanoia', '-d', $device, "1-$trackcount", 'wav');
141 exec('cdparanoia', '-d', $device, "1-$trackcount", 'wav');
142 # exec prints its own error message so just
152 'device|d=s' => \
$CDDEV,
153 'tracks|t=i' => \
$trackcount,
154 'help|h|?' => \
$help,
156 $help and pod2usage
(-exitstatus
=>0, -verbose
=>1);
158 # File::Temp::tempdir calls die on error.
159 $tempdir = File
::Temp
::tempdir
('flac-archive.XXXXXXXXXX');
160 chdir($tempdir) or die("chdir($tempdir): $!");
162 $trackcount = mkcue
($CDDEV, $trackcount);
163 tags
($CDDEV, $trackcount);
164 rip
($CDDEV, $trackcount);
172 B<fa-rip> creates a temporary directory for storage of its
173 intermediate files, runs C<mkcue(1)> to create the "cue" file, uses
174 MusicBrainz to generate candidate tags files, and runs
175 C<cdparanoia(1)> to rip the CD to the "wav" file.
177 In order for this CD to be processed by B<fa-flacd>, you must create a
178 "tags" file. This is usually done by renaming one of the
179 candidate-tags files and deleting the others. Don't forget to fill in
180 the DATE tag in the selected candidate before renaming it. If
181 B<fa-rip> could not find any tag information from MusicBrainz, you'll
182 have to fill out the candidate-tags-0 template.
188 =item B<-d> [B<--device>] I<device>
190 Use I<device> as the CD-ROM device, instead of the default
191 "/dev/cdrom" or the environment variable CDDEV.
193 =item B<-t> [B<--tracks>] I<track-count>
195 Archive only the first I<track-count> tracks. This is handy for
196 ignoring data tracks.
206 B<fa-rip> uses this to rip audio and save the cuesheet for a CD. It
207 makes some effort to check some common device names for FreeBSD,
208 Linux, and NetBSD by default.
214 Written by Eric Gillespie <epg@pretzelnet.org>.
216 flac-archive is free software; you may redistribute it and/or modify
217 it under the same terms as Perl itself.
222 # cperl-indent-level: 4
223 # perl-indent-level: 4
224 # indent-tabs-mode: nil
227 # vi: set tabstop=4 expandtab: