From d7f7c4c2637f10379195683e75173e736228b802 Mon Sep 17 00:00:00 2001 From: Shahin Agha-Ghassem Date: Sat, 18 Mar 2023 23:43:05 +0100 Subject: [PATCH] Initial proof of concept --- iptv | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 iptv diff --git a/iptv b/iptv new file mode 100755 index 0000000..b9ef9ae --- /dev/null +++ b/iptv @@ -0,0 +1,36 @@ +#!/bin/bash +m3u=$1 +search=$2 + +echo -en "\nLoading channels... " +OUTPUT=$(curl -s $m3u | grep EXTINF: -A 1 | grep -i "$search" -A 1) +echo -e "Done!\n" + +channels=() +while read line && read line2; do + name=$(echo "$line" | sed -n 's/.*tvg-name="\([^"]*\)".*/\1/p') + url=$line2 + + if [[ -n "$name" ]]; then + channels+=("$name url:$url") + fi +done <<< "$OUTPUT" + +for index in "${!channels[@]}"; do + id=$((index + 1)) + name=$(echo "${channels[$index]}" | sed 's/\(.*\) url:.*/\1/') + + echo "($id) $name" +done + +echo "" + +read -p "Select a channel: " selected +index=$((selected - 1)) + +name=$(echo "${channels[$index]}" | sed 's/\(.*\) url:.*/\1/') +url=$(echo "${channels[$index]}" | grep -oP 'url:\K.*' | tr -d '\r') + +mpv "$URL" > /dev/null 2>&1 & + +echo "Playing $url from $name"