Files
tv-stream/tv-cast
T
2026-10-20 22:12:56 +02:00

25 lines
2.4 KiB
Bash
Executable File

#!/bin/bash
# Bildschirm-Stream auf den Samsung-TV casten.
# Vorher: ~/.local/bin/tv-stream.py muss laufen (der Server).
# Usage: tv-cast start | stop
TV=http://192.168.1.54:9197/upnp/control/AVTransport1
H1='Content-Type: text/xml; charset="utf-8"'
A='SOAPACTION: "urn:schemas-upnp-org:service:AVTransport:1#%s"'
DIDL='<DIDL-Lite xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/"><item id="live" parentID="0" restricted="1"><dc:title>Bildschirm (Live)</dc:title><upnp:class>object.item.videoItem</upnp:class><res protocolInfo="http-get:*:video/mp2t:DLNA.ORG_OP=01;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=01700000000000000000000000000000" size="0">http://192.168.1.36:8081/stream.ts</res></item></DIDL-Lite>'
case "$1" in
start)
DIDL_ESC=$(printf '%s' "$DIDL" | sed -e 's/&/\&amp;/g' -e 's/</\&lt;/g' -e 's/>/\&gt;/g')
curl -s -X POST -H "$H1" -H "SOAPACTION: \"urn:schemas-upnp-org:service:AVTransport:1#SetAVTransportURI\"" \
--data "<?xml version=\"1.0\"?><s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:SetAVTransportURI xmlns:u=\"urn:schemas-upnp-org:service:AVTransport:1\"><InstanceID>0</InstanceID><CurrentURI>http://192.168.1.36:8081/stream.ts</CurrentURI><CurrentURIMetaData>${DIDL_ESC}</CurrentURIMetaData></u:SetAVTransportURI></s:Body></s:Envelope>" "$TV" >/dev/null
curl -s -X POST -H "$H1" -H "SOAPACTION: \"urn:schemas-upnp-org:service:AVTransport:1#Play\"" \
--data '<?xml version="1.0"?><s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:Play xmlns:u="urn:schemas-upnp-org:service:AVTransport:1"><InstanceID>0</InstanceID><Speed>1</Speed></u:Play></s:Body></s:Envelope>' "$TV" >/dev/null
echo "Gecastet — falls der TV fragt, mit OK bestätigen."
;;
stop)
curl -s -X POST -H "$H1" -H "SOAPACTION: \"urn:schemas-upnp-org:service:AVTransport:1#Stop\"" \
--data '<?xml version="1.0"?><s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:Stop xmlns:u="urn:schemas-upnp-org:service:AVTransport:1"><InstanceID>0</InstanceID></u:Stop></s:Body></s:Envelope>' "$TV" >/dev/null
echo "Wiedergabe am TV gestoppt."
;;
*) echo "Usage: tv-cast start|stop (Server: ~/.local/bin/tv-stream.py)"; exit 1;;
esac