From 251fc37831d3aa07c0e80c07d98f658b9feb56fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Couchet?= Date: Sat, 25 May 2019 10:11:09 +0200 Subject: [PATCH 01/10] =?UTF-8?q?Ajout=20de=20la=20g=C3=A9n=C3=A9ration=20?= =?UTF-8?q?des=20fichiers=20MP3=20et=20du=20texte=20=C3=A0=20mettre=20dans?= =?UTF-8?q?=20la=20page=20web=20consacr=C3=A9e=20=C3=A0=20l'=C3=A9mission.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- podcasts/scripts/make-all-podcasts.pl | 172 +++++++++++------- .../scripts/make-metadata-image-podcast.sh | 44 ++++- 2 files changed, 146 insertions(+), 70 deletions(-) diff --git a/podcasts/scripts/make-all-podcasts.pl b/podcasts/scripts/make-all-podcasts.pl index 1858a1a..7402473 100755 --- a/podcasts/scripts/make-all-podcasts.pl +++ b/podcasts/scripts/make-all-podcasts.pl @@ -29,6 +29,8 @@ my ($help,$config,$verbose,$dryrun); my $meta_data_script = "lav-outils/podcasts/scripts/make-metadata-image-podcast.sh"; my $verbose; +my $textwebpage="\n\n"; + +binmode(STDOUT, ":utf8"); +print "Pour la page web consacrée à l'émission :\n\n$textwebpage\n\n"; - # hashing - my $command = "sha1sum $source_name.ogg > $source_name.ogg.sha1"; - if($dryrun) { - print "$command\n"; - } else { - my @ret = `$command`; - if($?) { - print "Error while hashing $source_name.ogg\n"; - if($verbose) { - print Dumper @ret; - print Dumper $data; - } - return 0; - } - } } process($config,$verbose,$dryrun); diff --git a/podcasts/scripts/make-metadata-image-podcast.sh b/podcasts/scripts/make-metadata-image-podcast.sh index 22c7e96..e920d88 100755 --- a/podcasts/scripts/make-metadata-image-podcast.sh +++ b/podcasts/scripts/make-metadata-image-podcast.sh @@ -1,6 +1,6 @@ #!/bin/bash - # Copyright (C) 2019 Quentin GIBEAUX +# Copyright (C) 2019 Frédéric Couchet # # This file is part of lav-outils from "April/Libre à vous !" # @@ -19,7 +19,7 @@ usage() { echo "$0 -s source_file -d destination_file -u http://... -t \"title\" -p path/to/ffmpeg/binary"; exit 0; } [ $# -eq 0 ] && usage -while getopts "s:d:u:t:p:h" arg; do +while getopts "s:d:u:t:p:y:h" arg; do case $arg in s) source=${OPTARG} @@ -36,6 +36,10 @@ while getopts "s:d:u:t:p:h" arg; do p) FFmpegBin=${OPTARG} ;; + y) + year=${OPTARG} + ;; + h | *) # Display help. usage exit 0 @@ -55,13 +59,41 @@ if [ ! -f "$FFmpegBin" ]; then fi image="lav-outils/podcasts/images/image-pour-etiqueter-podcast.jpg" -fichiertemp="$(command mktemp -t "tmp.XXXXXXXXXX.ogg")" + +fichiertempogg="$(command mktemp -t "tmp.XXXXXXXXXX.ogg")" +fichiertempmp3="$(command mktemp -t "tmp.XXXXXXXXXX.mp3")" + +text=$(printf "Émission « Libre à vous ! » de l'April diffusée sur radio la « Cause Commune ».\n\nPour en savoir plus https://www.april.org/libre-a-vous et https://cause-commune.fm\n\nAdresse d'origine du fichier audio ${url}\n\nFichier diffusé selon les termes d’au moins une des licences suivantes : licence Art libre version 1.3 ou ultérieure http://artlibre.org/licence/lal/, licence Creative Commons By Sa version 2.0 ou ultérieure http://creativecommons.org/licenses/by-sa/2.0/fr/ et licence GNU FDL version 1.3 ou ultérieure http://www.gnu.org/licenses/fdl-1.3.html.") (echo -en ";FFMETADATA1\nMETADATA_BLOCK_PICTURE=";(i=${image};t=3;m="image/jpeg";eval "w=`identify-im6 "$i"|awk '{g=$3;sub("x"," h=",g);print g;d=$5;gsub(/-.*/,"",d);print " d=" d}'`"; echo -en "\x00\x00\x00\x$(printf '%02x' $t)\x00\x00\x00\x$(printf '%02x' `echo -n "$m"|wc -c`)$m\x00\x00\x00\x00$(printf '%08x' $w|sed 's/../\\x&/g')$(printf '%08x' $h|sed 's/../\\x&/g')$(printf '%08x' $d|sed 's/../\\x&/g')\x00\x00\x00\xff$(printf '%08x' `stat -c '%s' "$i"`|sed 's/../\\x&/g')";cat "$i")|base64 --wrap=0) > i.meta -${FFmpegBin} -y -i ${source} -acodec copy -map 0:0 -map_metadata -1 -metadata title="${title}" -metadata copyright="Diffusée selon les termes d’au moins une des licences suivantes : licence Art libre version 1.3 ou ultérieure http://artlibre.org/licence/lal/, licence Creative Commons By Sa version 2.0 ou ultérieure http://creativecommons.org/licenses/by-sa/2.0/fr/ et licence GNU FDL version 1.3 ou ultérieure http://www.gnu.org/licenses/fdl-1.3.html" -metadata artist="April - Cause Commune" -metadata contact="${url}" ${fichiertemp} +# Generation du fichier OGG avec l'image de pochette (cover) et les métadonnées +${FFmpegBin} -y -i ${source} -acodec copy -map 0:0 -map_metadata -1 -metadata title="${title}" -metadata license="Diffusée selon les termes d’au moins une des licences suivantes : licence Art libre version 1.3 ou ultérieure http://artlibre.org/licence/lal/, licence Creative Commons By Sa version 2.0 ou ultérieure http://creativecommons.org/licenses/by-sa/2.0/fr/ et licence GNU FDL version 1.3 ou ultérieure http://www.gnu.org/licenses/fdl-1.3.html Pour vérifier voir https://www.april.org/libre-a-vous" -metadata artist="April - Cause Commune" -metadata copyright="April - Cause Commune" -metadata genre="Podcast" -metadata contact="https://april.org/libre-a-vous" -metadata description="${text}" ${fichiertempogg} -${FFmpegBin} -y -i ${fichiertemp} -i i.meta -acodec copy -map 0:0 -map_metadata 1 ${destination} +${FFmpegBin} -y -i ${fichiertempogg} -i i.meta -acodec copy -map 0:0 -map_metadata 1 ${destination}.ogg -rm ${fichiertemp} +# Generation du fichier MP3 avec conservation de l'image de pochette (cover), des métadonnées en deux passes + +# Conservation de l'image de pochette (cover) et des métadonnées + +${FFmpegBin} -y -i ${destination}.ogg -map_metadata 0:s:0 ${fichiertempmp3} + +# Passe pour avoir le champ Duration dans le fichier (qui n'est pas présent suite à la conversion de OGG en MP3) + +${FFmpegBin} -y -i ${fichiertempmp3} -acodec copy ${destination}.mp3 + +# Mise à jour des métadonnées pour tenir compte des métadonnées MP3 + +eyeD3 --user-text-frame="LICENSE:" ${destination}.mp3 + +eyeD3 --user-text-frame="comment:" ${destination}.mp3 + +eyeD3 -c "`echo "${text}"|sed '1,$s/.ogg/.mp3/'`" ${destination}.mp3 + +eyeD3 --user-text-frame="WOAF:`echo ${url%.ogg}.mp3`" ${destination}.mp3 + +eyeD3 --text-frame="TCOP:${year} April - Cause Commune Fichier diffusé selon les termes d’au moins une des licences suivantes : licence Art libre version 1.3 ou ultérieure http://artlibre.org/licence/lal/, licence Creative Commons By Sa version 2.0 ou ultérieure http://creativecommons.org/licenses/by-sa/2.0/fr/ et licence GNU FDL version 1.3 ou ultérieure http://www.gnu.org/licenses/fdl-1.3.html. Pour vérifier voir https://www.april.org/libre-a-vous" ${destination}.mp3 + +rm ${fichiertempogg} +rm ${fichiertempmp3} rm i.meta From a6ee3cff73ce595a0f836cb022e64d26902914b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Couchet?= Date: Sat, 25 May 2019 10:22:32 +0200 Subject: [PATCH 02/10] Ajout de l'option pour la conversion mp3 --- ffmpeg-patch/README | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ffmpeg-patch/README b/ffmpeg-patch/README index 8db02d7..4154981 100644 --- a/ffmpeg-patch/README +++ b/ffmpeg-patch/README @@ -8,6 +8,10 @@ Car visiblement le patch ne s'applique plus : sudo apt install yasm +# Pour pouvoir gérer la conversion en mp3 + + apt install libmp3lame-dev + git clone https://github.com/FFmpeg/FFmpeg.git cd FFmpeg @@ -22,6 +26,6 @@ Car visiblement le patch ne s'applique plus : cd .. - ./configure + ./configure --enable-libmp3lame make From 0e9413062791607dbf0e475b2bbf08c80c07deab Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Sat, 25 May 2019 22:40:17 +0200 Subject: [PATCH 03/10] Normalized indent. --- podcasts/scripts/make-all-podcasts.pl | 203 +++++++++++++------------- 1 file changed, 100 insertions(+), 103 deletions(-) diff --git a/podcasts/scripts/make-all-podcasts.pl b/podcasts/scripts/make-all-podcasts.pl index 7402473..69113b3 100755 --- a/podcasts/scripts/make-all-podcasts.pl +++ b/podcasts/scripts/make-all-podcasts.pl @@ -32,9 +32,9 @@ my $verbose; my $textwebpage="
    \n\n"; GetOptions ("help" => \$help, - "config=s" => \$config, - "verbose" => \$verbose, - "dryrun" => \$dryrun); + "config=s" => \$config, + "verbose" => \$verbose, + "dryrun" => \$dryrun); if($help) { usage(); @@ -53,18 +53,18 @@ $0 --config conf_file.json --verbose increase verbosity --dryrun print commands without executing them EOS -; + ; } sub read_config { my ($filename) = @_; my $json_text = do { #read all the file in one shot - open(my $json_fh, '<:encoding(UTF-8)', $filename) - or die("Can't open \$filename\": $!\n"); + open(my $json_fh, '<:encoding(UTF-8)', $filename) + or die("Can't open \$filename\": $!\n"); local $/; - <$json_fh> - }; + <$json_fh> + }; my $json = JSON->new; my $data = $json->decode($json_text); @@ -77,7 +77,7 @@ sub process { my $data = read_config($config); my $short_date = $data->{short_date}; - my $year = substr $short_date,0,4; + my $year = substr $short_date,0,4; my $long_date = $data->{long_date}; my $source_name = "libre-a-vous-$short_date"; my $title = "Libre à vous ! du $long_date sur Cause Commune"; @@ -103,7 +103,7 @@ sub process { return 0; } } - + # putting metadata my $url = "https://media.april.org/audio/radio-cause-commune/libre-a-vous/emissions/$short_date/$source_name-$short_chapter_name.ogg"; my $command = "$meta_data_script -s \"$source_name-$short_chapter_name.ogg\" -d \"output\" -u \"$url\" -t \"$title - Partie $chapter_title\" -p \"$ffmpeg_bin\" -y \"$year\""; @@ -123,70 +123,67 @@ sub process { } } - # Update string for web site - - my $command = "mediainfo --Inform=\"Audio;%Duration/String%\" output.ogg"; + # Update string for web site - if($dryrun) { - print "$command\n"; - } else { - my @ret = `$command`; - if($?) { - print "Error while updating string for web site\n"; - if($verbose) { - print Dumper @ret; - print Dumper $data; - } - return 0; - } else { - chomp($ret[0]); - $ret[0] =~ s/s/secondes/ig; - $ret[0] =~ s/min/minutes/ig; - my $url2 = $url =~ s/\.ogg/\.mp3/r; - $textwebpage = $textwebpage . "
  • $chapter_title (format OGG) (et format MP3) ($ret[0])
  • \n\n"; - } - } - + my $command = "mediainfo --Inform=\"Audio;%Duration/String%\" output.ogg"; + + if($dryrun) { + print "$command\n"; + } else { + my @ret = `$command`; + if($?) { + print "Error while updating string for web site\n"; + if($verbose) { + print Dumper @ret; + print Dumper $data; + } + return 0; + } else { + chomp($ret[0]); + $ret[0] =~ s/s/secondes/ig; + $ret[0] =~ s/min/minutes/ig; + my $url2 = $url =~ s/\.ogg/\.mp3/r; + $textwebpage = $textwebpage . "
  • $chapter_title (format OGG) (et format MP3) ($ret[0])
  • \n\n"; + } + } # renaming to target OGG and MP3 - for my $format ("ogg","mp3") { - my $target_name = "$source_name-$short_chapter_name.$format"; - my $command = "mv output.$format $target_name"; - if($dryrun) { - print "$command\n"; - } else { - my @ret = `$command`; - if($?) { - print "Error while renaming $short_chapter_name.$format\n"; - if($verbose) { - print Dumper @ret; - print Dumper $data; - } - return 0; - } - } + for my $format ("ogg","mp3") { + my $target_name = "$source_name-$short_chapter_name.$format"; + my $command = "mv output.$format $target_name"; + if($dryrun) { + print "$command\n"; + } else { + my @ret = `$command`; + if($?) { + print "Error while renaming $short_chapter_name.$format\n"; + if($verbose) { + print Dumper @ret; + print Dumper $data; + } + return 0; + } + } + # hashing + my $command = "sha1sum $target_name > $target_name.sha1"; + if($dryrun) { + print "$command\n"; + } else { + my @ret = `$command`; + if($?) { + print "Error while hashing $target_name\n"; + if($verbose) { + print Dumper @ret; + print Dumper $data; + } + return 0; + } + } + } - # hashing - my $command = "sha1sum $target_name > $target_name.sha1"; - if($dryrun) { - print "$command\n"; - } else { - my @ret = `$command`; - if($?) { - print "Error while hashing $target_name\n"; - if($verbose) { - print Dumper @ret; - print Dumper $data; - } - return 0; - } - } - } + } - } - - # putting metadata in main podcast my $url = "https://media.april.org/audio/radio-cause-commune/libre-a-vous/emissions/$short_date/$source_name.ogg"; my $command = "$meta_data_script -s \"$source_name.ogg\" -d \"output\" -u \"$url\" -t \"$title\" -p \"$ffmpeg_bin\" -y \"$year\""; @@ -204,45 +201,45 @@ sub process { } } - # renaming to target OGG and MP3 - for my $format ("ogg","mp3") { + # renaming to target OGG and MP3 + for my $format ("ogg","mp3") { - my $command = "mv output.$format $source_name.$format"; - if($dryrun) { - print "$command\n"; - } else { - my @ret = `$command`; - if($?) { - print "Error while renaming $source_name.$format\n"; - if($verbose) { - print Dumper @ret; - print Dumper $data; - } - return 0; - } - } + my $command = "mv output.$format $source_name.$format"; + if($dryrun) { + print "$command\n"; + } else { + my @ret = `$command`; + if($?) { + print "Error while renaming $source_name.$format\n"; + if($verbose) { + print Dumper @ret; + print Dumper $data; + } + return 0; + } + } - # hashing - my $command = "sha1sum $source_name.$format > $source_name.$format.sha1"; - if($dryrun) { - print "$command\n"; - } else { - my @ret = `$command`; - if($?) { - print "Error while hashing $source_name.$format\n"; - if($verbose) { - print Dumper @ret; - print Dumper $data; - } - return 0; - } - } - } + # hashing + my $command = "sha1sum $source_name.$format > $source_name.$format.sha1"; + if($dryrun) { + print "$command\n"; + } else { + my @ret = `$command`; + if($?) { + print "Error while hashing $source_name.$format\n"; + if($verbose) { + print Dumper @ret; + print Dumper $data; + } + return 0; + } + } + } - $textwebpage = $textwebpage . "
\n\n"; + $textwebpage = $textwebpage . "\n\n"; -binmode(STDOUT, ":utf8"); -print "Pour la page web consacrée à l'émission :\n\n$textwebpage\n\n"; + binmode(STDOUT, ":utf8"); + print "Pour la page web consacrée à l'émission :\n\n$textwebpage\n\n"; } From 51a4524feea6221888bbc2cb24378c5dc735b58a Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Sun, 26 May 2019 13:22:33 +0200 Subject: [PATCH 04/10] Added zlib1g package requirement. --- ffmpeg-patch/README | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ffmpeg-patch/README b/ffmpeg-patch/README index 4154981..a3eeb76 100644 --- a/ffmpeg-patch/README +++ b/ffmpeg-patch/README @@ -8,6 +8,10 @@ Car visiblement le patch ne s'applique plus : sudo apt install yasm +# Pour pouvoir gére les PNG en Debian Stable + +apt-get install zlib1g-dev + # Pour pouvoir gérer la conversion en mp3 apt install libmp3lame-dev From bed025d42d6f667075a922c6b7531aa2e7c315d6 Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Sun, 26 May 2019 13:39:13 +0200 Subject: [PATCH 05/10] Added idea to fix future problems. --- ffmpeg-patch/README | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ffmpeg-patch/README b/ffmpeg-patch/README index a3eeb76..8f41401 100644 --- a/ffmpeg-patch/README +++ b/ffmpeg-patch/README @@ -33,3 +33,10 @@ apt-get install zlib1g-dev ./configure --enable-libmp3lame make + + +# Et si ça ne fonctionne pas ? + +En cas de problème, peut-être cela vient-il des paramètres de ./configure. Tenter : + +./configure --enable-libmp3lame --enable-decoder=png --enable-encoder=png From fa2522c41bfb56fa8376e00ae304568d698f8424 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Couchet?= Date: Mon, 27 May 2019 13:33:51 +0200 Subject: [PATCH 06/10] Add --mp3 option to generate MP3 files --- podcasts/scripts/make-all-podcasts.pl | 42 +++++--- .../scripts/make-metadata-image-podcast.sh | 97 ++++++++++--------- 2 files changed, 84 insertions(+), 55 deletions(-) diff --git a/podcasts/scripts/make-all-podcasts.pl b/podcasts/scripts/make-all-podcasts.pl index 69113b3..5a65553 100755 --- a/podcasts/scripts/make-all-podcasts.pl +++ b/podcasts/scripts/make-all-podcasts.pl @@ -29,11 +29,13 @@ my ($help,$config,$verbose,$dryrun); my $meta_data_script = "lav-outils/podcasts/scripts/make-metadata-image-podcast.sh"; my $verbose; -my $textwebpage="
    \n\n"; +my $mp3; +my $textwebpage="
      \n"; GetOptions ("help" => \$help, "config=s" => \$config, - "verbose" => \$verbose, + "mp3" => \$mp3, + "verbose" => \$verbose, "dryrun" => \$dryrun); if($help) { @@ -49,6 +51,7 @@ sub usage { Needs JSON perl library (apt install libjson-perl) $0 --config conf_file.json --config conf_file.json the configuration file containing stuff + --mp3 generate mp3 files --help show this message --verbose increase verbosity --dryrun print commands without executing them @@ -73,7 +76,7 @@ sub read_config { } sub process { - my ($config,$verbose,$dryrun)=@_; + my ($config,$mp3,$verbose,$dryrun)=@_; my $data = read_config($config); my $short_date = $data->{short_date}; @@ -82,7 +85,20 @@ sub process { my $source_name = "libre-a-vous-$short_date"; my $title = "Libre à vous ! du $long_date sur Cause Commune"; my $ffmpeg_bin = $data->{ffmpeg_bin}; - for my $chapter (values @{$data->{chapters}}) { + + my $option_mp3_meta_data_script; + my @formats_files; + + if($mp3) { + @formats_files = qw/ogg mp3/; + $option_mp3_meta_data_script = "yes"; + } + else { + @formats_files = qw/ogg/; + $option_mp3_meta_data_script = "no"; + } + + for my $chapter (values @{$data->{chapters}}) { my $start = $chapter->{start_timestamp}; my $end = $chapter->{end_timestamp}; my $short_chapter_name = $chapter->{short_chapter_name}; @@ -106,7 +122,7 @@ sub process { # putting metadata my $url = "https://media.april.org/audio/radio-cause-commune/libre-a-vous/emissions/$short_date/$source_name-$short_chapter_name.ogg"; - my $command = "$meta_data_script -s \"$source_name-$short_chapter_name.ogg\" -d \"output\" -u \"$url\" -t \"$title - Partie $chapter_title\" -p \"$ffmpeg_bin\" -y \"$year\""; + my $command = "$meta_data_script -s \"$source_name-$short_chapter_name.ogg\" -d \"output\" -u \"$url\" -t \"$title - Partie $chapter_title\" -p \"$ffmpeg_bin\" -y \"$year\" -m \"$option_mp3_meta_data_script\""; if($dryrun) { print "$command\n"; @@ -143,12 +159,12 @@ sub process { $ret[0] =~ s/s/secondes/ig; $ret[0] =~ s/min/minutes/ig; my $url2 = $url =~ s/\.ogg/\.mp3/r; - $textwebpage = $textwebpage . "
    • $chapter_title (format OGG) (et format MP3) ($ret[0])
    • \n\n"; + $textwebpage = $textwebpage . "
    • $chapter_title (format OGG) (et format MP3) ($ret[0])
    • \n"; } } # renaming to target OGG and MP3 - for my $format ("ogg","mp3") { + foreach my $format (@formats_files) { my $target_name = "$source_name-$short_chapter_name.$format"; my $command = "mv output.$format $target_name"; if($dryrun) { @@ -186,7 +202,7 @@ sub process { # putting metadata in main podcast my $url = "https://media.april.org/audio/radio-cause-commune/libre-a-vous/emissions/$short_date/$source_name.ogg"; - my $command = "$meta_data_script -s \"$source_name.ogg\" -d \"output\" -u \"$url\" -t \"$title\" -p \"$ffmpeg_bin\" -y \"$year\""; + my $command = "$meta_data_script -s \"$source_name.ogg\" -d \"output\" -u \"$url\" -t \"$title\" -p \"$ffmpeg_bin\" -y \"$year\" -m \"$option_mp3_meta_data_script\""; if($dryrun) { print "$command\n"; } else { @@ -202,7 +218,7 @@ sub process { } # renaming to target OGG and MP3 - for my $format ("ogg","mp3") { + foreach my $format (@formats_files) { my $command = "mv output.$format $source_name.$format"; if($dryrun) { @@ -239,8 +255,12 @@ sub process { $textwebpage = $textwebpage . "
    \n\n"; binmode(STDOUT, ":utf8"); - print "Pour la page web consacrée à l'émission :\n\n$textwebpage\n\n"; + print "\nText for the web page of the radio program :\n\n$textwebpage\n"; + + if(! $mp3) { + print "MP3 files not generated, please use --mp3 option to generate them\n"; + } } -process($config,$verbose,$dryrun); +process($config,$mp3,$verbose,$dryrun); diff --git a/podcasts/scripts/make-metadata-image-podcast.sh b/podcasts/scripts/make-metadata-image-podcast.sh index e920d88..053a662 100755 --- a/podcasts/scripts/make-metadata-image-podcast.sh +++ b/podcasts/scripts/make-metadata-image-podcast.sh @@ -17,45 +17,50 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -usage() { echo "$0 -s source_file -d destination_file -u http://... -t \"title\" -p path/to/ffmpeg/binary"; exit 0; } -[ $# -eq 0 ] && usage -while getopts "s:d:u:t:p:y:h" arg; do - case $arg in - s) - source=${OPTARG} - ;; - d) - destination=${OPTARG} - ;; - u) - url=${OPTARG} - ;; - t) - title=${OPTARG} - ;; - p) - FFmpegBin=${OPTARG} - ;; - y) - year=${OPTARG} - ;; +usage() { echo "$0 -s source_file -d destination_file -u http://... -t \"title\" -p path/to/ffmpeg/binary -y \"year\" -m \"yes or no\""; exit 0; } - h | *) # Display help. - usage - exit 0 - ;; - esac +[ $# -eq 0 ] && usage + +while getopts "s:d:u:t:p:y:m:h" arg; do + case $arg in + s) + source=${OPTARG} + ;; + d) + destination=${OPTARG} + ;; + u) + url=${OPTARG} + ;; + t) + title=${OPTARG} + ;; + p) + FFmpegBin=${OPTARG} + ;; + y) + year=${OPTARG} + ;; + m) + mp3=${OPTARG} + ;; + h | *) # Display help. + usage + exit 0 + ;; + esac done if [ ! -f $source ]; then - echo "File $source does not exist" - usage - exit 1 + echo "File $source does not exist" + usage + exit 1 fi + if [ ! -f "$FFmpegBin" ]; then - echo "$FFmpegBin is not executable" - usage - exit 1 + echo "$FFmpegBin is not executable" + usage + exit 1 fi image="lav-outils/podcasts/images/image-pour-etiqueter-podcast.jpg" @@ -72,27 +77,31 @@ ${FFmpegBin} -y -i ${source} -acodec copy -map 0:0 -map_metadata -1 -metadata ti ${FFmpegBin} -y -i ${fichiertempogg} -i i.meta -acodec copy -map 0:0 -map_metadata 1 ${destination}.ogg -# Generation du fichier MP3 avec conservation de l'image de pochette (cover), des métadonnées en deux passes +if [ "$mp3" = "yes" ]; then -# Conservation de l'image de pochette (cover) et des métadonnées + # Generation du fichier MP3 avec conservation de l'image de pochette (cover), des métadonnées en deux passes + + # Conservation de l'image de pochette (cover) et des métadonnées -${FFmpegBin} -y -i ${destination}.ogg -map_metadata 0:s:0 ${fichiertempmp3} + ${FFmpegBin} -y -i ${destination}.ogg -map_metadata 0:s:0 ${fichiertempmp3} -# Passe pour avoir le champ Duration dans le fichier (qui n'est pas présent suite à la conversion de OGG en MP3) + # Passe pour avoir le champ Duration dans le fichier (qui n'est pas présent suite à la conversion de OGG en MP3) -${FFmpegBin} -y -i ${fichiertempmp3} -acodec copy ${destination}.mp3 + ${FFmpegBin} -y -i ${fichiertempmp3} -acodec copy ${destination}.mp3 -# Mise à jour des métadonnées pour tenir compte des métadonnées MP3 + # Mise à jour des métadonnées pour tenir compte des métadonnées MP3 -eyeD3 --user-text-frame="LICENSE:" ${destination}.mp3 + eyeD3 --user-text-frame="LICENSE:" ${destination}.mp3 -eyeD3 --user-text-frame="comment:" ${destination}.mp3 + eyeD3 --user-text-frame="comment:" ${destination}.mp3 -eyeD3 -c "`echo "${text}"|sed '1,$s/.ogg/.mp3/'`" ${destination}.mp3 + eyeD3 -c "`echo "${text}"|sed '1,$s/.ogg/.mp3/'`" ${destination}.mp3 -eyeD3 --user-text-frame="WOAF:`echo ${url%.ogg}.mp3`" ${destination}.mp3 + eyeD3 --user-text-frame="WOAF:`echo ${url%.ogg}.mp3`" ${destination}.mp3 -eyeD3 --text-frame="TCOP:${year} April - Cause Commune Fichier diffusé selon les termes d’au moins une des licences suivantes : licence Art libre version 1.3 ou ultérieure http://artlibre.org/licence/lal/, licence Creative Commons By Sa version 2.0 ou ultérieure http://creativecommons.org/licenses/by-sa/2.0/fr/ et licence GNU FDL version 1.3 ou ultérieure http://www.gnu.org/licenses/fdl-1.3.html. Pour vérifier voir https://www.april.org/libre-a-vous" ${destination}.mp3 + eyeD3 --text-frame="TCOP:${year} April - Cause Commune Fichier diffusé selon les termes d’au moins une des licences suivantes : licence Art libre version 1.3 ou ultérieure http://artlibre.org/licence/lal/, licence Creative Commons By Sa version 2.0 ou ultérieure http://creativecommons.org/licenses/by-sa/2.0/fr/ et licence GNU FDL version 1.3 ou ultérieure http://www.gnu.org/licenses/fdl-1.3.html. Pour vérifier voir https://www.april.org/libre-a-vous" ${destination}.mp3 + +fi rm ${fichiertempogg} rm ${fichiertempmp3} From 5c69344b8f13239a24d111d8cfcf2ec991e92c1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Couchet?= Date: Mon, 27 May 2019 13:37:12 +0200 Subject: [PATCH 07/10] Add explanation about --mp3 option --- podcasts/README | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/podcasts/README b/podcasts/README index 0744892..3f05f75 100644 --- a/podcasts/README +++ b/podcasts/README @@ -45,8 +45,13 @@ drwxr-xr-x 5 root root 4096 janv. 16 11:53 lav-outils ] } -* Exécuter le script : +* Exécuter le script sans génération des MP3 (qui prend du temps) le temps de vérifier que les timestamps de découpe des podcasts sont ok + root@raspberrypi:~/libreavous# lav-outils/podcasts/scripts/make-all-podcasts.pl --config lav-outils/podcasts/config/lav-20190115.json +* Une fois que les timestamps de découpe des podcasts sont ok exécuter le script avec la génération des MP3 + +root@raspberrypi:~/libreavous# lav-outils/podcasts/scripts/make-all-podcasts.pl --config lav-outils/podcasts/config/lav-20190115.json --mp3 + * Les podcasts se retrouvent dans le dossier courant From c7306eedc2f2d8dd05eb6c8beae144f2069afd5a Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Wed, 29 May 2019 10:54:54 +0200 Subject: [PATCH 08/10] Added config file about 20190528 recording. --- podcasts/config/lav-20190528.json | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 podcasts/config/lav-20190528.json diff --git a/podcasts/config/lav-20190528.json b/podcasts/config/lav-20190528.json new file mode 100644 index 0000000..3ba43b1 --- /dev/null +++ b/podcasts/config/lav-20190528.json @@ -0,0 +1,31 @@ +{ + "short_date" : "20190528", + "long_date" : "28 mai 2019", + "ffmpeg_bin" : "../FFmpeg/ffmpeg", + "chapters" : [ + { + "start_timestamp" : "00:01:43.13", + "end_timestamp" : "00:15:17.24", + "short_chapter_name" : "chronique-in-code-we-trust-noemie-bergez-rgpd", + "chapter_title" : "Chronique « In code we trust » de Noémie Bergez : le RGPD" + }, + { + "start_timestamp" : "00:17:39.69", + "end_timestamp" : "01:10:56.79", + "short_chapter_name" : "collectivites-et-logiciel-libre", + "chapter_title" : "Collectivités et logiciel libre" + }, + { + "start_timestamp" : "01:16:07.13", + "end_timestamp" : "01:25:05.34", + "short_chapter_name" : "chronique-jouons-collectif-vincent-calame-dis-tu-ne-connaitrais-pas-un-logiciel-libre", + "chapter_title" : "Chronique « Jouons collectif » de Vincent Calame : « Dis, tu ne connaîtrais pas un logiciel libre ? »" + }, + { + "start_timestamp" : "01:25:10.92", + "end_timestamp" : "01:26:49.16", + "short_chapter_name" : "annonces", + "chapter_title" : "Annonces" + } + ] +} From 4d71cd525ec5dd71611066724888c495cfd63d40 Mon Sep 17 00:00:00 2001 From: Christian Pierre MOMON Date: Wed, 29 May 2019 17:49:43 +0200 Subject: [PATCH 09/10] Normalized indent with perltidy -b -bext='/' -t -et 4 -io make-all-podcasts.pl. --- podcasts/scripts/make-all-podcasts.pl | 40 +++++++++++++-------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/podcasts/scripts/make-all-podcasts.pl b/podcasts/scripts/make-all-podcasts.pl index 5a65553..ae8a6e2 100755 --- a/podcasts/scripts/make-all-podcasts.pl +++ b/podcasts/scripts/make-all-podcasts.pl @@ -34,8 +34,8 @@ my $textwebpage="
      \n"; GetOptions ("help" => \$help, "config=s" => \$config, - "mp3" => \$mp3, - "verbose" => \$verbose, + "mp3" => \$mp3, + "verbose" => \$verbose, "dryrun" => \$dryrun); if($help) { @@ -86,19 +86,19 @@ sub process { my $title = "Libre à vous ! du $long_date sur Cause Commune"; my $ffmpeg_bin = $data->{ffmpeg_bin}; - my $option_mp3_meta_data_script; - my @formats_files; - - if($mp3) { - @formats_files = qw/ogg mp3/; - $option_mp3_meta_data_script = "yes"; - } - else { - @formats_files = qw/ogg/; - $option_mp3_meta_data_script = "no"; - } + my $option_mp3_meta_data_script; + my @formats_files; - for my $chapter (values @{$data->{chapters}}) { + if($mp3) { + @formats_files = qw/ogg mp3/; + $option_mp3_meta_data_script = "yes"; + } + else { + @formats_files = qw/ogg/; + $option_mp3_meta_data_script = "no"; + } + + for my $chapter (values @{$data->{chapters}}) { my $start = $chapter->{start_timestamp}; my $end = $chapter->{end_timestamp}; my $short_chapter_name = $chapter->{short_chapter_name}; @@ -164,7 +164,7 @@ sub process { } # renaming to target OGG and MP3 - foreach my $format (@formats_files) { + foreach my $format (@formats_files) { my $target_name = "$source_name-$short_chapter_name.$format"; my $command = "mv output.$format $target_name"; if($dryrun) { @@ -202,7 +202,7 @@ sub process { # putting metadata in main podcast my $url = "https://media.april.org/audio/radio-cause-commune/libre-a-vous/emissions/$short_date/$source_name.ogg"; - my $command = "$meta_data_script -s \"$source_name.ogg\" -d \"output\" -u \"$url\" -t \"$title\" -p \"$ffmpeg_bin\" -y \"$year\" -m \"$option_mp3_meta_data_script\""; + my $command = "$meta_data_script -s \"$source_name.ogg\" -d \"output\" -u \"$url\" -t \"$title\" -p \"$ffmpeg_bin\" -y \"$year\" -m \"$option_mp3_meta_data_script\""; if($dryrun) { print "$command\n"; } else { @@ -218,7 +218,7 @@ sub process { } # renaming to target OGG and MP3 - foreach my $format (@formats_files) { + foreach my $format (@formats_files) { my $command = "mv output.$format $source_name.$format"; if($dryrun) { @@ -257,9 +257,9 @@ sub process { binmode(STDOUT, ":utf8"); print "\nText for the web page of the radio program :\n\n$textwebpage\n"; - if(! $mp3) { - print "MP3 files not generated, please use --mp3 option to generate them\n"; - } + if(! $mp3) { + print "MP3 files not generated, please use --mp3 option to generate them\n"; + } } From 4e5b1108613ef095fa50c25e97ee9ad328556169 Mon Sep 17 00:00:00 2001 From: Christian Pierre MOMON Date: Wed, 29 May 2019 17:50:00 +0200 Subject: [PATCH 10/10] Added cleanindent script. --- podcasts/scripts/cleanindent | 3 +++ 1 file changed, 3 insertions(+) create mode 100755 podcasts/scripts/cleanindent diff --git a/podcasts/scripts/cleanindent b/podcasts/scripts/cleanindent new file mode 100755 index 0000000..718b477 --- /dev/null +++ b/podcasts/scripts/cleanindent @@ -0,0 +1,3 @@ +#!/bin/bash + +perltidy -b -bext='/' -t -et 4 -io make-all-podcasts.pl