#!/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
## 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:
# 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}"
$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.
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:
-------
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
-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
-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
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
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/
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
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.
done
}
+### FIXME: freedb.org no longer exists. Convert to MusicBrainz.
### freedb magic
_freedb_login ()
{
return 0
}
+### FIXME: freedb.org no longer exists. Convert to MusicBrainz.
_parse_cddb ()
{
local various=yes
}
+### FIXME: freedb.org no longer exists. Convert to MusicBrainz.
_freedb_read ()
{
if [[ -z $1 ]]; then
}
+### FIXME: freedb.org no longer exists. Convert to MusicBrainz.
_freedb_query ()
{
if [[ -z $1 ]]; then
esac
}
+### FIXME: freedb.org no longer exists. Convert to MusicBrainz.
do_online ()
{
autoload -U tcp_open
{
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}
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
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]
-N $i $wavfile
rm $wavfile
fi
+ [ -f ${ARTWORK} ] && album_art ${dir}/$filename[$i]
[[ $write_playlist == yes ]] && echo ${dir}/$filename[$i] >> $plfile
fi
done
# 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)