Compare commits

...

2 Commits

Author SHA1 Message Date
Jason Tian 258d4cb72a fix the script 2023-03-08 09:30:37 +08:00
Jason Tian 25b5fab6df fix the script 2023-03-08 09:26:00 +08:00
1 changed files with 19 additions and 6 deletions

View File

@ -4,11 +4,24 @@ file="./scripts/duration-length.txt"
if [ -f "$file" ]
then
for i in $(cat $file); do
mp3="https://"$(cat "$i" | grep "^mp3:" | awk -F' ' '{print $2}')
duration=$(ffprobe -i "$mp3" -show_entries format=duration -v quiet -of csv="p=0" -sexagesimal)
length=$(ffprobe -i "$mp3" -show_entries format=size -v quiet -of csv="p=0")
sed -i "s/^duration: .*/duration: \"$duration\"/g" "$i"
sed -i "s/^length: .*/length: $length/g" "$i"
cat "$i"
FIRSTLINE=$(head -n 1 "$i")
if [ ${FIRSTLINE:0:3} == "---" ]
then
mp3="https://"$(cat "$i" | grep "^mp3:" | awk -F' ' '{print $2}')
duration=$(ffprobe -i "$mp3" -show_entries format=duration -v quiet -of csv="p=0" -sexagesimal)
length=$(ffprobe -i "$mp3" -show_entries format=size -v quiet -of csv="p=0")
sed -i "s/^duration: .*/duration: \"$duration\"/g" "$i"
sed -i "s/^length: .*/length: $length/g" "$i"
cat "$i"
fi
if [ ${FIRSTLINE:0:3} == "+++" ]
then
mp3="https://"$(cat "$i" | grep "^mp3 =" | awk -F' ' '{print $2}')
duration=$(ffprobe -i "$mp3" -show_entries format=duration -v quiet -of csv="p=0" -sexagesimal)
length=$(ffprobe -i "$mp3" -show_entries format=size -v quiet -of csv="p=0")
sed -i "s/^duration = .*/duration = \"$duration\"/g" "$i"
sed -i "s/^length = .*/length = $length/g" "$i"
cat "$i"
fi
done
fi