RIP freedb.org -- Add notes/todos re migrating to MusicBrainz
[zcdrip] / zcdrip.in
index b77e46d..6312876 100644 (file)
--- a/zcdrip.in
+++ b/zcdrip.in
@@ -1,11 +1,11 @@
 #!/bin/zsh
 
-## Copyright (C) 2006 - 2011 Steve Youngs
+## Copyright (C) 2006 - 2013 Steve Youngs
 
 ## Author:        Steve Youngs <steve@steveyoungs.com>
 ## Maintainer:    Steve Youngs <steve@steveyoungs.com>
 ## Created:       <2006-08-08>
-## Time-stamp:    <Wednesday Jun 22, 2011 16:35:04 steve>
+## Time-stamp:    <Saturday Feb 20, 2021 12:38:28 steve>
 
 ## Redistribution and use in source and binary forms, with or without
 ## modification, are permitted provided that the following conditions
@@ -45,7 +45,8 @@
 ##    o Partial album ripping.  Specify track numbers or a range of
 ##      track numbers to only rip/encode those tracks.
 ##
-##    o Ripping from music DVDs
+##    o Rewrite online metadata retrieval to use MusicBrainz instead
+##      of freedb.org as the latter no longer exists.
 ##
 
 ### Bugs:
@@ -62,7 +63,7 @@ ourname=${0##*/}
 
 # Version info.
 VERSION=@VERSION@
-COPYRIGHT="Copyright (C) 2006 - 2011 Steve Youngs <steve@steveyoungs.com>"
+COPYRIGHT="Copyright (C) 2006 - 2021 Steve Youngs <steve@steveyoungs.com>"
 
 version_str="${ourname}: ${VERSION}
 ${COPYRIGHT}"
@@ -104,7 +105,7 @@ Description:
 
   $ourname is a "frontend" to the process of ripping audio (cdda) CDs
   to a hard disk and encoding the audio tracks to either MP3 format or
-  Ogg Vorbis format.
+  Ogg/Vorbis format.
 
   File names are auto-generated from track titles, with illegal
   characters removed and spaces converted to underscores.
@@ -112,6 +113,10 @@ Description:
   Track title, artist, and album names are added to the ID3 tags or
   Vorbis comments header.
 
+  If the file: '\${PWD}/cover.jpg' exists it will be embedded into
+  each track file as "Front Cover" art.  This is only supported for
+  Ogg/Vorbis and FLAC formats.
+
 Options:
 -------
 
@@ -127,8 +132,8 @@ Options:
         Save encoded files to the directory, DIR.  If flac encoding
         is also requested, see '--flac_copy' option below, the flac
         files will be saved to DIR/flac.  If this option is omitted,
-        it defaults to 'PWD/ARTIST/ALBUM' the album name is first
-        converted to a sane filename.
+        it defaults to: '\${PWD}/ARTIST/ALBUM' (with sanitised
+        filenames).
 
   -e FILE
   --edit_rcfile=FILE
@@ -138,8 +143,8 @@ Options:
 
   -f
   --flac_copy
-        In addition to encoding the CD audio tracks to MP3 or Ogg
-        Vorbis, create a FLAC audio file for archival purposes.
+        In addition to encoding the CD audio tracks to Ogg/Vorbis or
+        MP3, create a FLAC audio file for archival purposes.
 
   -h
   --help
@@ -155,11 +160,16 @@ Options:
 
   -o
   --ogg
-        Specify Ogg Vorbis encoding.
+        Specify Ogg/Vorbis encoding.
 
   -O
   --online
         Attempt to grab the track info from freedb.freedb.org.
+        DO NOT USE.
+
+        freedb.org no longer exists.  The plan is for zcdrip to
+       use MusicBrainz instead of freedb.org but it is not yet
+       implemented.
 
   -p PLAYLISTFILE
   --playlist=PLAYLISTFILE
@@ -175,7 +185,7 @@ Options:
            Artist Name|Track Title
 
         One "record" per line.  Whitespace and punctuation is permitted,
-        blank lines are not.  And there is no "comment" lines.
+        blank lines are not.  And there are no "comment" lines.
 
   -s ARTIST
   --sameartist=ARTIST
@@ -202,10 +212,10 @@ Requirements:
 
     lame        http://www.mp3dev.org/
                 For encoding to MP3 format. (optional if encoding to
-                Ogg Vorbis)
+                Ogg/Vorbis)
 
     oggenc      http://www.xiph.org/
-                For encoding to Ogg Vorbis format (optional if encoding
+                For encoding to Ogg/Vorbis format (optional if encoding
                 to MP3)
 
     flac        http://flac.sourceforge.net/
@@ -264,6 +274,11 @@ Environment Variables:
 
 Example Usage:
 -------------
+  ## Note:
+  Currently, online metadata retrieval is not possible because freedb.org
+  no longer exists.  We will be converting to MusicBrainz but that is yet
+  to be implemented.  In the meantime, the examples below that use the
+  '-O' option are presently not valid.
 
   Probably the most common usage would be to encode to Ogg/Vorbis
   format using track info obtained from freedb.freedb.org.  Like
@@ -311,6 +326,8 @@ ${COPYRIGHT}
 
 EOF
 }
+# Cover Art
+ARTWORK=$(pwd)/cover.jpg
 
 # Convert song title to something resembling a sane filename... no
 # whitespace, no punctuation, etc.  Also adds .ogg/.mp3 extension.
@@ -333,6 +350,7 @@ fnamefix ()
     done
 }
 
+### FIXME: freedb.org no longer exists. Convert to MusicBrainz.
 ### freedb magic
 _freedb_login ()
 {
@@ -360,6 +378,7 @@ _freedb_login ()
     return 0
 }
 
+### FIXME: freedb.org no longer exists. Convert to MusicBrainz.
 _parse_cddb ()
 {
     local various=yes
@@ -420,6 +439,7 @@ _parse_cddb ()
     
 }
 
+### FIXME: freedb.org no longer exists. Convert to MusicBrainz.
 _freedb_read ()
 {
     if [[ -z $1 ]]; then
@@ -438,6 +458,7 @@ _freedb_read ()
     
 }
 
+### FIXME: freedb.org no longer exists. Convert to MusicBrainz.
 _freedb_query ()
 {
     if [[ -z $1 ]]; then
@@ -506,6 +527,7 @@ _freedb_query ()
     esac
 }
 
+### FIXME: freedb.org no longer exists. Convert to MusicBrainz.
 do_online ()
 {
     autoload -U tcp_open
@@ -687,7 +709,8 @@ flacenc ()
 {
     file=$1
     shift                      # pop off $1 (flacfile)
-    flac -8 --delete-input-file -o ${fdir}/${file} ${1}
+    [ -f ${ARTWORK} ] && PIC="--picture=${ARTWORK}" || PIC=""
+    flac -8 ${PIC} --delete-input-file -o ${fdir}/${file} ${1}
     shift                      # pop off next arg (wavfile)
     for tag in title artist album year genre tracknumber comment; do
        metaflac --set-tag="$tag=${1}" ${fdir}/${file}
@@ -701,13 +724,13 @@ flactomp3 ()
     mp3=$2
 
     # tags
-    title=$(metaflac --show-tag=title|cut -d= -f2)
-    artist=$(metaflac --show-tag=artist|cut -d= -f2)
-    album=$(metaflac --show-tag=album|cut -d= -f2)
-    year=$(metaflac --show-tag=year|cut -d= -f2)
-    genre=$(metaflac --show-tag=genre|cut -d= -f2)
-    track=$(metaflac --show-tag=tracknumber|cut -d= -f2)
-    comment=$(metaflac --show-tag=comment|cut -d= -f2)
+    title=$(metaflac --show-tag=title ${flac}|cut -d= -f2)
+    artist=$(metaflac --show-tag=artist ${flac}|cut -d= -f2)
+    album=$(metaflac --show-tag=album ${flac}|cut -d= -f2)
+    year=$(metaflac --show-tag=year ${flac}|cut -d= -f2)
+    genre=$(metaflac --show-tag=genre ${flac}|cut -d= -f2)
+    track=$(metaflac --show-tag=tracknumber ${flac}|cut -d= -f2)
+    comment=$(metaflac --show-tag=comment ${flac}|cut -d= -f2)
 
     flac -c -d $flac|lame -h --tt ${title} --ta ${artist} --tl ${album} \
        --ty $year --tg $genre --tn $track --tc ${comment} - $mp3
@@ -717,7 +740,7 @@ flactomp3 ()
 mp3rip ()
 {
     # Work around lame being too anal about genre
-    lame --genre-list|grep ${genre} 1>/dev/null || genre=Other
+    lame --genre-list 2>&1 | grep -q ${genre} || genre=Other
 
     for (( i=1; i<=$tracks; ++i )); do
        echo MP3-Ripping: $song[$i], by: $artist[$i], to: $filename[$i]
@@ -757,6 +780,7 @@ oggrip ()
                    -N $i $wavfile
                rm $wavfile
            fi
+           [ -f ${ARTWORK} ] && album_art ${dir}/$filename[$i]
            [[ $write_playlist == yes ]] && echo ${dir}/$filename[$i] >> $plfile
        fi
     done
@@ -765,7 +789,7 @@ oggrip ()
 # Make sure we have everything we need.
 # This might be a little over the top, but I don't see any point in
 # checking for `oggenc' if you are encoding to MP3, likewise, there's
-# no point in checking for `lame' if you are encoding to Ogg Vorbis.
+# no point in checking for `lame' if you are encoding to Ogg/Vorbis.
 chkreqs ()
 {
     reqs=(cdparanoia lame oggenc flac)