Skip to content
euzu edited this page Nov 14, 2023 · 29 revisions

m3u-filter

Some of the m3u-filter features are:

  • filter, raname, map entries of playlists with regular-expressions
  • mimick XTREAM-Server or a M3U-Server with api-endpoints
  • create files for Kodi
  • process one/multiple source(s) and produce one/multiple playlist(s)
  • use templates for filter to avoid repetitions
  • define filter as statements
  • schedule updates
  • send telegram bot messages
  • watch changes in groups and get messages

m3u-filter needs configurations for doing its job. There are three configuration files in yaml format.

  • config.yml
  • mapping.yml
  • api-proxy.yml

config.yml

Is mandatory to run m3u-filter.
Detailled explanation is here.

mapping.yml

Is optional and used for advanced mapping functionality.
Detailled explanation is here.

api-proxy.yml

Is optional and used for api-endpoints for xtream and m3u server mimicking.
Detailled explanation is here.

Program Arguments

Extended M3U playlist filter

Usage: m3u-filter [OPTIONS]

Options:
  -c, --config <CONFIG>        The config file
  -t, --target <TARGET>        The target to process
  -m, --mapping <MAPPING>      The mapping file
  -a, --api-proxy <API_PROXY>  The user file
  -s, --server                 Run in server mode
  -l, --log-level <LOG_LEVEL>  log level
  -h, --help                   Print help
  -V, --version                Print version

m3u-filtersearches in the current directory for the configuration files.
If they are somewhere else you need to specifiy the locations with the arguments -c, -m and -a.

If you run m3u-filterin cli-mode (running from terminal and without the -s argument), you can define specific targets to update with the -t argument. You can write multiple -t arguments.
Target names should be provided in the config. The -t option overrides enabled attributes of input and target elements.
This means, even disabled inputs and targets are processed when the given target name as argument matches a target.

If you run with -s argument, the -t is ignored. This starts m3u-filterin server mode.
In Server mode the Web-UI is accesible through a browser. The port is defined in the config.yml file. The Url should look like http://<IP-Address>:<Port>. You need to replace <IP-Address> and <Port>

Logging

Following log levels are supported:

  • debug
  • info default
  • warn
  • error

Use the -l or -log-level cli-argument to specify the log-level.

Compilation

Static binary for docker

Install prerequisites

rustup update
sudo apt-get install pkg-config musl-tools libssl-dev
rustup target add x86_64-unknown-linux-musl

Build statically linked binary

cargo build --target x86_64-unknown-linux-musl --release

Cross compile for windows on linux

If you want to compile this project on linux for windows, you need to do the following steps.

Install mingw packages for your distribution

For ubuntu type:

sudo apt-get install gcc-mingw-w64

Install mingw support for rust

rustup target add x86_64-pc-windows-gnu
rustup toolchain install stable-x86_64-pc-windows-gnu

Compile it with:

cargo build --release --target x86_64-pc-windows-gnu

Dockerize

Dockerfile

FROM gcr.io/distroless/base-debian12 as build

FROM scratch

WORKDIR /

COPY --from=build /usr/share/zoneinfo /usr/share/zoneinfo
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/

COPY ["./m3u-filter", "./config.yml",  "./api-proxy.yml",  "./mapping.yml", "/"]
COPY ./web /web

CMD ["/m3u-filter", "-s", "-c", "/config.yml"]

Image

docker build -t m3u-filter .

docker-compose.yml

version: '3'
services:
  m3u-filter:
    container_name: m3u-filter
    image: m3u-filter:latest
    working_dir: /
    volumes:
      - ./data:/data
    ports:
      - "8901:8901"
    environment:
      - TZ=Europe/Paris
    restart: unless-stopped

The image should be around 15MB.

m3u-filter$ docker images
REPOSITORY                             TAG       IMAGE ID       CREATED        SIZE
m3u-filter                             latest    c59e1edb9e56   1 day ago     14.6MB
Clone this wiki locally