[bglug] audiorip

k|b|s kbs@bglug.it
Lun 29 Ago 2005 16:18:37 CEST


Allora, tornati dalle ferie? E io qui a lavorare per pagarvi la pensione...

Per chi non si è ancora obnubilato la mente con grip et similia.

Base version. TODO: add lame and burn support.
Uso: inserite il cd, date audiorip e aspettate che faccia tutto per voi.
Programmi necessari: cdrtools e xsltproc

Happy ripping.

--8<-- CUT HERE --8<-- 
#!/bin/sh
#
# audiorip v0.1
# Save your audio cd to ogg
# by k|b|s
# License: GPL


if [ ! -d ~/.audiorip ]; then
	mkdir ~/.audiorip
fi

if [ ! -f ~/.audiorip/config ]; then
	echo ""
	echo "  Creating ~/.audiorip/config"
	echo "  Edit it before continuing"
cat << EOF >> ~/.audiorip/config
TMP=/tmp/audiorip
## Change to fit your needs
BASEDIR=~/music
## Lame, oggenc... (TODO)
## ENCODER=oggenc
## Range 1-10
QUALITY=8
## 56K? [yes|no]
MODEM=yes
## cddb query: [0] = interactive ; [1] = first fit mode
CDDBQUERY=0
EOF
exit
fi

. ~/.audiorip/config

if [ ! -d $TMP ]; then
mkdir $TMP
fi

cd $TMP

# Yes, I am a poor 56Ker...
if [ "$MODEM" = "yes" ]; then
if [ -f /var/run/ppp0.pid ]; then
cdda2wav --cddb $CDDBQUERY --bulk
else 
	echo "audiorip v0.1"
	echo "  Connect to the Net and retry ;^)"
	exit
fi
fi

cat << EOF >> audiorip.xsl
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                version="1.0">

  <xsl:output method="text"/>
  <xsl:strip-space elements="*"/>

  <xsl:param name="quality" select="'$QUALITY'"/>

  <xsl:template match="CDInfo">
    <xsl:text>#!/bin/sh
# Generated by audiorip v0.1
# by Joe Galaxy <joegalaxy(at)despammed(dot)com>
# Album: </xsl:text>
    <xsl:value-of select="Title"/><xsl:text>
</xsl:text>
<xsl:apply-templates/>
  </xsl:template>

  <xsl:template match="SingleArtistCD">
    <xsl:for-each select="Track">
      <xsl:text>oggenc</xsl:text>
      <xsl:text> --quality=</xsl:text><xsl:value-of select="\$quality"/>
      <xsl:text> --output=&quot;</xsl:text>
      <xsl:number value="@Num" format="01"/>
      <xsl:text>_</xsl:text>
      <xsl:value-of select="translate(Name, ' ', '_')"/>
      <xsl:text>.ogg</xsl:text>
      <xsl:text>&quot;</xsl:text>
      <xsl:text> --artist &quot;</xsl:text>
      <xsl:value-of select="../Artist"/>
      <xsl:text>&quot;</xsl:text>
      <xsl:text> --title &quot;</xsl:text>
      <xsl:value-of select="."/>
      <xsl:text>&quot;</xsl:text>
      <xsl:text> --album &quot;</xsl:text>
      <xsl:value-of select="//Title"/>
      <xsl:text>&quot;</xsl:text>
      <xsl:text> --tracknum </xsl:text>
      <xsl:value-of select="@Num"/>
      <xsl:text> audio_</xsl:text><xsl:number value="@Num" format="01"/>
      <xsl:text>.wav</xsl:text>
      <xsl:text>
</xsl:text>
    </xsl:for-each>
  </xsl:template>

  <xsl:template match="*">
  </xsl:template>
</xsl:stylesheet>
EOF

ARTIST="`cat audio.cdindex | grep "<Artist>" | sed -e 's/<Artist>//g' -e 's/<\/Artist>//g' -e 's/^[ \t]*//;s/[ \t]*$//' -e 's/ /_/g'`"
mkdir -p $BASEDIR/$ARTIST

ALBUM="`cat audio.cdindex | grep Title | sed -e 's/<Title>//g' -e 's/<\/Title>//g' -e 's/^[ \t]*//;s/[ \t]*$//' -e 's/ /_/g'`"
mkdir -p $BASEDIR/$ARTIST/$ALBUM

xsltproc -o encode.sh audiorip.xsl audio.cdindex
sh ./encode.sh
cp *.ogg audio.cddb audio.cdindex audiorip.xsl encode.sh $BASEDIR/$ARTIST/$ALBUM
ls $BASEDIR/$ARTIST/$ALBUM/*.ogg | sed 's/^.\///g' > $BASEDIR/$ARTIST/$ALBUM/$ARTIST-$ALBUM.m3u

rm -rf $TMP
--8<-- CUT HERE --8<-- 


-- 
011010110110001001110011010000000110001001100111
011011000111010101100111001011100110100101110100


Maggiori informazioni sulla lista bglug