Ajout de la génération des fichiers MP3 et du texte à mettre dans la
page web consacrée à l'émission.
This commit is contained in:
parent
5e9eea186b
commit
251fc37831
@ -29,6 +29,8 @@ my ($help,$config,$verbose,$dryrun);
|
|||||||
my $meta_data_script = "lav-outils/podcasts/scripts/make-metadata-image-podcast.sh";
|
my $meta_data_script = "lav-outils/podcasts/scripts/make-metadata-image-podcast.sh";
|
||||||
|
|
||||||
my $verbose;
|
my $verbose;
|
||||||
|
my $textwebpage="<ul>\n\n";
|
||||||
|
|
||||||
GetOptions ("help" => \$help,
|
GetOptions ("help" => \$help,
|
||||||
"config=s" => \$config,
|
"config=s" => \$config,
|
||||||
"verbose" => \$verbose,
|
"verbose" => \$verbose,
|
||||||
@ -75,6 +77,7 @@ sub process {
|
|||||||
my $data = read_config($config);
|
my $data = read_config($config);
|
||||||
|
|
||||||
my $short_date = $data->{short_date};
|
my $short_date = $data->{short_date};
|
||||||
|
my $year = substr $short_date,0,4;
|
||||||
my $long_date = $data->{long_date};
|
my $long_date = $data->{long_date};
|
||||||
my $source_name = "libre-a-vous-$short_date";
|
my $source_name = "libre-a-vous-$short_date";
|
||||||
my $title = "Libre à vous ! du $long_date sur Cause Commune";
|
my $title = "Libre à vous ! du $long_date sur Cause Commune";
|
||||||
@ -103,10 +106,12 @@ sub process {
|
|||||||
|
|
||||||
# putting metadata
|
# 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 $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.ogg\" -u \"$url\" -t \"$title - Partie $chapter_title\" -p \"$ffmpeg_bin\"";
|
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\"";
|
||||||
|
|
||||||
if($dryrun) {
|
if($dryrun) {
|
||||||
print "$command\n";
|
print "$command\n";
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
my @ret = `$command`;
|
my @ret = `$command`;
|
||||||
if($?) {
|
if($?) {
|
||||||
print "Error while setting metadata in $short_chapter_name\n";
|
print "Error while setting metadata in $short_chapter_name\n";
|
||||||
@ -118,15 +123,41 @@ sub process {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# renaming to target
|
# Update string for web site
|
||||||
my $target_name = "$source_name-$short_chapter_name.ogg";
|
|
||||||
my $command = "mv output.ogg $target_name";
|
my $command = "mediainfo --Inform=\"Audio;%Duration/String%\" output.ogg";
|
||||||
|
|
||||||
if($dryrun) {
|
if($dryrun) {
|
||||||
print "$command\n";
|
print "$command\n";
|
||||||
} else {
|
} else {
|
||||||
my @ret = `$command`;
|
my @ret = `$command`;
|
||||||
if($?) {
|
if($?) {
|
||||||
print "Error while renaming $short_chapter_name\n";
|
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 . "<li><a href=\"$url\">$chapter_title</a> (format OGG) (et <a href=\"$url2\">format MP3</a>) ($ret[0])</li>\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) {
|
if($verbose) {
|
||||||
print Dumper @ret;
|
print Dumper @ret;
|
||||||
print Dumper $data;
|
print Dumper $data;
|
||||||
@ -135,6 +166,7 @@ sub process {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# hashing
|
# hashing
|
||||||
my $command = "sha1sum $target_name > $target_name.sha1";
|
my $command = "sha1sum $target_name > $target_name.sha1";
|
||||||
if($dryrun) {
|
if($dryrun) {
|
||||||
@ -152,9 +184,12 @@ sub process {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# putting metadata in main podcast
|
# 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 $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.ogg\" -u \"$url\" -t \"$title\" -p \"$ffmpeg_bin\"";
|
my $command = "$meta_data_script -s \"$source_name.ogg\" -d \"output\" -u \"$url\" -t \"$title\" -p \"$ffmpeg_bin\" -y \"$year\"";
|
||||||
if($dryrun) {
|
if($dryrun) {
|
||||||
print "$command\n";
|
print "$command\n";
|
||||||
} else {
|
} else {
|
||||||
@ -169,14 +204,16 @@ sub process {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# renaming to target
|
# renaming to target OGG and MP3
|
||||||
my $command = "mv output.ogg $source_name.ogg";
|
for my $format ("ogg","mp3") {
|
||||||
|
|
||||||
|
my $command = "mv output.$format $source_name.$format";
|
||||||
if($dryrun) {
|
if($dryrun) {
|
||||||
print "$command\n";
|
print "$command\n";
|
||||||
} else {
|
} else {
|
||||||
my @ret = `$command`;
|
my @ret = `$command`;
|
||||||
if($?) {
|
if($?) {
|
||||||
print "Error while renaming $source_name\n";
|
print "Error while renaming $source_name.$format\n";
|
||||||
if($verbose) {
|
if($verbose) {
|
||||||
print Dumper @ret;
|
print Dumper @ret;
|
||||||
print Dumper $data;
|
print Dumper $data;
|
||||||
@ -186,13 +223,13 @@ sub process {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# hashing
|
# hashing
|
||||||
my $command = "sha1sum $source_name.ogg > $source_name.ogg.sha1";
|
my $command = "sha1sum $source_name.$format > $source_name.$format.sha1";
|
||||||
if($dryrun) {
|
if($dryrun) {
|
||||||
print "$command\n";
|
print "$command\n";
|
||||||
} else {
|
} else {
|
||||||
my @ret = `$command`;
|
my @ret = `$command`;
|
||||||
if($?) {
|
if($?) {
|
||||||
print "Error while hashing $source_name.ogg\n";
|
print "Error while hashing $source_name.$format\n";
|
||||||
if($verbose) {
|
if($verbose) {
|
||||||
print Dumper @ret;
|
print Dumper @ret;
|
||||||
print Dumper $data;
|
print Dumper $data;
|
||||||
@ -202,4 +239,11 @@ sub process {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$textwebpage = $textwebpage . "</ul>\n\n";
|
||||||
|
|
||||||
|
binmode(STDOUT, ":utf8");
|
||||||
|
print "Pour la page web consacrée à l'émission :\n\n$textwebpage\n\n";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
process($config,$verbose,$dryrun);
|
process($config,$verbose,$dryrun);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Copyright (C) 2019 Quentin GIBEAUX <qgibeaux@april.org>
|
# Copyright (C) 2019 Quentin GIBEAUX <qgibeaux@april.org>
|
||||||
|
# Copyright (C) 2019 Frédéric Couchet <fcouchet@april.org>
|
||||||
#
|
#
|
||||||
# This file is part of lav-outils from "April/Libre à vous !"
|
# 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; }
|
usage() { echo "$0 -s source_file -d destination_file -u http://... -t \"title\" -p path/to/ffmpeg/binary"; exit 0; }
|
||||||
[ $# -eq 0 ] && usage
|
[ $# -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
|
case $arg in
|
||||||
s)
|
s)
|
||||||
source=${OPTARG}
|
source=${OPTARG}
|
||||||
@ -36,6 +36,10 @@ while getopts "s:d:u:t:p:h" arg; do
|
|||||||
p)
|
p)
|
||||||
FFmpegBin=${OPTARG}
|
FFmpegBin=${OPTARG}
|
||||||
;;
|
;;
|
||||||
|
y)
|
||||||
|
year=${OPTARG}
|
||||||
|
;;
|
||||||
|
|
||||||
h | *) # Display help.
|
h | *) # Display help.
|
||||||
usage
|
usage
|
||||||
exit 0
|
exit 0
|
||||||
@ -55,13 +59,41 @@ if [ ! -f "$FFmpegBin" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
image="lav-outils/podcasts/images/image-pour-etiqueter-podcast.jpg"
|
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
|
(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
|
rm i.meta
|
||||||
|
Loading…
Reference in New Issue
Block a user