56 lines
3.2 KiB
Bash
56 lines
3.2 KiB
Bash
|
#!/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 '<tbody><tr><td colspan="4" data-behavior="toggle-collapse">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><td>\(.*\)$/\1<del>\2<nl>/g' -e 's/ /<space>/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/<nl>/\n/g') ; do echo CHAPTER0$ni=$(date -u -d @$(($chs/1000)) +%H:%M:%S).00; echo CHAPTER0${ni}NAME=$(echo $i | sed -e 's/<del>.*//' -e 's/<space>/ /g'); chs=$(( $chs + $(date -u -d"$(echo $i | sed -e 's/.*<del>//')" +%s%N) / 1000000 )); ni=$(($ni+1)) ; done >> metadata.txt
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
chaptersxml()
|
||
|
{
|
||
|
chs=0;
|
||
|
echo "<item>" >> chapter.xml
|
||
|
echo "<title>$num - $title</title>" >> chapter.xml
|
||
|
echo "<description>Episode: $num - $title</description>" >> chapter.xml
|
||
|
echo "<itunes:summary>Episode: $num - $title</itunes:summary>" >> chapter.xml
|
||
|
echo "<itunes:subtitle>Episode $num</itunes:subtitle>" >> chapter.xml
|
||
|
echo "<itunesu:category itunesu:code=\"112\"/>" >> chapter.xml
|
||
|
echo "<enclosure url=\"https://podcast.eris.cc/tkkg/$num.opus\" type=\"audio/ogg\" length=\"1\"/>" >> chapter.xml
|
||
|
echo "<guid>https://podcast.eris.cc/tkkg/$num.opus</guid>" >> chapter.xml
|
||
|
echo '<psc:chapters xmlns:psc="http://podlove.org/simple-chapters" version="1.2">' >> chapter.xml
|
||
|
if [ -z "$url" ]; then
|
||
|
for i in ./*.mp3; do echo "<psc:chapter start=\"$(date -u -d @$(($chs/1000)) +%H:%M:%S).000\" title=\"$(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 >> chapter.xml
|
||
|
else
|
||
|
|
||
|
for i in $(echo $curl | sed -e 's/<nl>/\n/g'); do echo "<psc:chapter start=\"$(date -u -d @$(($chs/1000)) +%H:%M:%S).000\" title=\"$(echo $i | sed -e 's/<del>.*//' -e 's/<space>/ /g')\"/>"; chs=$(( $chs + $(date -u -d"$(echo $i | sed -e 's/.*<del>//')" +%s%N) / 1000000 )); ni=$(($ni+1)) ; done >> chapter.xml
|
||
|
fi
|
||
|
echo '</psc:chapters>' >> chapter.xml
|
||
|
echo "<itunes:duration>$(date -u -d @$(($chs/1000)) +%H:%M:%S)</itunes:duration>" >> chapter.xml
|
||
|
echo "<pubDate>$(date +"%a, %d %B %Y %H:%M:%S %Z")</pubDate>" >> chapter.xml
|
||
|
echo "</item>" >> 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 ..
|