Skip to content

idevakk/HLS-Stream-Interceptor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📥 HLS Stream Downloader

A powerful, automated system to intercept secure HLS video streams (.m3u8), extract single-use tokens, and perform multi-threaded downloading and merging of .ts segments into a single video file.

🚀 Features

  • Secure Interception: Captures authenticated stream links directly from the browser's network traffic without "burning" one-time tokens.
  • Smart Pattern Detection: Automatically handles various stream formats (stream_0, 720p, 480p, etc.).
  • Multi-Threaded Downloader: Downloads segments in parallel for maximum speed using cpd.py.
  • Auto-Merge: Verifies all segments and merges them into a final playable .ts video file.
  • Interactive UI: Chrome Extension popup allows you to rename the file before downloading.

🛠️ Architecture

  1. Chrome Extension: Injects a script to spy on network requests. When a video stream is detected, it shows a popup.
  2. Python Bridge (bridge.py): A local Flask server that listens for commands from the extension.
  3. Downloader Core (cpd.py): The engine that handles downloading, retrying, and merging chunks.

📋 Prerequisites

  • Python 3.8+ installed on your system.
  • Google Chrome (or any Chromium-based browser like Edge/Brave).

⚙️ Installation Guide

Step 1: Install Python Dependencies

Open your terminal/command prompt in the project folder and run:

pip install requests flask flask-cors

Step 2: Set Up the Chrome Extension

  1. Create a folder named StreamAutoExtension.
  2. Place the manifest.json, content.js, and injected.js files inside it.
  3. Open Chrome and navigate to chrome://extensions/.
  4. Toggle Developer mode (top right).
  5. Click Load unpacked and select the StreamAutoExtension folder.

📂 File Structure

Ensure your project folder looks like this:

Project_Folder/
│
├── cpd.py                 # Core Downloader Logic
├── bridge.py              # Local Server (The Bridge)
├── README.md              # This file
│
└── StreamAutoExtension/   # Extension Folder
    ├── manifest.json
    ├── content.js
    └── injected.js

🖥️ How to Use

1. Start the Bridge Server

Before opening your browser, start the local listener. This must be running to receive the download command.

python bridge.py

You should see: [*] Bridge Server Running on http://localhost:5555

2. Navigate to Video

  1. Open your browser and log in to the website.
  2. Navigate to the course or video page.
  3. Click the video to start playing.

3. Intercept & Download

  1. A Dark Popup will automatically appear on the screen once the stream is detected.
  2. Edit Filename: You can rename the file (e.g., Biology_Lec_01.ts).
  3. Click Download.
  4. Check your terminal window running bridge.py. You will see the download progress bars.

4. Output

Once finished, the merged video file will appear in the same folder as cpd.py.


🔧 Troubleshooting

Issue Solution
Popup doesn't appear Refresh the page. Ensure the extension is enabled and you clicked the video to play.
"Error: bridge.py is not running" Check your terminal. You must run python bridge.py before clicking download.
Permission Denied / OSError Ensure your filename doesn't contain special characters like ?, :, or `
Download Stuck at 0% The token might have expired. Refresh the page and try again immediately.

📜 Legal Disclaimer

This tool is for educational purposes and personal archiving only. Please respect the copyright and terms of service of the content providers.

About

A secure browser-to-python automation tool for intercepting HLS (.m3u8) streams. Extracts single-use tokens from active browser sessions via Chrome Extension and pipes them to a multi-threaded local downloader for seamless video archiving.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors