From 0d43176adf124d7eb48374ff62fa964c3689173d Mon Sep 17 00:00:00 2001 From: Bram Kelchtermans Date: Wed, 16 Apr 2025 20:46:48 +0200 Subject: [PATCH] ip tv filter --- Dockers/iptv-filter/Dockerfile | 7 +++++++ Dockers/iptv-filter/README.md | 21 +++++++++++++++++++++ Dockers/iptv-filter/iptv-boxsets.php | 8 ++++++++ Dockers/iptv-filter/iptv-boxsets.sh | 18 ++++++++++++++++++ Dockers/iptv-filter/iptv-tv.php | 8 ++++++++ Dockers/iptv-filter/iptv-tv.sh | 21 +++++++++++++++++++++ Dockers/iptv-filter/version | 1 + Dockers/iptv-filter/vhost.conf | 9 +++++++++ 8 files changed, 93 insertions(+) create mode 100644 Dockers/iptv-filter/Dockerfile create mode 100644 Dockers/iptv-filter/README.md create mode 100644 Dockers/iptv-filter/iptv-boxsets.php create mode 100755 Dockers/iptv-filter/iptv-boxsets.sh create mode 100644 Dockers/iptv-filter/iptv-tv.php create mode 100755 Dockers/iptv-filter/iptv-tv.sh create mode 100644 Dockers/iptv-filter/version create mode 100644 Dockers/iptv-filter/vhost.conf diff --git a/Dockers/iptv-filter/Dockerfile b/Dockers/iptv-filter/Dockerfile new file mode 100644 index 0000000..907ca7c --- /dev/null +++ b/Dockers/iptv-filter/Dockerfile @@ -0,0 +1,7 @@ +FROM php:7.2-apache + +COPY . /var/www/html +COPY vhost.conf /etc/apache2/sites-available/000-default.conf + +EXPOSE 80 +RUN chown -R www-data:www-data /var/www/html && a2enmod rewrite \ No newline at end of file diff --git a/Dockers/iptv-filter/README.md b/Dockers/iptv-filter/README.md new file mode 100644 index 0000000..895eb51 --- /dev/null +++ b/Dockers/iptv-filter/README.md @@ -0,0 +1,21 @@ +# IPTV M3U filter + +A simple web server that will download an M3U file, at most once a day, and filter that file down to selected groups. + +## Docker + +To build and run the docker image use: + + docker build -t iptv-filter . + docker run -itd --name iptv-filter -p 81:80 iptv-filter + +You can connect to the container with: + + docker exec -it iptv-filter /bin/bash + +## Docker - Raspberry Pi + +To build the image on a Raspberry Pi, use: + + docker build -f Dockerfile.rpi -t iptv-filter . + docker run -itd --name iptv-filter -p 81:80 iptv-filter diff --git a/Dockers/iptv-filter/iptv-boxsets.php b/Dockers/iptv-filter/iptv-boxsets.php new file mode 100644 index 0000000..7fec8c0 --- /dev/null +++ b/Dockers/iptv-filter/iptv-boxsets.php @@ -0,0 +1,8 @@ + /tmp/iptv-boxsets.m3u'); + +header("Content-Description: File Transfer"); +header("Content-Type: application/octet-stream"); +header("Content-Disposition: attachment; filename=\"iptv-boxsets.m3u\""); +readfile("/tmp/iptv-boxsets.m3u"); +?> \ No newline at end of file diff --git a/Dockers/iptv-filter/iptv-boxsets.sh b/Dockers/iptv-filter/iptv-boxsets.sh new file mode 100755 index 0000000..5a7e7f9 --- /dev/null +++ b/Dockers/iptv-filter/iptv-boxsets.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +m3u_src="http://iptv.example.com/iptv.m3u" +m3u_file=/tmp/iptv-`date +%Y%m%d`.m3u + +if [ ! -f "$m3u_file" ]; then + # Delete files downloaded over seven days ago. + find /tmp/iptv-* -mtime +7 -exec rm {} \; + + # Download the m3u files. + curl -s $m3u_src --output $m3u_file +fi + +echo "#EXTM3U" +grep -E "^#EXTINF.*group\-title=\"\|EN\| SERIES" -A 1 $m3u_file | sed "/^--$/d" +grep -E "^#EXTINF.*group\-title=\"\|EN.+MOVIES" -A 1 $m3u_file | sed "/^--$/d" + +exit 0 \ No newline at end of file diff --git a/Dockers/iptv-filter/iptv-tv.php b/Dockers/iptv-filter/iptv-tv.php new file mode 100644 index 0000000..50e2e03 --- /dev/null +++ b/Dockers/iptv-filter/iptv-tv.php @@ -0,0 +1,8 @@ + /tmp/iptv-tv.m3u'); + +header("Content-Description: File Transfer"); +header("Content-Type: application/octet-stream"); +header("Content-Disposition: attachment; filename=\"iptv-tv.m3u\""); +readfile("/tmp/iptv-tv.m3u"); +?> \ No newline at end of file diff --git a/Dockers/iptv-filter/iptv-tv.sh b/Dockers/iptv-filter/iptv-tv.sh new file mode 100755 index 0000000..84d0a51 --- /dev/null +++ b/Dockers/iptv-filter/iptv-tv.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +m3u_src="http://iptv.example.com/iptv.m3u" +m3u_file=/tmp/iptv-`date +%Y%m%d`.m3u + +if [ ! -f "$m3u_file" ]; then + # Delete files downloaded over seven days ago. + find /tmp/iptv-* -mtime +7 -exec rm {} \; + + # Download the m3u files. + curl -s $m3u_src --output $m3u_file +fi + +echo "#EXTM3U" +grep -E '^#EXTINF.*group\-title=\"IRE' -A 1 $m3u_file | sed "/^--$/d" +grep -E '^#EXTINF.*group\-title=\"UK\|' -A 1 $m3u_file | sed "/^--$/d" +grep -E '^#EXTINF.*group\-title=\"USA' -A 1 $m3u_file | sed "/^--$/d" +grep -E '^#EXTINF.*group\-title=\"CA' -A 1 $m3u_file | sed "/^--$/d" +grep -E '^#EXTINF.*group\-title=\"SP' -A 1 $m3u_file | sed "/^--$/d" + +exit 0 \ No newline at end of file diff --git a/Dockers/iptv-filter/version b/Dockers/iptv-filter/version new file mode 100644 index 0000000..b9bc2fd --- /dev/null +++ b/Dockers/iptv-filter/version @@ -0,0 +1 @@ +latest \ No newline at end of file diff --git a/Dockers/iptv-filter/vhost.conf b/Dockers/iptv-filter/vhost.conf new file mode 100644 index 0000000..8fcb6ab --- /dev/null +++ b/Dockers/iptv-filter/vhost.conf @@ -0,0 +1,9 @@ + + DocumentRoot /var/www/html + + + AllowOverride all + Require all granted + DirectoryIndex iptv-tv.php + + \ No newline at end of file