-
Notifications
You must be signed in to change notification settings - Fork 4
/
play
executable file
·117 lines (99 loc) · 2.65 KB
/
play
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/bin/bash
export PATH="$PATH:/usr/local/bin"
function trap_ctrlc () {
printf "\n"
if docker ps &> /dev/null; then
echo "[*] quitting iina..."
osascript -e 'quit app "IINA"' &> /dev/null
if docker top $name &> /dev/null; then
echo "[*] stopping server..."
docker stop $name &> /dev/null || true
fi
echo "[*] quitting docker..."
if [ "$homebrew_mode" = true ]; then
docker-machine stop default &> /dev/null
else
osascript -e 'quit app "Docker"' 1> /dev/null
fi
fi
exit 2
}
trap "trap_ctrlc" 2
function helptext {
scr=$(basename $0)
echo "USAGE: ./$scr <Acestream ID>"
}
[ -z "$1" ] && helptext && exit 0
if ! ls /Applications/ | grep -qi IINA
then
echo "[!] Error! IINA not found, get it at https://iina.io"
exit 1
fi
homebrew_mode=false
if ! ls /Applications/ | grep -qi Docker; then
if [ -x "$(docker-machine)" ]; then
echo '[!] Error! Docker not found, get it at https://www.docker.com or with homebrew'
exit 1
else
echo "[*] Detected Docker installation with homebrew (docker-machine)"
homebrew_mode=true
fi
else
echo "[*] Detected desktop-based Docker installation"
fi
image="blaiseio/acelink:1.3.0"
name="acelink--ace-stream-server"
port="6878"
# remove "acestream://" from arg if found at the beginning
full=$1
prefix="acestream://"
hash=${full/#$prefix}
# Start Docker if not running
printf "[*] starting docker"
if [ "$homebrew_mode" = true ]; then
# Assuming docker-machine is correctly set up and working
docker-machine start default &> /dev/null
docker-machine env default &> /dev/null
eval $(docker-machine env default)
else
if ! docker ps &> /dev/null; then
open --background --hide -a Docker
fi
fi
# Wait until Docker runs
until docker ps &> /dev/null; do
printf "."
sleep 0.5
done
printf "\n"
echo "[*] docker is running"
# Download Docker image if not available
if ! docker image inspect $image &> /dev/null; then
echo "[*] pulling docker image ${image}"
docker pull $image
fi
ip_address="127.0.0.1"
if [ "$homebrew_mode" = true ]; then
ip_address=$(docker-machine ip)
fi
# Start Ace Stream server if not running
if ! nc -z $ip_address $port &> /dev/null; then
printf "[*] starting Ace Stream server"
docker run -d --rm -p $port:$port --name=$name $image 1> /dev/null
# Wait until Ace Stream server runs
until curl "http://${ip_address}:${port}/webui/api/service?method=get_version" &> /dev/null; do
printf "."
sleep 0.5
done
printf "\n"
fi
echo "[*] acestream server is running"
# Open stream in IINA
stream="http://$ip_address:${port}/ace/getstream?id=${hash}"
echo "[*] opening stream"
/Applications/IINA.app/Contents/MacOS/iina-cli "${stream}"
# Keep running until CTRL+C
while true
do
sleep 10
done