#1 Le 14/11/2016, à 10:15
- Compte anonymisé
[Abandon]Problème avec script de copie CD-Audio
Bonjour,
je viens vers vous car je n'arrive pas dans la partie "GRAVAGE" de mon script à faire éjecter un CD-R inutilisable ( Déjà enregistré) ; Reconnaissance en fait.
J'aimerai que dans ce script, tant que le CD-R chargé n'ai pas Vierge, il soit rejeté . Et que la suite du script continue.
Pour la partie CD-RW, ça fonctionne.
J'espère que mes explications sont bonnes.
Je vous post mon script. Merci par avance.
#!/bin/sh
## @Golgot200
## Programmes cdrdao cuetools
## Recherche sur freedb des informations sur le disque compact audio.
## Création du dossier ayant le nom de l'artiste et le titre de l'album. [ les fichier *.bin + *.toc seront déplacé à l'intérieur ]
## RIP du CDA vers une image *.bin et un fichier *.toc sera crée.
## Correction des mauvais caractères dans le fichier T*.toc ... [à compléter le cas échéant]
## Possibilité de créer un fichier *.cue.
## Éjection et attente chargement du média.
## Fermeture Auto
## N'écrase pas l'image existante si présente. [à améliorer]
## Vérification si le CD contient des données ou est vierge. ( Choix pour effacer ou pour changer de support )
## N'efface pas un CD-RW vide.
## Pas de CD-R ou CD-RW lors du lancement de la gravure. [ possibilité de quitter]
## Refuse un CD-R non vierge !!!
VERT="\\033[1;32m"
VERTCLAIR="\033[32m"
NORMAL="\\033[0;39m"
ROUGE="\\033[1;31m"
ROSE="\\033[1;35m"
BLEU="\\033[1;34m"
BLANC="\\033[0;02m"
BLANCLAIR="\\033[1;08m"
JAUNE="\\033[1;33m"
CYAN="\\033[1;36m"
DEVICE=/dev/sr0
echo "$VERTCLAIR Ouverture Du Lecteur $NORMAL"
eject $DEVICE
echo "Charger Le Compact Disc Audio, Puis Touche $BLEU[Entrée]$NORMAL "
read touche
case $touche in
*) echo "$VERTCLAIR Fermeture, Recherche Infos ...$NORMAL"
;;
esac
eject -t $DEVICE
## CDDB INFO
ALBUMNAME=$(curl -s "http://freedb.freedb.org/~cddb/cddb.cgi?cmd=cddb+query+$(cd-discid $DEVICE | sed 's/ /+/g')&hello=user+hostname+cdparanoia+3&proto=3" | sed 's/\// - /g'|awk '{$1=""; $2=""; $3=""; sub(" ", " "); print}'| sed s'/.$//' | awk '{gsub(/^[ \t]+|[ \t]+$/,"")};1') \
CDID=$(curl -s "http://freedb.freedb.org/~cddb/cddb.cgi?cmd=cddb+query+$(cd-discid $DEVICE | sed 's/ /+/g')&hello=user+hostname+cdparanoia+3&proto=3" | head -n1 | awk '{print $3}';) \
TRACKLIST=$(curl -s "http://freedb.freedb.org/~cddb/cddb.cgi?cmd=cddb+read+misc+$CDID&hello=name+hostname+cdparanoia+3&proto=1" | grep TTITLE | awk -F "=" '{print $2}';) \
ARTIST=$(curl -s "http://freedb.freedb.org/~cddb/cddb.cgi?cmd=cddb+read+misc+$CDID&hello=name+hostname+cdparanoia+3&proto=1" | grep DTITLE | awk -F "=" '{print $2}' | awk -F "/" '{print $1}')
## CRÉATION DU DOSSIER "ARTISTE + TITRE" / PERMET À L'UTILISATEUR DE MODIFIER LE NOM
echo "Album Identifié : $JAUNE $ALBUMNAME $NORMAL"
read -p "Ces Informations Sont-elles Correctes ? (y/n) " yn
case $yn in
[Yy]* )
mkdir "$ALBUMNAME" ;;
[Nn]* )
read -p "Entrez Les Informations Correctes: " ALBUMNAME
mkdir "$ALBUMNAME";;
* ) echo "Répondre Par Oui Ou Par Non.";;
esac
## RIP DU CD-AUDIO VERS UNE IMAGE BIN & SON FICHIER TOC
read -p "Ripper Le Compact Disc Audio ? (y/n)" reply
choice=$(echo $reply)
if [ "$choice" = 'y' ]
then
echo "$VERTCLAIR Création De L'image En Cours ...$NORMAL";
cdrdao read-cd --source-device $DEVICE --driver generic-mmc --with-cddb --datafile "$ALBUMNAME.bin" "$ALBUMNAME.toc"
## CORRECTION DES MAUVAIS CARACTÈRES DANS LE FICHIER TOC
sed -i -e 's/\\351/é/g' -e 's/\\350/è/g' -e 's/\\353/ë/g' -e 's/\\352/ê/g' -e 's/\\340/à/g' -e 's/\\342/â/g' -e 's/\\347/ç/g' -e 's/\\356/î/g' -e 's/\\364/ô/g' -e 's/\\373/û/g' -e 's/\\371/ù/g' "$ALBUMNAME.toc"
elif [ "$choice" = 'n' ]
then
echo "Éjection Du CD";
rm -R "$ALBUMNAME"
eject $DEVICE
echo "$VERTCLAIR Opération Abandonnée $VERTCLAIR"
exit
fi
## CRÉATION DU FICHIER CUE
read -p "Créer Le Fichier CUE ? (y/n)" reply
choice=$(echo $reply)
if [ "$choice" = 'y' ]
then
echo "$VERTCLAIR Création Du Fichier CUE ...$NORMAL";
cueconvert -i toc -o cue "$ALBUMNAME.toc" "$ALBUMNAME.cue"
mv "$ALBUMNAME.cue" "$ALBUMNAME"
elif [ "$choice" = 'n' ]
then
echo "$VERTCLAIR Étape Suivante ...$NORMAL";
fi
## DÉPLACEMENT DES 2 FICHIERS DANS LE DOSSIER
mv "$ALBUMNAME.bin" "$ALBUMNAME"
mv "$ALBUMNAME.toc" "$ALBUMNAME"
## GRAVAGE
read -p "Lancer La Gravure ? (y/n)" reply
choice=$(echo $reply)
if [ "$choice" = 'y' ]
then
eject $DEVICE
echo "Insérez Un CD Vierge Dans Le Lecteur Et Appuyer Sur La Touche [Entrée]"
read touche
case $touche in
*) echo "$VERTCLAIR Chargement Du CD ...$NORMAL"
;;
esac
eject -t $DEVICE
elif [ "$choice" = 'n' ]
then
echo "$VERTCLAIR Opération Terminée $NORMAL";
eject $DEVICE
exit
fi
echo "$VERTCLAIR Vérification Que Le Support Présent Dans Le Lecteur Est Bien Vide ...$NORMAL"
#cdrdao disk-info /dev/sr0 2>&1| grep 'empty ' | grep yes && cdrdao disk-info /dev/sr0 2>&1| grep 'CD-RW ' | grep yes ;
cdrdao disk-info $DEVICE 2>&1| grep 'empty ' | grep yes ;
STATUS=$?
while [ $STATUS != "0" ] ; do
echo "Ce Support Contient Des Données"
read -p "Faut-il [C]hanger Le Disque , [E]ffacer Ce CD Ou [A]bandonner La Gravure ? (c/e/a)" reply
choice=$(echo $reply)
if [ "$choice" = 'c' ]
then
echo "$VERTCLAIR Éjection Du CD $VERTCLAIR";
eject $DEVICE
echo "Charger Un Nouveau Support et Appuyer Sur [Entrée]"
read touche
case $touche in
*) echo "$VERTCLAIR Fermeture ...$NORMAL"
;;
esac
eject -t $DEVICE
sleep 17
elif [ "$choice" = 'e' ]
then
echo "$VERTCLAIR Effacement En Cours ...$NORMAL";
cdrdao blank –device $DEVICE –blank-mode minimal
elif [ "$choice" = 'a' ]
then
echo "Abandon Par L'utilateur - Opération Terminée. ";
eject $DEVICE
exit
fi
cdrdao disk-info $DEVICE 2>&1 | grep 'empty' | grep yes ;
STATUS=$?
done
echo "Le CD Est Vide : OK"
read -p "Graver le CD Maintenant ? (y/n)" reply
choice=$(echo $reply)
if [ "$choice" = 'y' ]
then
echo "$VERTCLAIR Création Du CD-Audio ...$NORMAL";
#cdrdao write --device $DEVICE --driver generic-mmc-raw audiocd.toc ;
cdrdao write --device $DEVICE --driver generic-mmc-raw "$ALBUMNAME/$ALBUMNAME.toc" ;
elif [ "$choice" = 'n' ]
then
echo "$VERTCLAIR Éjection Du CD $NORMAL";
eject $DEVICE
exit
fi
eject $DEVICE
exit
Dernière modification par Compte anonymisé (Le 17/01/2017, à 10:28)
#2 Le 15/11/2016, à 18:56
- kholo
Re : [Abandon]Problème avec script de copie CD-Audio
salut,
ce serait bien d'indenter car c'est dur à lire
je me demande si j'ai pas manqué un fi quelque part !
version indentée :
#!/bin/sh
## @Golgot200
## Programmes cdrdao cuetools
## Recherche sur freedb des informations sur le disque compact audio.
## Création du dossier ayant le nom de l'artiste et le titre de l'album. [ les fichier *.bin + *.toc seront déplacé à l'intérieur ]
## RIP du CDA vers une image *.bin et un fichier *.toc sera crée.
## Correction des mauvais caractères dans le fichier T*.toc ... [à compléter le cas échéant]
## Possibilité de créer un fichier *.cue.
## Éjection et attente chargement du média.
## Fermeture Auto
## N'écrase pas l'image existante si présente. [à améliorer]
## Vérification si le CD contient des données ou est vierge. ( Choix pour effacer ou pour changer de support )
## N'efface pas un CD-RW vide.
## Pas de CD-R ou CD-RW lors du lancement de la gravure. [ possibilité de quitter]
## Refuse un CD-R non vierge !!!
VERT="\\033[1;32m"
VERTCLAIR="\033[32m"
NORMAL="\\033[0;39m"
ROUGE="\\033[1;31m"
ROSE="\\033[1;35m"
BLEU="\\033[1;34m"
BLANC="\\033[0;02m"
BLANCLAIR="\\033[1;08m"
JAUNE="\\033[1;33m"
CYAN="\\033[1;36m"
DEVICE=/dev/sr0
echo "$VERTCLAIR Ouverture Du Lecteur $NORMAL"
eject $DEVICE
echo "Charger Le Compact Disc Audio, Puis Touche $BLEU[Entrée]$NORMAL "
read touche
case $touche in
*) echo "$VERTCLAIR Fermeture, Recherche Infos ...$NORMAL" ;;
esac
eject -t $DEVICE
## CDDB INFO
ALBUMNAME=$(curl -s "http://freedb.freedb.org/~cddb/cddb.cgi?cmd=cddb+query+$(cd-discid $DEVICE | sed 's/ /+/g')&hello=user+hostname+cdparanoia+3&proto=3" | sed 's/\// - /g'|awk '{$1=""; $2=""; $3=""; sub(" ", " "); print}'| sed s'/.$//' | awk '{gsub(/^[ \t]+|[ \t]+$/,"")};1') \
CDID=$(curl -s "http://freedb.freedb.org/~cddb/cddb.cgi?cmd=cddb+query+$(cd-discid $DEVICE | sed 's/ /+/g')&hello=user+hostname+cdparanoia+3&proto=3" | head -n1 | awk '{print $3}';) \
TRACKLIST=$(curl -s "http://freedb.freedb.org/~cddb/cddb.cgi?cmd=cddb+read+misc+$CDID&hello=name+hostname+cdparanoia+3&proto=1" | grep TTITLE | awk -F "=" '{print $2}';) \
ARTIST=$(curl -s "http://freedb.freedb.org/~cddb/cddb.cgi?cmd=cddb+read+misc+$CDID&hello=name+hostname+cdparanoia+3&proto=1" | grep DTITLE | awk -F "=" '{print $2}' | awk -F "/" '{print $1}')
## CRÉATION DU DOSSIER "ARTISTE + TITRE" / PERMET À L'UTILISATEUR DE MODIFIER LE NOM
echo "Album Identifié : $JAUNE $ALBUMNAME $NORMAL"
read -p "Ces Informations Sont-elles Correctes ? (y/n) " yn
case $yn in
[Yy]* ) mkdir "$ALBUMNAME" ;;
[Nn]* ) read -p "Entrez Les Informations Correctes: " ALBUMNAME
mkdir "$ALBUMNAME" ;;
* ) echo "Répondre Par Oui Ou Par Non." ;;
esac
## RIP DU CD-AUDIO VERS UNE IMAGE BIN & SON FICHIER TOC
read -p "Ripper Le Compact Disc Audio ? (y/n)" reply
choice=$(echo $reply)
if [ "$choice" = 'y' ]; then
echo "$VERTCLAIR Création De L'image En Cours ...$NORMAL";
cdrdao read-cd --source-device $DEVICE --driver generic-mmc --with-cddb --datafile "$ALBUMNAME.bin" "$ALBUMNAME.toc"
## CORRECTION DES MAUVAIS CARACTÈRES DANS LE FICHIER TOC
sed -i -e 's/\\351/é/g' -e 's/\\350/è/g' -e 's/\\353/ë/g' -e 's/\\352/ê/g' -e 's/\\340/à/g' -e 's/\\342/â/g' -e 's/\\347/ç/g' -e 's/\\356/î/g' -e 's/\\364/ô/g' -e 's/\\373/û/g' -e 's/\\371/ù/g' "$ALBUMNAME.toc"
elif [ "$choice" = 'n' ]; then
echo "Éjection Du CD";
rm -R "$ALBUMNAME"
eject $DEVICE
echo "$VERTCLAIR Opération Abandonnée $VERTCLAIR"
exit
fi
## CRÉATION DU FICHIER CUE
read -p "Créer Le Fichier CUE ? (y/n)" reply
choice=$(echo $reply)
if [ "$choice" = 'y' ]; then
echo "$VERTCLAIR Création Du Fichier CUE ...$NORMAL";
cueconvert -i toc -o cue "$ALBUMNAME.toc" "$ALBUMNAME.cue"
mv "$ALBUMNAME.cue" "$ALBUMNAME"
elif [ "$choice" = 'n' ]; then
echo "$VERTCLAIR Étape Suivante ...$NORMAL";
fi
## DÉPLACEMENT DES 2 FICHIERS DANS LE DOSSIER
mv "$ALBUMNAME.bin" "$ALBUMNAME"
mv "$ALBUMNAME.toc" "$ALBUMNAME"
## GRAVAGE
read -p "Lancer La Gravure ? (y/n)" reply
choice=$(echo $reply)
if [ "$choice" = 'y' ]; then
eject $DEVICE
echo "Insérez Un CD Vierge Dans Le Lecteur Et Appuyer Sur La Touche [Entrée]"
read touche
case $touche in
*) echo "$VERTCLAIR Chargement Du CD ...$NORMAL" ;;
esac
eject -t $DEVICE
elif [ "$choice" = 'n' ]; then
echo "$VERTCLAIR Opération Terminée $NORMAL";
eject $DEVICE
exit
fi
echo "$VERTCLAIR Vérification Que Le Support Présent Dans Le Lecteur Est Bien Vide ...$NORMAL"
#cdrdao disk-info /dev/sr0 2>&1| grep 'empty ' | grep yes && cdrdao disk-info /dev/sr0 2>&1| grep 'CD-RW ' | grep yes ;
cdrdao disk-info $DEVICE 2>&1| grep 'empty ' | grep yes ;
STATUS=$?
while [ $STATUS != "0" ] ; do
echo "Ce Support Contient Des Données"
read -p "Faut-il [C]hanger Le Disque , [E]ffacer Ce CD Ou [A]bandonner La Gravure ? (c/e/a)" reply
choice=$(echo $reply)
if [ "$choice" = 'c' ]; then
echo "$VERTCLAIR Éjection Du CD $VERTCLAIR";
eject $DEVICE
echo "Charger Un Nouveau Support et Appuyer Sur [Entrée]"
read touche
case $touche in
*) echo "$VERTCLAIR Fermeture ...$NORMAL" ;;
esac
eject -t $DEVICE
sleep 17
elif [ "$choice" = 'e' ]; then
echo "$VERTCLAIR Effacement En Cours ...$NORMAL";
cdrdao blank –device $DEVICE –blank-mode minimal
elif [ "$choice" = 'a' ]; then
echo "Abandon Par L'utilateur - Opération Terminée. ";
eject $DEVICE
exit
fi
cdrdao disk-info $DEVICE 2>&1 | grep 'empty' | grep yes ;
STATUS=$?
done
echo "Le CD Est Vide : OK"
read -p "Graver le CD Maintenant ? (y/n)" reply
choice=$(echo $reply)
if [ "$choice" = 'y' ]; then
echo "$VERTCLAIR Création Du CD-Audio ...$NORMAL";
#cdrdao write --device $DEVICE --driver generic-mmc-raw audiocd.toc ;
cdrdao write --device $DEVICE --driver generic-mmc-raw "$ALBUMNAME/$ALBUMNAME.toc" ;
elif [ "$choice" = 'n' ]; then
echo "$VERTCLAIR Éjection Du CD $NORMAL";
eject $DEVICE
exit
fi
eject $DEVICE
exit
Dernière modification par kholo (Le 15/11/2016, à 19:05)
Hors ligne