From bf0b2fa8c7c60aaca3a4ec2be9ff1b578f623b1a Mon Sep 17 00:00:00 2001 From: Stefano Date: Sun, 4 May 2025 18:02:08 -0500 Subject: [PATCH] Updated index.html and README --- .vscode/settings.json | 1 + README.md | 114 +++++++++++++++-------- src/static/index.html | 209 +++++++++++++++++++++++++++++++++--------- 3 files changed, 246 insertions(+), 78 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 796ad9f..a8adcde 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,6 +2,7 @@ "cSpell.words": [ "dotenv", "fout", + "gluetun", "levelname", "mpegts", "Referer", diff --git a/README.md b/README.md index a19d09c..9890a5d 100644 --- a/README.md +++ b/README.md @@ -1,30 +1,62 @@ -# streamlink-server +# Streamlink Server -Run your m3u and mpd streams through streamlink with authentication +A powerful streaming proxy server that handles various stream types through Streamlink with authentication support. -## Purpose +## Overview -Convert unstable or incompatible video streams into a format that media players can reliably play and record by processing them through streamlink. +This server provides a secure way to proxy and convert video streams using Streamlink. It supports various streaming protocols and includes features for custom headers, proxy support, and authentication. + +## Key Features + +- Stream conversion using Streamlink +- Authentication protection for all endpoints +- Support for custom HTTP headers +- Proxy server support +- Channel configuration via JSON +- Docker and Docker Compose support +- RESTful API endpoints +- Real-time stream monitoring and recovery +- Support for MPEG-TS output format ## Requirements - Python 3.11 or newer - FFmpeg -- streamlink -- Python packages (install via `pip`): - - FastAPI - - uvicorn - - python-dotenv - - python-multipart +- Streamlink 6.5.0 or newer +- Additional Python packages (installed via requirements.txt): + - FastAPI 0.109.0+ + - uvicorn 0.27.0+ + - python-multipart 0.0.9+ + - python-dotenv 1.0.0 + - typing-extensions 4.9.0+ ## Installation +### Standard Installation + ```bash -git clone https://github.com/purplescorpion1/streamlink-server.git +git clone https://git.fiorinis.com/Home/streamlink-server.git cd streamlink-server pip install -r src/requirements.txt ``` +### Docker Installation + +```bash +docker-compose up -d +``` + +### Hugging Face Spaces Deployment + +The project includes a specialized Dockerfile (`Dockerfile_HF`) optimized for deployment on Hugging Face Spaces. Once you have created the Space, you can create a Dockerfile and past the contents of `Dockerfile_HF` into it. + +This version is specifically configured to run as a Space on huggingface.co, providing: + +- Optimized container size +- Pre-configured environment for Spaces +- Automatic HTTPS handling +- Integration with Hugging Face's monitoring + ## Configuration 1. Create a `.env` file in the project root: @@ -34,7 +66,7 @@ AUTH_USERNAME=your_username AUTH_PASSWORD=your_password ``` -2. Configure your channels in `data/channels.json`: +2. Configure your channels in `data/channels.json`. Example: ```json { @@ -42,45 +74,55 @@ AUTH_PASSWORD=your_password { "id": "1", "name": "Example Channel", - "url": "https://example.com/stream.m3u8" + "url": "https://example.com/stream", + "origin": "https://example.com", + "referer": "https://example.com/player", + "agent": "Mozilla/5.0...", + "proxy": "http://proxy:8080" } ] } ``` -## Usage +## API Endpoints -1. Start the server: +### Stream Endpoints -```bash -python src/stream_link_server.py -``` +- `GET /stream/{channel_id}` - Stream a channel by ID +- `GET /stream/url` - Stream from a custom URL with query parameters -The server will start on port 6090 by default. +### Utility Endpoints -2. Access your streams: +- `GET /utils/channels` - List all available channels +- `POST /utils/generate_url` - Generate encoded streaming URLs -- List all channels: - `http://localhost:6090/channels?username=xxx&password=xxx` -- Stream specific channel: - `http://localhost:6090/{channel_id}?username=xxx&password=xxx` +### Authentication -## Docker Support +All endpoints require authentication via query parameters: -Run with Docker Compose: +- `username`: Your configured username +- `password`: Your configured password -```bash -docker-compose up -d -``` +## Docker Environment Variables -## Environment Variables +- `AUTH_USERNAME`: Authentication username +- `AUTH_PASSWORD`: Authentication password +- `TZ`: Timezone (default: UTC) -- `AUTH_USERNAME`: Username for authentication -- `AUTH_PASSWORD`: Password for authentication -- `PORT`: Server port (default: 6090) +## Stream URL Parameters + +When using the `/stream/url` endpoint: + +- `url`: The source stream URL (required) +- `origin`: Custom Origin header +- `referer`: Custom Referer header +- `agent`: Custom User-Agent header +- `proxy`: Proxy server URL ## Notes -- Make sure streamlink is properly installed and available in your system PATH -- All streams require authentication with username/password -- The server provides a clean HTTP interface for your media players \ No newline at end of file +- All streams are converted to MPEG-TS format for maximum compatibility +- The server includes automatic stream recovery on failures +- Default server port is 6090 +- All API endpoints require authentication +- Docker setup includes optional VPN support via gluetun \ No newline at end of file diff --git a/src/static/index.html b/src/static/index.html index ea185a0..d462467 100644 --- a/src/static/index.html +++ b/src/static/index.html @@ -3,74 +3,199 @@ - MediaFlow Proxy - + Streamlink Server -
- MediaFlow Proxy Logo -

MediaFlow Proxy

-
-

A high-performance proxy server for streaming media, supporting HTTP(S), HLS, and MPEG-DASH with real-time DRM decryption.

+
+ +

Streamlink Server

+

A powerful streaming proxy server that handles various stream types through Streamlink with authentication support

+
-

Key Features

-
Convert MPEG-DASH streams (DRM-protected and non-protected) to HLS
-
Support for Clear Key DRM-protected MPD DASH streams
-
Handle both live and video-on-demand (VOD) DASH streams
-
Proxy HTTP/HTTPS links with custom headers
-
Proxy and modify HLS (M3U8) streams in real-time with custom headers and key URL modifications for bypassing some sneaky restrictions.
-
Protect against unauthorized access and network bandwidth abuses
+
+
+

Overview

+

This server provides a secure way to proxy and convert video streams using Streamlink. It supports various streaming protocols and includes features for custom headers, proxy support, and authentication.

+
-

Getting Started

-

Visit the GitHub repository for installation instructions and documentation.

+
+
+

Key Features

+
    +
  • Stream conversion using Streamlink
  • +
  • Authentication protection for all endpoints
  • +
  • Support for custom HTTP headers
  • +
  • Proxy server support
  • +
  • Channel configuration via JSON
  • +
  • Docker and Docker Compose support
  • +
  • RESTful API endpoints
  • +
  • Real-time stream monitoring and recovery
  • +
  • Support for MPEG-TS output format
  • +
+
-

Premium Hosted Service

-

For a hassle-free experience, check out premium hosted service on ElfHosted.

+
+

Requirements

+
    +
  • Python 3.11 or newer
  • +
  • FFmpeg
  • +
  • Streamlink 6.5.0 or newer
  • +
  • FastAPI 0.109.0+
  • +
  • uvicorn 0.27.0+
  • +
  • python-multipart 0.0.9+
  • +
  • python-dotenv 1.0.0
  • +
  • typing-extensions 4.9.0+
  • +
+
+
-

API Documentation

-

Explore the Swagger UI for comprehensive details about the API endpoints and their usage.

+
+

API Endpoints

+ +
+

Stream Endpoints

+ GET /stream/{channel_id} - Stream a channel by ID
+ GET /stream/url - Stream from a custom URL with query parameters +
+
+

Utility Endpoints

+ GET /utils/channels - List all available channels
+ POST /utils/generate_url - Generate encoded streaming URLs +
+
+ +
+

Installation Methods

+ +
+

Standard Installation

+
git clone https://git.fiorinis.com/Home/streamlink-server.git
+ cd streamlink-server
+ pip install -r src/requirements.txt
+ +

Docker Installation

+
docker-compose up -d
+ +

Hugging Face Spaces

+

Use the provided Dockerfile_HF for deployment on Hugging Face Spaces with:

+
    +
  • Optimized container size
  • +
  • Pre-configured environment for Spaces
  • +
  • Automatic HTTPS handling
  • +
  • Integration with Hugging Face's monitoring
  • +
+
+
+ +
+

Documentation

+

For detailed API documentation and interactive testing, visit the Swagger UI.

+

For the OpenAPI specification, visit OpenAPI JSON.

+
+
\ No newline at end of file