#!/bin/bash
### https://www.digital-eliteboard.com/threads/autoscript-vavoo-auf-e2.513335/
### On an idea of Clever999 modified by Demosat 30/05/2023
### thx to MasterX, giniman an Oyster for the authkey
vec="hier der VEC einfügen"
authkey="$(curl -k --location --request POST 'https://www.vavoo.tv/api/box/ping2' --header 'Content-Type: application/json' --data "{\"vec\": \"$vec\"}" | sed 's#^.*"signed":"##' | sed "s#\"}}##g" | sed 's/".*//')"
curl -k "https://www2.vavoo.to/live2/index?countries=all&output=json" > vavoo
echo "#EXTM3U" > index
cat vavoo | sed 's/\(}\),/\1}\n,/g' | sed 's/"url":"/"url":\n/g' | sed 's#,{\"group\":#\#EXTINF:-1 group-title=#g' | sed 's#,\"logo.*,\"name\":#,#g' | sed 's/\"}.*//' | sed 's/\",\"tvg.*//' | sed 's#\",\"#\",#g' >> index
mv index index.m3u
for country in Germany Turkey France Albania Arabia Balkans Poland Portugal Spain United Italy; do
cat index.m3u | grep -E -A1 =\"$country > $country.m3u
# file m3u for vlc
echo "#EXTM3U" > vavoo-$country.m3u
cat $country.m3u | sed "s#.ts#.ts?n=1\&b=5\&vavoo_auth="$authkey"#g" | sed '/^#EXTINF/a#EXTVLCOPT:http-user-agent=VAVOO/2.6' >> vavoo-$country.m3u
# file for enigma2
echo "#NAME Vavoo-"$country > /etc/enigma2/userbouquet.vavoo-$country.tv
cat $country.m3u | sed "s#.ts#.ts?n=1\&b=5\&vavoo_auth="$authkey"\#User-Agent=VAVOO/2.6#g" | sed '/^#EXTINF/{h;d}; /^http/G' | sed 's#,#,\#DESCRIPTION #g' | sed 's#^.*,##' | sed 's#:#%3a#g' | sed 's#http#\#SERVICE 4097:0:0:0:0:0:0:0:0:0:http#g' | sed '/--/d; s/#DESCRIPTION/@#DESCRIPTION/g' | sed '$!N;s/\n/ /' | sort -k 4 | sed 's/@/\n/g; s/@//g' >> /etc/enigma2/userbouquet.vavoo-$country.tv
if cat /etc/enigma2/bouquets.tv | grep vavoo-$country > /dev/null 2>&1
then
echo -e Entry bouquets.tv $country available > /dev/null 2>&1
else
echo -e Entry bouquets.tv $country is missing > /dev/null 2>&1
echo "#SERVICE 1:7:1:0:0:0:0:0:0:0:FROM BOUQUET \"userbouquet.vavoo-$country.tv\" ORDER BY bouquet" >> /etc/enigma2/bouquets.tv
fi
rm -rf $country.m3u
done
wget -O - -q "http://127.0.0.1/web/servicelistreload?mode=2" > /dev/null
rm -rf index.m3u
exit 0