#!/bin/bash
cd /root/ztvh
session=$(<user/session)
curl -i -s -X POST -H "Content-Type: application/x-www-form-urlencoded" -H "Accept: application/x-www-form-urlencoded" --cookie "$session" --data "stream_type=hls&https_watch_urls=True&timeshift=10800" https://zattoo.com/zapi/watch/live/vox_deutschland | grep "{" | sed 's/.*"watch_urls": \[{"url": "//g;s/", .*//g;' > work/chlink && PIPE=$(sed '/zahs/{s/https:/http:/g;s/zahs.tv.*/zahs.tv/g;s/\//\\\//g;};/akamaized/{s/https:/http:/g;s/akamaized.net.*/akamaized.net/g;s/\//\\\//g;}' work/chlink) && curl -s $(<work/chlink) | \
grep -E "live-8000|live-5000|live-3000|live-2999|live-1500" | sed "2,5d;s/.*/#\!\/bin\/bash\n\/usr\/bin\/ffmpeg -loglevel fatal -i $PIPE\/& -vcodec copy -acodec copy -f mpegts -tune zerolatency -preset normal -metadata service_name='' pipe:1/g;" > chpipe.sh
bash chpipe.sh