-
Notifications
You must be signed in to change notification settings - Fork 0
/
mediathek
executable file
·64 lines (53 loc) · 1.8 KB
/
mediathek
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
#!/usr/bin/env bash
# play video streams from the ARD mediathek
# get URLs and MEDIATHEK_QUALITY_DEFAULT (the max width of the video)
. ~/.mediathekrc
# re-calculate MEDIATHEK_QUALITY
# environment variable MEDIATHEK_QUALITY overwrites MEDIATHEK_QUALITY_DEFAULT from ~/.mediathekrc
MEDIATHEK_QUALITY="${MEDIATHEK_QUALITY:-$MEDIATHEK_QUALITY_DEFAULT}"
# PROXY: environment variable https_proxy gets propagated into this script
PROXY=${https_proxy:+"--ytdl-raw-options=proxy=[http://${https_proxy}]"}
unset https_proxy # otherwise lynx will also use the proxy
# argument: none
# action: iterate over all stations and print currently played titles
function listing() {
for station in ${!URL[@]}; do
title $station &
done | sort
}
# argument: station
# action: print station name and current title as a one-liner
function title() {
station=$1
stationpadded="$1 "
stationchopped=${stationpadded:0:14}
title=`lynx -width=200 -display_charset=utf-8 -dump ${URL[$station]} | grep -av "^$" | grep -av "^ " | head -2 | tail -1`
echo -e "$stationchopped$title"
}
# argument: station and title
# action: play video
function play() {
station=$1
title=$2
mpv --really-quiet -ao pulse,pipewire --no-osd-bar --title="$title" ${PROXY} --ytdl-format="best[width<=${MEDIATHEK_QUALITY}]/bestvideo[width<=${MEDIATHEK_QUALITY}]+bestaudio" --ytdl ${URL[$station]} 2> /dev/null
}
# main
if [ $# == 0 ]
then
listing
elif [ ${URL[$1]+_} ]
then
station="$1"
# get title
title="$(title $station)"
# play video
echo $title
play "$station" "mediathek $title"
else
echo supported arguments: ${!URL[@]}
echo
echo To enable bash completion of arguments, consider adding this line to your ~/.bashrc:
echo complete -W \"${!URL[@]}\" $0
exit 1
fi
exit 0