Ich glotz TV

Well, actually I've essentially stopped watching linear TV about 20 years ago. My Loewe CRT TV set I'd bought in 1994 didn't take kindly to that and twice suffered from dried-up electrolyte capacitors. “You have to switch on the TV at least sometimes”, said the electronics guy who repaired the set. When it happened the third time, I didn't bother anymore, but lived without dedicated TV set for the next 5 years. My first flat-screen TV purchased in 2010 suffered the same fate when it all of a sudden developed dead pixel rows, resulting in a rapidly increasing number of black lines across the display.

It was not until 2018 when I finally gave in and bought a new TV set with the explicit purpose to enjoy the FIFA World Cup held this year. You all know that from a German perspective, this word cup was as much of a disaster as the following one in 2022. Regardless, the 65" QLED panel with three-sided ambilight is perfect for enjoying the occasional movie from my NAS or Amazon Prime Video.

This panel creates a high level of immersion due to its sheer size and the light surrounding it, providing a near cinematic experience for movies in FullHD and 4K resolution. For anything else the immersion may be a bit overwhelming, particularly if one is not willing to fully focus on the action displayed. For me, that's often the case when watching a football match, or a documentary on publicly broadcasted TV, and I would prefer to be able to watch the TV channel on my notebook with one eye while doing other stuff in the background.

Instead of a flull-fledged IPTV application such as hypnotix, I thought that a simple script may be more suitable to my needs. The script I've found on archlinux.de was basically just what I needed. I've merely integrated the download of the current URLs (done by a python script by Axel-Erfurt I've reproduced below), cleaned up a bit, and formatted it for zenity. I've also excluded some redundant channels to keep the list from cluttering.


# Original livetv script by tuxnix and Mis,
# see `https://wiki.archlinux.de/title/Live-Tv <https://wiki.archlinux.de/title/Live-Tv>`_
# liveiptvstations.py by Axel-Erfurt,
# see `https://gist.github.com/Axel-Erfurt/5106f9bbef1fca1d63bb74a849607128 <https://gist.github.com/Axel-Erfurt/5106f9bbef1fca1d63bb74a849607128>`_
# Also see `https://wiki.ubuntuusers.de/Internet-TV/Stationen/ <https://wiki.ubuntuusers.de/Internet-TV/Stationen/>`_

script_path="$(dirname "$0")"
script_name="$(basename "$0")"

# Pull down a current list of IPTV channels
liveiptvstations.py > channellist.txt

# Basic formatting
sed -i -e 'N;s/:\n/ /' -e 's/^/FALSE /' channellist.txt
sed -i -e "s/ARD Alpha/ARD.alpha/" -e "s/ARD ONE/ARD.one/" -e "s/MDR Sachsen/MDR/" -e "s/BR Süd/BR/" -e "s/NDR Hamburg/NDR/" -e "s/RBB Berlin/RBB/" -e "s/SWR BW/SWR/" -e "s/WDR (Deutschland)/WDR/" channellist.txt

# Remove some redundant channels (optional, but beware they need formatting if included)
sed -i -e "/Tagesschau/d" -e "/ARTE.FR/d" -e "/ORF/d" -e "/Brandenburg/d" -e "/Anhalt/d" -e "/Thüringen/d" -e "/Mecklenburg-Vorpommern/d" -e "/Niedersachsen/d" -e "/Schleswig-Holstein/d" -e "/Lokalzeit/d" -e "/weltweit/d" -e "/BR Nord/d" -e "/SWR RP/d" channellist.txt

#create oneliner for zenity
channel_list=$(paste -s -d ' ' channellist.txt)

stream_url=$(zenity --list --title "Live IPTV channels" --text "Choose a channel:" --radiolist  --column "" --column "Channel" --column "URL" --print-column=3 $channel_list)

if(($? == 0)); then
        mpv "${stream_url}"
        exec "${script_path}/${script_name}"
        echo "Leaving LiveTV"
# -*- coding: utf-8 -*-
import requests
import json

# see https://gist.github.com/Axel-Erfurt/5106f9bbef1fca1d63bb74a849607128

url = "https://raw.githubusercontent.com/mediathekview/MServer/master/dist/live-streams.json"

data = requests.get(url).text

js = json.loads(data)

def parse_object_pairs(pairs):
        return pairs

decoder = json.JSONDecoder(object_pairs_hook=parse_object_pairs)
obj = decoder.decode(data)

for value in obj[2:]:
        print(f'{value[1][2].replace(" Livestream", "")}:\n{value[1][8]}')