I'm trying to use Termux widget to launch scripts launching Streamlink with different URLs to see different streams, but I find some issues.
The specific script is this one:
~/.shortcuts $ cat NASA.sh
#!/bin/bash
slink www.youtube.com/NASA/live best
What is slink? It's a workaround to make streamlink work. I explain that below in additional information.
If i run it in Termux terminal, it works normally:
~/.shortcuts $ ./NASA.sh
[cli][info] Found matching plugin youtube for URL www.youtube.com/NASA/live
[cli][info] Available streams: 144p (worst), 240p, 360p, 480p, 720p (best)
[cli][info] Starting server, access with one of:
[cli][info] http://127.0.0.1:4567/
HTTP/1.1 200 OK
Server: Streamlink
Content-Type: video/unknown
Starting: Intent { act=android.intent.action.VIEW dat=http://127.0.0.1:4567/... cmp=org.videolan.vlc/.gui.video.VideoPlayerActivity }
[cli][info] Got HTTP request from VLC/3.0.18 LibVLC/3.0.18
[cli][info] Opening stream: 720p (hls)
( ... )
However, if I use it directly in the widget, it shows this instead:
/data/data/com.termux/files/home/.shortcuts/NASA.sh: line 2: /data/data/com.termux/files/usr/bin/slink: cannot execute: required file not found
[Process completed (code 127) - press Enter]
An important thing to note: If instead of using that slink script, i launch directly streamlink (streamlink www.youtube.com/NASA/live best) in my widget shortcuts, IT WORKS. So is something with the script itself, not streamlink.
Create a shorcut for the Termux Widget with any stream URL, for example:
~/.shortcuts $ cat NASA.sh
#!/bin/bash
slink www.youtube.com/NASA/live best
Run it from the Widget.
Expected behavior
It should run exactly the same as when you run it from the termux terminal.
Additional information
I used this guide, because you can't use streamlink directly inside Termux without some issues and because streamlink is not officially supported in Android you only can set some workarounds. The main issue there is you need to maintain streamlink alive because as you launch VLC through am, and am launchs it and directly closes, streamlinkthinks that the player has been closed and stops streaming to VLC is still there playing (and suddenly VLC closes a few second later when there is no more bytes from the stream to show).
The script is in the guide but I can copy it here:
#!/bin/bash
set -e
INTERFACE=${INTERFACE:-127.0.0.1}
PORT=${PORT:-4567}
PLAYER=${PLAYER:-org.videolan.vlc/org.videolan.vlc.gui.video.VideoPlayerActivity}
streamlink "$@" \
--player-external-http \
--player-external-http-interface "${INTERFACE}" \
--player-external-http-port "${PORT}" \
&
slpid=$!
trap "kill ${slpid} 2>/dev/null" EXIT
while ! curl --output /dev/null --silent --head --fail "http://${INTERFACE}:${PORT}"; do
sleep 0.1
done
am start \
-n "${PLAYER}" \
-a android.intent.action.VIEW \
-d "http://${INTERFACE}:${PORT}"
read -n1 -s
# or run: wait $slpid
Like i said above, if instead of using this script, I try to launch using streamlink itself in the shortcut widget script, it has that issue about closing itself prematurely but it launches from the Termux Widget without problem.
Both scripts are in /data/data/com.termux/files/usr/bin/ to make it easy to launch them everywhere:
$ ls -l /data/data/com.termux/files/usr/bin/s*link
-rwxr-xr-x 1 u0_a656 everybody 569 May 11 21:05 /data/data/com.termux/files/usr/bin/slink
-rwxr-xr-x 1 u0_a656 u0_a656 248 May 17 23:57 /data/data/com.termux/files/usr/bin/streamlink
Hello
Problem description
I'm trying to use Termux widget to launch scripts launching
Streamlink
with different URLs to see different streams, but I find some issues. The specific script is this one:What is
slink
? It's a workaround to makestreamlink
work. I explain that below in additional information.If i run it in Termux terminal, it works normally:
However, if I use it directly in the widget, it shows this instead:
An important thing to note: If instead of using that slink script, i launch directly
streamlink
(streamlink www.youtube.com/NASA/live best
) in my widget shortcuts, IT WORKS. So is something with the script itself, notstreamlink
.Steps to reproduce
streamlink
in termux.Expected behavior
It should run exactly the same as when you run it from the termux terminal.
Additional information
I used this guide, because you can't use
streamlink
directly inside Termux without some issues and becausestreamlink
is not officially supported in Android you only can set some workarounds. The main issue there is you need to maintainstreamlink
alive because as you launch VLC througham
, andam
launchs it and directly closes,streamlink
thinks that the player has been closed and stops streaming to VLC is still there playing (and suddenly VLC closes a few second later when there is no more bytes from the stream to show).The script is in the guide but I can copy it here:
Like i said above, if instead of using this script, I try to launch using
streamlink
itself in the shortcut widget script, it has that issue about closing itself prematurely but it launches from the Termux Widget without problem.Both scripts are in
/data/data/com.termux/files/usr/bin/
to make it easy to launch them everywhere:Specs:
Thanks!