-
Notifications
You must be signed in to change notification settings - Fork 0
/
_radiomhysa,--.play.internet.radio
executable file
·113 lines (102 loc) · 4.47 KB
/
_radiomhysa,--.play.internet.radio
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
#!/usr/bin/env bash
# author: gotbletu (@youtube|github|odysee)
# https://www.youtube.com/user/gotbletu
# desc: fzf internet radio (use playerctl to control)
# demo: https://youtu.be/yfREdXs4H5o
# depend: fzf coreutils util-linux grep sed mpv mpv-mpris playerctl
# reff: get more stations at:
# https://www.radiolineup.com/locate/Los-Angeles-CA
# https://onlineradiobox.com/us/ktwv
# http://laalmanac.com/media/me10.php
# https://directory.shoutcast.com
# https://zeno.fm/search/radio/?query=80s
### example bindings for mpris
# amixer set Master toggle # Shift-F1 = toggle mute
# playerctl --player=mpv volume 0.2- # Shift-F2 = vol down (mpv)
# playerctl --player=mpv volume 0.2+ # Shift-F3 = vol up (mpv)
# playerctl --player=mpv stop # Shift-F4 = quit/stop/exit (mpv)
# playerctl --player=mpv shuffle on # Shift-F5 = shuffle (mpv)
# playerctl --player=mpv previous # Shift-F6 = playlist previous (mpv)
# playerctl --player=mpv play-pause # Shift-F7 = play/pause (mpv)
# playerctl --player=mpv next # Shift-F8 = playlist next (mpv)
# playerctl --player=mpv position 5- # Shift-F9 = seek/rewind (mpv)
# playerctl --player=mpv position 5+ # Shift-F10 = seek/forward (mpv)
generate_example() {
cat <<'EOF' > "$myfile"
[Classical] |Zeno| Mozart,https://zeno.fm/radio/mozart/
[Classical] |Zeno| Beethoven,https://zeno.fm/radio/beethoven/
[Pop] |Zeno| Hits 80s 90s Radio,https://zeno.fm/radio/hits80s90s/
[Pop] |Zeno| 90s Hits Circuito Dance,https://zeno.fm/radio/90s_HITS/
{FM 094.7} <KTWV> [Urban Adult Contemporary] (English) The Wave 94.7 FM,https://live.amperwave.net/manifest/audacy-ktwvfmaac-hlsc.m3u8
{FM 102.7} <KIIS> [Top 40 Contemporary] (English) 102.7 KIIS FM,https://ample.revma.ihrhls.com/zc185/34_nbf03dzxgz6e02/playlist.m3u8
{FM 105.9} <KPWR> [HipHop] (English) Power 106,https://18703.live.streamtheworld.com/KPWRAAC.aac
Alternative (BAGeL Radio),https://ais-sa3.cdnstream1.com/2606_128.aac
American Roots (Boot Liquor - SomaFM),http://somafm.com/bootliquor.pls
Celtic (ThistleRadio - SomaFM),http://somafm.com/thistle.pls
Chillout (Groove Salad - SomaFM),http://somafm.com/startstream=groovesalad.pls
Groove Salad Classic (Early 2000s Ambient),https://somafm.com/gsclassic.pls
n5MD Radio (Ambient and Experimental),https://somafm.com/n5md.pls
Vaporwaves [SomaFM],https://somafm.com/vaporwaves.pls
EOF
}
# use pyradio csv if exist
if [ -f "$HOME/.config/pyradio/stations.csv" ]; then
myfile="$HOME/.config/pyradio/stations.csv"
elif [ -f "$HOME/.config/radiomhysa/stations.csv" ]; then
myfile="$HOME/.config/radiomhysa/stations.csv"
else
myfile="$HOME/.config/radiomhysa/stations.csv"
if [ ! -f "$myfile" ]; then
mkdir -p "$(dirname "$myfile")"
generate_example
fi
fi
export FZF_DEFAULT_OPTS="-e -i --info=hidden --layout=reverse --scroll-off=5 --tiebreak=index --bind 'home:first,end:last,tab:down,shift-tab:up'"
mytui() {
selected="$( grep -nH , "$myfile" | sed -e 's/:/,/' -e 's/:/,/' | \
fzf -d , --with-nth -2 \
--prompt="radiomhysa: " \
--bind "ctrl-o:execute:${EDITOR:-nano} +{2} {1} >/dev/tty" \
--bind "ctrl-f:execute:${EDITOR:-nano} {1} >/dev/tty" \
--bind 'ctrl-x:execute:playerctl --player=mpv stop >/dev/null 2>&1' \
--bind "ctrl-r:reload:grep -nH , $myfile | sed -e 's/:/,/' -e 's/:/,/'" \
--header 'C-x:stop C-o:edit-line C-f:edit-file C-r:reload C-j/k/n/p|tab/shift-tab:navigate'
)"
[ -z "$selected" ] && exit
selected="$(echo "$selected" | cut -d ',' -f4)"
playerctl --player=mpv stop >/dev/null 2>&1
setsid mpv --no-video "$selected" >/dev/null 2>&1 & disown
sleep 0.2
}
helpmsg() {
cat <<EOF
desc: radiomhysa - play internet radio
demo: https://youtu.be/yfREdXs4H5o
depend: fzf coreutils util-linux grep sed mpv mpv-mpris playerctl
usage: ${0##*/} <options>
options:
No argument then start fzf TUI
-l, --list List all stream
-e, --edit Edit radio list
-s, --search Search keyword
-h, --help Show help page
example:
${0##*/}
${0##*/} -s keyword
EOF
}
if [ "$1" = -h ] || [ "$1" = --help ]; then
helpmsg
exit 0
elif [ -z "$1" ]; then
mytui
elif [ "$1" = -l ] || [ "$1" = --list ]; then
cat "$myfile"
elif [ "$1" = -e ] || [ "$1" = --edit ]; then
"$EDITOR" "$myfile"
elif [ "$1" = -s ] || [ "$1" = --search ]; then
grep --color=auto -in "$2" -- "$myfile" 2>/dev/null
else
helpmsg
exit 1
fi