#!/bin/bash # title=$(echo "$1" | sed -e 's/.*- //') num=$(echo "$1" | sed -e 's/.*- \(.*\) -.*/\1/') path="/d/hd0/Hoerbuecher/podcasts/tkkg" url=$2 curl=$(curl "$url" | grep 'C' | sed 's/\([0-9][0-9]:[0-9][0-9]:[0-9][0-9]\)/\1\n/g' | sed -e 's/.*215/215/g' | sed -e 's/\(215.*\)<\/td>\(.*\)$/\1\2/g' -e 's/ //g' | grep 215) echo $curl metadata() { chs=0; ni=0; echo \;FFMETADATA1 > metadata.txt ; echo "title=$title" >> metadata.txt ; if [ -z "$url" ]; then for i in ./*.mp3; do echo CHAPTER0$ni=$(date -u -d @$(($chs/1000)) +%H:%M:%S).00; echo CHAPTER0${ni}NAME=$(echo $i | sed -e 's/^\.\/\(.*\).mp3$/\1/'); chs=$(( $chs + $(date -u -d"$(ffmpeg -i "$i" 2>&1 | grep Duration | sed -e 's/.*ion: \(.*\), s.*/\1/')" +%s%N) / 1000000 )); ni=$(($ni+1)) ; done >> metadata.txt else for i in $(echo $curl | sed -e 's//\n/g') ; do echo CHAPTER0$ni=$(date -u -d @$(($chs/1000)) +%H:%M:%S).00; echo CHAPTER0${ni}NAME=$(echo $i | sed -e 's/.*//' -e 's// /g'); chs=$(( $chs + $(date -u -d"$(echo $i | sed -e 's/.*//')" +%s%N) / 1000000 )); ni=$(($ni+1)) ; done >> metadata.txt fi } chaptersxml() { chs=0; echo "" >> chapter.xml echo "$num - $title" >> chapter.xml echo "Episode: $num - $title" >> chapter.xml echo "Episode: $num - $title" >> chapter.xml echo "Episode $num" >> chapter.xml echo "" >> chapter.xml echo "" >> chapter.xml echo "https://podcast.eris.cc/tkkg/$num.opus" >> chapter.xml echo '' >> chapter.xml if [ -z "$url" ]; then for i in ./*.mp3; do echo ""; chs=$(( $chs + $(date -u -d"$(ffmpeg -i "$i" 2>&1 | grep Duration | sed -e 's/.*ion: \(.*\), s.*/\1/')" +%s%N) / 1000000 )); ni=$(($ni+1)) ; done >> chapter.xml else for i in $(echo $curl | sed -e 's//\n/g'); do echo ".*//' -e 's// /g')\"/>"; chs=$(( $chs + $(date -u -d"$(echo $i | sed -e 's/.*//')" +%s%N) / 1000000 )); ni=$(($ni+1)) ; done >> chapter.xml fi echo '' >> chapter.xml echo "$(date -u -d @$(($chs/1000)) +%H:%M:%S)" >> chapter.xml echo "$(date +"%a, %d %B %Y %H:%M:%S %Z")" >> chapter.xml echo "" >> chapter.xml } cd "$1" metadata chaptersxml for f in ./*.mp3; do echo "file '$(echo "$f" | sed "s/'/'\\\''/g" )'" >> mylist.txt ;done ffmpeg -f concat -safe 0 -i mylist.txt -i metadata.txt -map_metadata 1 -codec libopus -vbr on -b:a 128000 "$path/$num.opus" #rm metadata.txt mylist.txt cd ..