From: epg <> Date: Fri, 27 Aug 2004 03:07:55 +0000 (+0000) Subject: fa-tags: X-Git-Url: https://diplodocus.org/git/flac-archive/commitdiff_plain/bbb47ac8a49e5cfa41d7fd3b5c584b76ff07ac4f?ds=inline;hp=6aa2468770481c0e17a41760600b8a4eaff7a846 fa-tags: Rewrite in Perl using MusicBrainz::Client::Simple. fa-rip: Adapt to new fa-tags. Use mktemp(1) to create work directory now that we don't have cd-discid. README: No longer need cddb-tool and cd-discid. --- diff --git a/README b/README index 324eddd..a1c241f 100644 --- a/README +++ b/README @@ -2,7 +2,6 @@ $Id$ Run perldoc fa-flacd for more information. -flac-archive requires Perl >= 5.6, zsh >= 4.0, cddb-tool (part of -abcde) and cd-discid, cdparanoia, and cdrdao. +flac-archive requires Perl >= 5.6, zsh >= 4.0, cdparanoia, and cdrdao. flac2mp3 additionally requires lame. diff --git a/fa-rip b/fa-rip index a97e90c..eabf52e 100755 --- a/fa-rip +++ b/fa-rip @@ -23,14 +23,14 @@ if [[ -z ${CDDEV} ]]; then fi fi -discid=($(cd-discid ${CDDEV})) +dir=$(mktemp -d flac-archive.XXXXXXXXXX) +cd ${dir} -[[ -d $discid[1] ]] || mkdir $discid[1] -cd $discid[1] +cdrdao read-toc --device ${CDDEV} --driver generic-mmc toc +toc2cue toc cue -eval fa-tags $discid & +trackcount=$(grep -c 'TRACK.*AUDIO' cue) -cdrdao read-toc --device ${CDDEV} --driver generic-mmc toc -toc2cue toc cue & +fa-tags ${trackcount} exec cdparanoia -d ${CDDEV} 1-$(grep -c 'TRACK.*AUDIO' cue) wav diff --git a/fa-tags b/fa-tags index 743736a..d17dba3 100755 --- a/fa-tags +++ b/fa-tags @@ -1,103 +1,52 @@ -#! /usr/bin/env zsh +#! /usr/bin/env perl # $Id$ -# Copyright (c) 1998-2001 Robert Woodcock -# Copyright (c) 2003-2004 Jesus Climent -# Copyright (c) 2004 Eric Gillespie -# This code is hereby licensed for public consumption under either the -# GNU GPL v2 or greater, or Larry Wall's Artistic license - your choice. +use strict; +use warnings; -set -e +use Getopt::Long; +use Pod::Usage; -if [[ -z ${CDDBURL} ]]; then - CDDBURL="http://freedb.freedb.org/~cddb/cddb.cgi" -fi +use MusicBrainz::Client::Simple; -get_cddb_protocol () { - for CDDBPROTO in 5 4 3; do - if [[ \ - $(cddb-tool stat $CDDBURL $USER $HOST $CDDBPROTO \ - | sed 's/^\([0-9][0-9]*\).*/\1/;q') = '210' ]]; then - return 0 - fi - done +my $help; +GetOptions( + 'help|h|?' => \$help, + ) or pod2usage(); +$help and pod2usage(-exitstatus=>0, -verbose=>1); - echo "${CDDBURL} does not work" - exit 2 -} - -handle_read=$(<candidate-tags-0'): $!"); +print(F "$_=\n") for ('ARTIST', 'ALBUM', 'DATE'); +print(F "TITLE=\n") for 1 .. $trackcount; +close(F) or die("close('>candidate-tags-0'): $!"); -/^TTITLE[[:digit:]]+/ { - rstrip_print("TITLE=" \$2) -} -EOF -) +my $i; +for my $album (@result) { + $i++; + open(F, '>', "candidate-tags-$i") or die("open('>candidate-tags-$i'): $!"); -perl_handle_read=$(<candidate-tags-$i'): $!"); } -EOF -) - -handle_queries () { - local F - local i=1 - - # First eat the status line. - read F - - while read -A F; do - [[ $F = '.' ]] && break - cddb-tool read $CDDBURL $CDDBPROTO $USER $HOST $F[1] $F[2] \ - | nawk $handle_read > candidate-tags-$i -# XXX The awk script has at least one problem; since we can't split to -# exactly two components, we break on track names with equal signs. -# Use Perl instead: -# cddb-tool read $CDDBURL $CDDBPROTO $USER $HOST $F[1] $F[2] \ -# | perl -lne $handle_read > candidate-tags-$i - i=$(( $i + 1 )) - done -} - -get_cddb_protocol -(cddb-tool query $CDDBURL $CDDBPROTO $USER $HOST "$@" | handle_queries) & - -cat > candidate-tags-0 <