X-Git-Url: https://diplodocus.org/git/flac-archive/blobdiff_plain/890a5921fe12b21fbc65d88a0e59080dc8cc9a5b..e564c9f4b7463d34f2caf79cb6b33680c277e3e9:/fa-tags diff --git a/fa-tags b/fa-tags index 34eafb8..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 <