first version

This commit is contained in:
2024-11-25 15:12:08 +01:00
parent 2688e0f831
commit f3fb1ebcbf
13 changed files with 1309 additions and 195 deletions

21
depFiles/audioforge.sh Executable file
View File

@ -0,0 +1,21 @@
#!/bin/sh
CRTSCRIPT=`readlink -f $0`
BASEDIR=${CRTSCRIPT%/*}
if [ $# -lt 1 ]
then
echo "Usage: sh $0 <action> <codec>"
exit 1
else
ACTION=$1
CODEC=$2
DIRECTORY_RIP=/media/rip/
if [ -n $CODEC ]
then
python3 /usr/local/bin/convert_audio.py $DIRECTORY_RIP $CODEC
else
echo "$1: Valid options: rip | encode ">&2
exit 1
fi
esac
fi

68
depFiles/convert_audio.py Executable file
View File

@ -0,0 +1,68 @@
import os
import sys
import subprocess
from pydub import AudioSegment
from pydub.utils import mediainfo
from pathlib import Path
def convert_to_flac(sourcepath, file):
fileName = os.path.splitext(file)[0]
extension = ext
relpath = sourcepath[len(initPath):len(sourcepath)]
destinationDir = destinationBaseDir + relpath + "/"
destinationFile = destinationDir+fileName+extension
if os.path.exists(destinationFile):
print(f"File {destinationFile} already exists")
else:
source_file = sourcepath+file
source_audio = AudioSegment.from_file(sourcepath+"/"+file, format="wav")
Path(destinationDir).mkdir(parents=True, exist_ok=True, mode=0o755)
# source_audio.export(destinationFile, codec=codec, format=newFormat,
# tags=mediainfo(sourcepath+"/"+file).get('TAG', {}))
artistCmd = 'ffmpeg -i "'+source_file+'" 2>&1 | grep artist | awk -F: \'{print $2}\' | sed -e \'s/^[[:space:]]*//\''
artist = out(str(artistCmd))
trackCmd = 'ffmpeg -i "'+source_file+'" 2>&1 | grep track | awk -F: \'{print $2}\' | sed -e \'s/^[[:space:]]*//\''
track = out(str(trackCmd))
titleCmd = 'ffmpeg -i \"'+source_file+'" 2>&1 | grep title | awk -F: \'{print $2}\' | sed -e \'s/^[[:space:]]*//\''
title = out(str(titleCmd))
# addAlbumARtist = 'ffmpeg -i "' + source_file + '" -map_metadata 0 -c '+codec+' -movflags use_metadata_tags -metadata album_artist="'+artist.decode("utf-8")+'"'+ destinationDir+trackCmd.decode("utf-8")+"-"+titleCmd.decode("utf-8")+extension + "\""
print(addAlbumARtist)
# os.system(addAlbumARtist)
print(f"Created {destinationFile}")
def list_directory(path):
with os.scandir(path) as archives:
extension = '.wav'
for archive in archives:
if archive.is_file() and archive.name.endswith(extension):
convert_to_flac(path, archive.name)
elif archive.is_dir():
global relpath
newPath = path+"/"+archive.name
list_directory(newPath)
def out(command):
subprocess.check_output(command)
if len(sys.argv) < 3:
print(f"Use script: {sys.argv[0]} directory codec")
exit()
else:
initPath = sys.argv[1]
codec = sys.argv[2]
if codec == "flac":
destinationBaseDir = "/tmp/FLAC_RIP"
ext = ".flac"
newFormat = 'flac'
elif codec == "alac":
destinationBaseDir = "/tmp/ALAC_DIR"
ext = ".m4a"
newFormat = 'ipod'
else:
print('codec not valid')
exit()
list_directory(initPath)

65
depFiles/extract_audio.py Normal file
View File

@ -0,0 +1,65 @@
import csv
import json
import sys
import music_tag # pip install music-tag
import os
# Variables
csvFilePath = r'albums.csv'
jsonFilePath = r'albums.json'
# Functions
def csv_to_json(csvFilePath, jsonFilePath):
jsonArray = []
# read csv file
with open(csvFilePath, encoding='utf-8') as csvf:
# load csv file data using csv library's dictionary reader
csvReader = csv.DictReader(csvf)
# convert each csv row into python dict
for row in csvReader:
# add this python dict to json array
jsonArray.append(row)
# convert python jsonArray to JSON String and write to file
with open(jsonFilePath, 'w', encoding='utf-8') as jsonf:
jsonString = json.dumps(jsonArray, indent=4)
jsonf.write(jsonString)
def getDataAlbum(key, field):
for keyval in data:
if key == keyval['cddb']:
return keyval[field]
def existCddb(key):
for entry in data:
if key == entry['cddb']:
return True
print('Existe')
if len(sys.argv) < 2:
print(f"Use script: {sys.argv[0]} device")
exit()
else:
csv_to_json(csvFilePath, jsonFilePath)
f = open(jsonFilePath)
data = json.load(f)
# TODO Load key from wav folder
# keyVal = sys.argv[1]
if existCddb(keyVal):
relData = [getDataAlbum(keyVal, 'Artist'),
getDataAlbum(keyVal, 'Album'),
getDataAlbum(keyVal, 'Year'),
getDataAlbum(keyVal, 'disc'),
getDataAlbum(keyVal, 'comments'),
getDataAlbum(keyVal, 'compilation')]
# external programs
ripcd = "cdda2wav -vall cddb=0 speed=4 -paranoia paraopts=proof -B -D"
os.system(cmd)
print(f"Data: {relData}")
else:
print("Item is not found")

27
depFiles/parsexml.py Normal file
View File

@ -0,0 +1,27 @@
from xml.dom import minidom
import xml.etree.ElementTree as ET
# parse an xml file by name
# mydoc = minidom.parse('/home/victor/nfs/media/audio/RIP/Albert King/Stax Profiles/audio.cdindex')
# items = mydoc.getElementsByTagName('Track')
# # one specific item attribute
# print('Item #2 attribute:')
# print(items[1].attributes['Num'].value)
# all item attributes
# print('nAll attributes:')
# for elem in items:
# print(elem.attributes['Num'].value)
tree = ET.parse('/home/victor/nfs/media/audio/RIP/Barón Rojo/20+//audio.cdindex')
root = tree.getroot()
print("Root tag: "+root.tag)
print("Items: ")
for child in root:
print(child.tag, child.attrib)
for track in root.findall("./SingleArtistCD/Track"):
trackName=track.find('Name').text.encode('utf8')
print("Track Number: "+track.attrib['Num'])
print("Track name: "+str(trackName))

View File

@ -0,0 +1,3 @@
AudioSegment
mediainfo
Path

222
depFiles/ripCD.sh Executable file
View File

@ -0,0 +1,222 @@
#!/bin/sh
if [ $# -lt 1 ]
then
echo "Usage: sh $0 <action> <codec>"
exit 1
else
VOLUME=/tmp
RIP_DIR=RIP
ALAC_DIR=ALAC_RIP
FLAC_DIR=FLAC_DIR
DEV=/dev/cdrom
CDDB_URL="freedb.freac.org:/~cddb/cddb.cgi"
ACTION=$1
if [ $ACTION = 'r' ] || [ $ACTION = 'e' ] || [ $ACTION = 'b' ] || [ $ACTION = 'toc' ]; then
if [ $ACTION = "e" ] || [ $ACTION = 'b' ]; then
if [ $# -lt 2 ]; then
echo "If action is 'e' you must to specify a codec. Valid values: flac, alac"
exit 1
else
CODEC=$2
if ( [ $CODEC = 'flac' ] || [ $CODEC = 'alac' ] ); then
ENCODE='s'
else
echo "action Valid values: flac, alac"
exit 1
fi
fi
else
ENCODE='n'
fi
else
echo "Valid <action> values are 'r' for rip, 'e' for encode"
exit 1
fi
if [ $ACTION = 'r' ] || [ $ACTION = 'b' ] ; then
CDDA=$(cdparanoia -Q 2>&1 | grep -c 'audio only')
CSVFILE=$VOLUME/$RIP_DIR/albums.csv
if [ "$CDDA" -eq 1 ]; then
DISCID=$(cd-discid $DEV| awk '{print $1}')
ALBUMNAME=$(curl -s "http://$CDDB_URL?cmd=cddb+query+$(cd-discid "$DEV" | sed 's/ /+/g')&hello=user+hostname+cdparanoia+3&proto=3" | sed -e 's/AC\/DC/\ACDC/g' | sed 's/\// - /g'|awk '{$1=""; $2=""; $3=""; sub(" ", " "); print}'| sed s'/.$//' | awk '{gsub(/^[ \t]+|[ \t]+$/,"")};1' | iconv -f=ISO-8859-1 -t=UTF-8)
PERFORMER=$(echo $ALBUMNAME | awk -F' -' '{print $1}')
ALBUM_TITLE=$(echo $ALBUMNAME | awk -F'- ' '{print $2}')
#SPEED=$(more /proc/sys/dev/cdrom/info | egrep -i --color 'drive speed:' | awk '{print $3}')
# Check autodetected info and download art
read -r -p "Is a compilation?: " COMPILATION
case $COMPILATION in
[yY][eE][sS]|[yY])
read -r -p "Disc number?: " DISCNUMBER
if [[ -z "$DISCNUMBER" ]]; then
DISCNUMBER='1'
fi
;;
[nN][oO]|[nN])
echo -e "No"
DISCNUMBER='1'
;;
*)
echo "Invalid input..."
echo "Quit"
exit 1
;;
esac
echo "Artist detected as: "$PERFORMER""
read -r -p "Is correct: ? [Y/n] " input
case $input in
[yY][eE][sS]|[yY])
echo "Yes"
;;
[nN][oO]|[nN])
echo -e "No"
read -r -p "Enter a new name: " PERFORMER
if [[ -z "$PERFORMER" ]]; then
echo "Invalid input..."
echo "Quit"
exit 1
fi
;;
*)
echo "Invalid input..."
echo "Quit"
exit 1
;;
esac
echo "Album detected as: "$ALBUM_TITLE""
read -r -p "Is correct: ? [Y/n] " input
case $input in
[yY][eE][sS]|[yY])
echo "Yes"
;;
[nN][oO]|[nN])
echo -e "No"
read -r -p "Enter a new name: " ALBUM_TITLE
if [[ -z "$ALBUM_TITLE" ]]; then
echo "Invalid input..."
echo "Quit"
exit 1
fi
;;
*)
echo "Invalid input..."
echo "Quit"
exit 1
;;
esac
# [ Save album info on albums.csv
if [ ! -e ${CSVFILE} ]; then
touch ${CSVFILE}
fi
grep -qF -- $DISCID ${CSVFILE} || echo ""$DISCID","$PERFORMER","$ALBUM_TITLE","$YEAR","$DISCNUMBER"" >> ${CSVFILE}
RIP='s'
if [ $DISCNUMBER -gt 1 ]; then
ALBUM_TITLE="$ALBUM_TITLE (CD $DISCNUMBER)"
fi
if [ -d "$VOLUME/$RIP_DIR/$PERFORMER/$ALBUM_TITLE" ]; then
read -r -p "Directory already exists, do you want to rip audio cd?: [Y/n] " RIP
case $RIP in
[yY][eE][sS]|[yY])
RIP='s'
;;
[nN][oO]|[nN])
RIP='n'
;;
*)
echo "Invalid input..."
echo "Quit"
exit 1
;;
esac
fi
if [ $RIP = 's' ];then
SACAD_PERFORMER=\"${PERFORMER}\"
SACAD_ALBUM_TITLE=\"${ALBUM_TITLE}\"
if [ ! -d "$VOLUME/$RIP_DIR/$PERFORMER/$ALBUM_TITLE" ] && [ $RIP = 's' ]; then
mkdir -p "$VOLUME/$RIP_DIR/$PERFORMER/$ALBUM_TITLE"
fi
sacad "$SACAD_PERFORMER" "$SACAD_ALBUM_TITLE" 500 "$VOLUME/$RIP_DIR/$PERFORMER/$ALBUM_TITLE/AlbumArt.jpg"
cd "$VOLUME/$RIP_DIR/$PERFORMER/$ALBUM_TITLE"
#cdda2wav -vall cddb=0 -cddbp-server=gnudb.gnudb.org speed="$SPEED" -paranoia -B -D $DEV
cdda2wav -vall cddb=0 -cddbp-server=gnudb.gnudb.org -paranoia -B -D $DEV
TOTALTRACKS=$(grep TTITLE audio.cddb |wc -l)
GENRE=$(grep DGENRE audio.cddb | awk -F '=' '{print $2}')
YEAR=$(grep DYEAR audio.cddb | awk -F '=' '{print $2}')
for file in ./*.wav
do
CFILE=$(echo $file | cut -c 3-)
TRACKTITLE=$(grep Tracktitle "${CFILE%wav}inf" |tr -d './' | awk -F= '{print $2}' | sed -e 's/^[[:space:]]*//' | tr -d \')
TRACKNUMBER=$(grep Tracknumber "${CFILE%wav}inf" | tr -d './' | awk -F= '{print $2}' | sed -e 's/^[[:space:]]*//')
echo "File: $file"
ffmpeg -y -i "$file" -metadata album_artist="${PERFORMER}" -metadata artist="${PERFORMER}" -metadata genre="${GENRE}" \
-metadata TRACKTOTAL="$TOTALTRACKS" -metadata date="$YEAR" -metadata album="${ALBUM_TITLE}" \
-metadata disc="${DISCNUMBER}" -metadata track="$TRACKNUMBER" -metadata title="$TRACKTITLE" -c copy "tmp.wav";
mv "tmp.wav" $file
done
fi
fi
fi
if [ $RIP = 's' ] || [ $ACTION = 'toc' ];then
cdrdao read-toc --fast-toc --device "$DEV" --driver generic-mmc:0x20000 --paranoia-mode 0 --with-cddb --cddb-servers $CDDB_URL "$VOLUME/$RIP_DIR/$PERFORMER/$ALBUM_TITLE/$ALBUM_TITLE.toc"
sed -i -e 's/\\240/ /g' -e 's/\\300/À/g' -e 's/\\340/à/g' \
-e 's/\\241/¡/g' -e 's/\\301/Á/g' -e 's/\\341/á/g' \
-e 's/\\242/¢/g' -e 's/\\302/Â/g' -e 's/\\342/â/g' \
-e 's/\\243/£/g' -e 's/\\303/Ã/g' -e 's/\\343/ã/g' \
-e 's/\\244/¤/g' -e 's/\\304/Ä/g' -e 's/\\344/ä/g' \
-e 's/\\245/¥/g' -e 's/\\305/Å/g' -e 's/\\345/å/g' \
-e 's/\\246/¦/g' -e 's/\\306/Æ/g' -e 's/\\346/æ/g' \
-e 's/\\247/§/g' -e 's/\\307/Ç/g' -e 's/\\347/ç/g' \
-e 's/\\250/¨/g' -e 's/\\310/È/g' -e 's/\\350/è/g' \
-e 's/\\251/©/g' -e 's/\\311/É/g' -e 's/\\351/é/g' \
-e 's/\\252/ª/g' -e 's/\\312/Ê/g' -e 's/\\352/ê/g' \
-e 's/\\253/«/g' -e 's/\\313/Ë/g' -e 's/\\353/ë/g' \
-e 's/\\254/¬/g' -e 's/\\314/Ì/g' -e 's/\\354/ì/g' \
-e 's/\\255/ /g' -e 's/\\315/Í/g' -e 's/\\355/í/g' \
-e 's/\\256/®/g' -e 's/\\316/Î/g' -e 's/\\356/î/g' \
-e 's/\\257/¯/g' -e 's/\\317/Ï/g' -e 's/\\357/ï/g' \
-e 's/\\260/°/g' -e 's/\\320/Ð/g' -e 's/\\360/ð/g' \
-e 's/\\261/±/g' -e 's/\\321/Ñ/g' -e 's/\\361/ñ/g' \
-e 's/\\262/²/g' -e 's/\\322/Ò/g' -e 's/\\362/ò/g' \
-e 's/\\263/³/g' -e 's/\\323/Ó/g' -e 's/\\363/ó/g' \
-e 's/\\264/´/g' -e 's/\\324/Ô/g' -e 's/\\364/ô/g' \
-e 's/\\265/µ/g' -e 's/\\325/Õ/g' -e 's/\\365/õ/g' \
-e 's/\\266/¶/g' -e 's/\\326/Ö/g' -e 's/\\366/ö/g' \
-e 's/\\267/·/g' -e 's/\\327/×/g' -e 's/\\367/÷/g' \
-e 's/\\270/¸/g' -e 's/\\330/Ø/g' -e 's/\\370/ø/g' \
-e 's/\\271/¹/g' -e 's/\\331/Ù/g' -e 's/\\371/ù/g' \
-e 's/\\272/º/g' -e 's/\\332/Ú/g' -e 's/\\372/ú/g' \
-e 's/\\273/»/g' -e 's/\\333/Û/g' -e 's/\\373/û/g' \
-e 's/\\274/¼/g' -e 's/\\334/Ü/g' -e 's/\\374/ü/g' \
-e 's/\\275/½/g' -e 's/\\335/Ý/g' -e 's/\\375/ý/g' \
-e 's/\\276/¾/g' -e 's/\\336/Þ/g' -e 's/\\376/þ/g' \
-e 's/\\277/¿/g' -e 's/\\337/ß/g' -e 's/\\377/ÿ/g' "$VOLUME/$RIP_DIR/$PERFORMER/$ALBUM_TITLE/$ALBUM_TITLE.toc"
sed -i -e '/TITLE/s/\\"//g' "$VOLUME/$RIP_DIR/$PERFORMER/$ALBUM_TITLE/$ALBUM_TITLE.toc"
fi
if [ $ENCODE = 's' ];then
# cd $VOLUME/$RIP_DIR
# find . -name '*.wav' | while read line; do
# artistCmd=$(ffmpeg -i "${line}" 2>&1 | grep artist | awk -F: '{print $2}' | sed -e 's/^[[:space:]]*//')
# trackCmd=$(ffmpeg -i "${line}" 2>&1 | grep track | awk -F: '{print $2}' | sed -e 's/^[[:space:]]*//')
# titleCmd=$(ffmpeg -i "${line}" 2>&1 | grep title | awk -F: '{print $2}' | sed -e 's/^[[:space:]]*//')
# if [ $CODEC = 'flac' ]; then
# OUTDIR="$VOLUME/FLAC_RIP"
# EXT="flac"
# fi
# if [ $CODEC = 'alac' ]; then
# OUTDIR="$VOLUME/ALAC_RIP"
# EXT="m4a"
# fi
# OUTSUBDIR=$(echo $line | sed 's/^..//' | awk -F/ '{print $1 "/" $2}')
# OUTFILE=$(echo $line | sed 's/^..//')
# if [ ! -d "$OUTDIR/$OUTSUBDIR" ]; then
# echo "se crea $OUTDIR/$OUTSUBDIR"
# mkdir -p "$OUTDIR/$OUTSUBDIR"
# fi
# ffmpeg -i "${line}" -loglevel verbose -map_metadata 0 -c $CODEC -movflags use_metadata_tags -metadata album_artist="${artistCmd}" "$OUTDIR/${OUTFILE%wav}$EXT"
# #echo "ffmpeg -i \"${line}\" -map_metadata 0 -c $CODEC -movflags use_metadata_tags \"$OUTDIR/${OUTFILE%wav}$EXT\""
# done
python3 /usr/local/bin/convert_audio.py $VOLUME/$RIP_DIR/ $CODEC
#DISCID=$(cd-discid $DEV| awk '{print $1}')
#cddb_query -s gnudb.gnudb.org -P http read misc 0x$DISCID
fi
fi

221
depFiles/ripCD2.sh Normal file
View File

@ -0,0 +1,221 @@
#!/bin/sh
if [ $# -lt 1 ]
then
echo "Usage: sh $0 <action> <codec>"
exit 1
else
VOLUME=/tmp
RIP_DIR=RIP
ALAC_DIR=ALAC_RIP
FLAC_DIR=FLAC_DIR
DEV=/dev/cdrom
ACTION=$1
if [ $ACTION = 'r' ] || [ $ACTION = 'e' ] || [ $ACTION = 'b' ] || [ $ACTION = 'toc' ]; then
if [ $ACTION = "e" ] || [ $ACTION = 'b' ]; then
if [ $# -lt 2 ]; then
echo "If action is 'e' you must to specify a codec. Valid values: flac, alac"
exit 1
else
CODEC=$2
if ( [ $CODEC = 'flac' ] || [ $CODEC = 'alac' ] ); then
ENCODE='s'
else
echo "action Valid values: flac, alac"
exit 1
fi
fi
else
ENCODE='n'
fi
else
echo "Valid <action> values are 'r' for rip, 'e' for encode"
exit 1
fi
if [ $ACTION = 'r' ] || [ $ACTION = 'b' ] ; then
CDDA=$(cdparanoia -Q 2>&1 | grep -c 'audio only')
CSVFILE=$VOLUME/$RIP_DIR/albums.csv
if [ "$CDDA" -eq 1 ]; then
DISCID=$(cd-discid $DEV| awk '{print $1}')
ALBUMNAME=$(curl -s "http://freedb.freac.org/~cddb/cddb.cgi?cmd=cddb+query+$(cd-discid "$DEV" | sed 's/ /+/g')&hello=user+hostname+cdparanoia+3&proto=3" | sed -e 's/AC\/DC/\ACDC/g' | sed 's/\// - /g'|awk '{$1=""; $2=""; $3=""; sub(" ", " "); print}'| sed s'/.$//' | awk '{gsub(/^[ \t]+|[ \t]+$/,"")};1' | iconv -f=ISO-8859-1 -t=UTF-8)
PERFORMER=$(echo $ALBUMNAME | awk -F' -' '{print $1}')
ALBUM_TITLE=$(echo $ALBUMNAME | awk -F'- ' '{print $2}')
#SPEED=$(more /proc/sys/dev/cdrom/info | egrep -i --color 'drive speed:' | awk '{print $3}')
# Check autodetected info and download art
read -r -p "Is a compilation?: " COMPILATION
case $COMPILATION in
[yY][eE][sS]|[yY])
read -r -p "Disc number?: " DISCNUMBER
if [[ -z "$DISCNUMBER" ]]; then
DISCNUMBER='1'
fi
;;
[nN][oO]|[nN])
echo -e "No"
DISCNUMBER='1'
;;
*)
echo "Invalid input..."
echo "Quit"
exit 1
;;
esac
echo "Artist detected as: "$PERFORMER""
read -r -p "Is correct: ? [Y/n] " input
case $input in
[yY][eE][sS]|[yY])
echo "Yes"
;;
[nN][oO]|[nN])
echo -e "No"
read -r -p "Enter a new name: " PERFORMER
if [[ -z "$PERFORMER" ]]; then
echo "Invalid input..."
echo "Quit"
exit 1
fi
;;
*)
echo "Invalid input..."
echo "Quit"
exit 1
;;
esac
echo "Album detected as: "$ALBUM_TITLE""
read -r -p "Is correct: ? [Y/n] " input
case $input in
[yY][eE][sS]|[yY])
echo "Yes"
;;
[nN][oO]|[nN])
echo -e "No"
read -r -p "Enter a new name: " ALBUM_TITLE
if [[ -z "$ALBUM_TITLE" ]]; then
echo "Invalid input..."
echo "Quit"
exit 1
fi
;;
*)
echo "Invalid input..."
echo "Quit"
exit 1
;;
esac
# [ Save album info on albums.csv
if [ ! -e ${CSVFILE} ]; then
touch ${CSVFILE}
fi
grep -qF -- $DISCID ${CSVFILE} || echo ""$DISCID","$PERFORMER","$ALBUM_TITLE","$YEAR","$DISCNUMBER"" >> ${CSVFILE}
RIP='s'
if [ $DISCNUMBER -gt 1 ]; then
ALBUM_TITLE="$ALBUM_TITLE (CD $DISCNUMBER)"
fi
if [ -d "$VOLUME/$RIP_DIR/$PERFORMER/$ALBUM_TITLE" ]; then
read -r -p "Directory already exists, do you want to rip audio cd?: [Y/n] " RIP
case $RIP in
[yY][eE][sS]|[yY])
RIP='s'
;;
[nN][oO]|[nN])
RIP='n'
;;
*)
echo "Invalid input..."
echo "Quit"
exit 1
;;
esac
fi
if [ $RIP = 's' ];then
SACAD_PERFORMER=\"${PERFORMER}\"
SACAD_ALBUM_TITLE=\"${ALBUM_TITLE}\"
if [ ! -d "$VOLUME/$RIP_DIR/$PERFORMER/$ALBUM_TITLE" ] && [ $RIP = 's' ]; then
mkdir -p "$VOLUME/$RIP_DIR/$PERFORMER/$ALBUM_TITLE"
fi
sacad "$SACAD_PERFORMER" "$SACAD_ALBUM_TITLE" 500 "$VOLUME/$RIP_DIR/$PERFORMER/$ALBUM_TITLE/AlbumArt.jpg"
cd "$VOLUME/$RIP_DIR/$PERFORMER/$ALBUM_TITLE"
#cdda2wav -vall cddb=0 -cddbp-server=gnudb.gnudb.org speed="$SPEED" -paranoia -B -D $DEV
cdda2wav -vall cddb=0 -cddbp-server=gnudb.gnudb.org -paranoia -B -D $DEV
TOTALTRACKS=$(grep TTITLE audio.cddb |wc -l)
GENRE=$(grep DGENRE audio.cddb | awk -F '=' '{print $2}')
YEAR=$(grep DYEAR audio.cddb | awk -F '=' '{print $2}')
for file in ./*.wav
do
CFILE=$(echo $file | cut -c 3-)
TRACKTITLE=$(grep Tracktitle "${CFILE%wav}inf" |tr -d './' | awk -F= '{print $2}' | sed -e 's/^[[:space:]]*//' | tr -d \')
TRACKNUMBER=$(grep Tracknumber "${CFILE%wav}inf" | tr -d './' | awk -F= '{print $2}' | sed -e 's/^[[:space:]]*//')
echo "File: $file"
ffmpeg -y -i "$file" -metadata album_artist="${PERFORMER}" -metadata artist="${PERFORMER}" -metadata genre="${GENRE}" \
-metadata TRACKTOTAL="$TOTALTRACKS" -metadata date="$YEAR" -metadata album="${ALBUM_TITLE}" \
-metadata disc="${DISCNUMBER}" -metadata track="$TRACKNUMBER" -metadata title="$TRACKTITLE" -c copy "tmp.wav";
mv "tmp.wav" $file
done
fi
fi
fi
if [ $RIP = 's' ] || [ ACTION = 'toc' ];then
cdrdao read-toc --fast-toc --device "$DEV" --driver generic-mmc:0x20000 --paranoia-mode 0 --with-cddb --cddb-servers freedb.freac.org:/~cddb/cddb.cgi "$VOLUME/$RIP_DIR/$PERFORMER/$ALBUM_TITLE/$ALBUM_TITLE.toc"
sed -i -e 's/\\240/ /g' -e 's/\\300/À/g' -e 's/\\340/à/g' \
-e 's/\\241/¡/g' -e 's/\\301/Á/g' -e 's/\\341/á/g' \
-e 's/\\242/¢/g' -e 's/\\302/Â/g' -e 's/\\342/â/g' \
-e 's/\\243/£/g' -e 's/\\303/Ã/g' -e 's/\\343/ã/g' \
-e 's/\\244/¤/g' -e 's/\\304/Ä/g' -e 's/\\344/ä/g' \
-e 's/\\245/¥/g' -e 's/\\305/Å/g' -e 's/\\345/å/g' \
-e 's/\\246/¦/g' -e 's/\\306/Æ/g' -e 's/\\346/æ/g' \
-e 's/\\247/§/g' -e 's/\\307/Ç/g' -e 's/\\347/ç/g' \
-e 's/\\250/¨/g' -e 's/\\310/È/g' -e 's/\\350/è/g' \
-e 's/\\251/©/g' -e 's/\\311/É/g' -e 's/\\351/é/g' \
-e 's/\\252/ª/g' -e 's/\\312/Ê/g' -e 's/\\352/ê/g' \
-e 's/\\253/«/g' -e 's/\\313/Ë/g' -e 's/\\353/ë/g' \
-e 's/\\254/¬/g' -e 's/\\314/Ì/g' -e 's/\\354/ì/g' \
-e 's/\\255/ /g' -e 's/\\315/Í/g' -e 's/\\355/í/g' \
-e 's/\\256/®/g' -e 's/\\316/Î/g' -e 's/\\356/î/g' \
-e 's/\\257/¯/g' -e 's/\\317/Ï/g' -e 's/\\357/ï/g' \
-e 's/\\260/°/g' -e 's/\\320/Ð/g' -e 's/\\360/ð/g' \
-e 's/\\261/±/g' -e 's/\\321/Ñ/g' -e 's/\\361/ñ/g' \
-e 's/\\262/²/g' -e 's/\\322/Ò/g' -e 's/\\362/ò/g' \
-e 's/\\263/³/g' -e 's/\\323/Ó/g' -e 's/\\363/ó/g' \
-e 's/\\264/´/g' -e 's/\\324/Ô/g' -e 's/\\364/ô/g' \
-e 's/\\265/µ/g' -e 's/\\325/Õ/g' -e 's/\\365/õ/g' \
-e 's/\\266/¶/g' -e 's/\\326/Ö/g' -e 's/\\366/ö/g' \
-e 's/\\267/·/g' -e 's/\\327/×/g' -e 's/\\367/÷/g' \
-e 's/\\270/¸/g' -e 's/\\330/Ø/g' -e 's/\\370/ø/g' \
-e 's/\\271/¹/g' -e 's/\\331/Ù/g' -e 's/\\371/ù/g' \
-e 's/\\272/º/g' -e 's/\\332/Ú/g' -e 's/\\372/ú/g' \
-e 's/\\273/»/g' -e 's/\\333/Û/g' -e 's/\\373/û/g' \
-e 's/\\274/¼/g' -e 's/\\334/Ü/g' -e 's/\\374/ü/g' \
-e 's/\\275/½/g' -e 's/\\335/Ý/g' -e 's/\\375/ý/g' \
-e 's/\\276/¾/g' -e 's/\\336/Þ/g' -e 's/\\376/þ/g' \
-e 's/\\277/¿/g' -e 's/\\337/ß/g' -e 's/\\377/ÿ/g' "$VOLUME/$RIP_DIR/$PERFORMER/$ALBUM_TITLE/$ALBUM_TITLE.toc"
sed -i -e '/TITLE/s/\\"//g' "$VOLUME/$RIP_DIR/$PERFORMER/$ALBUM_TITLE/$ALBUM_TITLE.toc"
fi
if [ $ENCODE = 's' ];then
# cd $VOLUME/$RIP_DIR
# find . -name '*.wav' | while read line; do
# artistCmd=$(ffmpeg -i "${line}" 2>&1 | grep artist | awk -F: '{print $2}' | sed -e 's/^[[:space:]]*//')
# trackCmd=$(ffmpeg -i "${line}" 2>&1 | grep track | awk -F: '{print $2}' | sed -e 's/^[[:space:]]*//')
# titleCmd=$(ffmpeg -i "${line}" 2>&1 | grep title | awk -F: '{print $2}' | sed -e 's/^[[:space:]]*//')
# if [ $CODEC = 'flac' ]; then
# OUTDIR="$VOLUME/FLAC_RIP"
# EXT="flac"
# fi
# if [ $CODEC = 'alac' ]; then
# OUTDIR="$VOLUME/ALAC_RIP"
# EXT="m4a"
# fi
# OUTSUBDIR=$(echo $line | sed 's/^..//' | awk -F/ '{print $1 "/" $2}')
# OUTFILE=$(echo $line | sed 's/^..//')
# if [ ! -d "$OUTDIR/$OUTSUBDIR" ]; then
# echo "se crea $OUTDIR/$OUTSUBDIR"
# mkdir -p "$OUTDIR/$OUTSUBDIR"
# fi
# ffmpeg -i "${line}" -loglevel verbose -map_metadata 0 -c $CODEC -movflags use_metadata_tags -metadata album_artist="${artistCmd}" "$OUTDIR/${OUTFILE%wav}$EXT"
# #echo "ffmpeg -i \"${line}\" -map_metadata 0 -c $CODEC -movflags use_metadata_tags \"$OUTDIR/${OUTFILE%wav}$EXT\""
# done
python3 /usr/local/bin/convert_audio.py $VOLUME/$RIP_DIR/ $CODEC
#DISCID=$(cd-discid $DEV| awk '{print $1}')
#cddb_query -s gnudb.gnudb.org -P http read misc 0x$DISCID
fi
fi

6
depFiles/sources.list Normal file
View File

@ -0,0 +1,6 @@
# deb http://snapshot.debian.org/archive/debian/20221114T000000Z stable main
deb http://deb.debian.org/debian stable main contrib non-free
# deb http://snapshot.debian.org/archive/debian-security/20221114T000000Z stable-security main
deb http://deb.debian.org/debian-security stable-security main
# deb http://snapshot.debian.org/archive/debian/20221114T000000Z stable-updates main
deb http://deb.debian.org/debian stable-updates main

0
depFiles/whipper.conf Normal file
View File