modify script ydl

This commit is contained in:
Kayn Ty 2021-03-27 10:08:19 +01:00
parent b618dfe7c3
commit 27b82d9d0d
3 changed files with 16 additions and 10 deletions

View File

@ -31,18 +31,19 @@ include( '_head.php' );
// print '[Erreur] pas de commande youtube-dl installée sur ce serveur';
// } else {
$uniqid = time();
$uniqid = date('Y-M-d_').time();
// # exemple url https://peertube.cipherbliss.com/videos/watch/e6a37508-042e-4d83-8598-5d36b764bb3d
exec( './youtube-dl.sh uniqueid_facho https://peertube.cipherbliss.com/videos/watch/b88a9568-517c-4a49-ab07-75c79323a825', $output, $result );
// exec( '.'.$old . '/test.sh ' . $uniqid . ' ' . $url, $output, $result );
// exec( './youtube-dl.sh uniqueid_facho https://peertube.cipherbliss.com/videos/watch/b88a9568-517c-4a49-ab07-75c79323a825', $output, $result );
exec( './youtube-dl.sh ' . $uniqid . ' ' . $url, $output, $result );
echo "<br/> résultat du script. <br>";
var_dump( $result );
echo "<br/> sortie du script. <br>";
var_dump( $output );
if ( $result ) {
echo( '<div class="alert is-danger"> problème de script </div>' );
include( '_foot.php' );
@ -64,7 +65,7 @@ include( '_head.php' );
echo " <br> pas d'url envoyée. Vérifiez le formulaire. <a href='index.php'>Retour</a>";
}
exec( './youtube-dl.sh canadien https://www.youtube.com/watch?v=w97pAEr3svc', $output, $result );
// exec( './youtube-dl.sh canadien https://www.youtube.com/watch?v=w97pAEr3svc', $output, $result );
?>

View File

@ -1,5 +1,6 @@
#!/bin/bash
touch log_ydl.txt
echo " $(date) ###### start conversion __ $1 __ $2" >> log_ydl.txt
UNIQID=$1
mkdir -p ../input/ydl
@ -7,16 +8,20 @@ rm -rf ../input/ydl/$UNIQID.mp3
rm -rf ../input/ydl/$UNIQID
URL=$2
OUTPUT="../input/ydl/$UNIQID.mp3"
youtube-dl --extract-audio --audio-format mp3 --audio-quality 0 --output $OUTPUT $URL
OUTPUT="../input/ydl/$UNIQID/base.mp3"
mkdir ../input/ydl/$UNIQID
ffmpeg -i "../input/ydl/$UNIQID.mp3" -ac 1 "../input/ydl/$UNIQID/$UNIQID.wav"
youtube-dl --extract-audio --audio-format mp3 --audio-quality 0 --output $OUTPUT $URL
ffmpeg -i "../input/ydl/$UNIQID/base.mp3" -ac 1 "../input/ydl/$UNIQID/mono_canal.wav"
cd ..
OUT_DIR="input/ydl/$UNIQID"
python3 ./conversion_simple_fr.py "input/ydl/$UNIQID/$UNIQID.wav" > $OUT_DIR/0_output_$FILE_NAME.json
python3 ./conversion_simple_fr.py $OUT_DIR/mono_canal.wav > $OUT_DIR/0_output_$FILE_NAME.json
jq .text $OUT_DIR/0_output_$FILE_NAME.json > $OUT_DIR/1_converted_$FILE_NAME.txt
sed 's/null//g' $OUT_DIR/1_converted_$FILE_NAME.txt > $OUT_DIR/2_without_nulls_$FILE_NAME.txt
sed 's/^ *//; s/ *$//; /^$/d' $OUT_DIR/2_without_nulls_$FILE_NAME.txt > $OUT_DIR/3_without_nulls_$FILE_NAME.txt
sed 's/\"//g' $OUT_DIR/3_without_nulls_$FILE_NAME.txt > $OUT_DIR/4_phrases_$FILE_NAME.txt
ls -l $OUT_DIR >> log_ydl.txt
echo " $(date) ###### end conversion __ $1 __ $2" >> log_ydl.txt