blog-howest/content/project/project-1.md
2025-05-29 17:28:25 +02:00

5.7 KiB
Raw Blame History

title, image, date, description, draft
title image date description draft
DRMDTool Project /images/project/project-1.jpg 2025-05-21 00:00:00 +0000 UTC DRMDTool is a complete solution for handling `.drmd` files with automated decryption and downloading via N m3u8DL-RE, watch folder monitoring, and a rich web UI. false

DRMDTool is an automation-centric utility designed to streamline the processing of .drmd files by tightly integrating with the N_m3u8DL-RE downloader. The tool offers robust automation via a watch folder and an intuitive web-based interface, significantly reducing the friction for managing and processing DRM-protected streaming content.


Whats New

DRMDTool has evolved into a comprehensive platform for batch downloading with enhanced support for user interaction and background processing. It features granular job tracking, dynamic download control (pause, resume, abort), and a refined WebSocket-based console for real-time command output. Subtitle handling now includes automatic downloading and conversion from VTT to SRT, and the downloader adapts based on metadata, organizing content into categorized directories.


Goals and Use Case

The primary aim is to automate .drmd file processing with minimal manual input. Users can configure download formats, specify directories, and enable real-time command broadcasting. DRMDTool is suitable for both interactive use through a web UI and headless automation in pipelines, supporting inotify or polling-based folder watching.


How .drmd Files Work

A .drmd file is a structured JSON document that defines one or more encrypted media items to be processed by DRMDTool. It contains an Items array, with each item representing a specific media job. DRMDTool parses these entries to generate download commands for N_m3u8DL-RE.

Each item includes:

  • MPD: A DASH manifest, either a direct URL or a base64-encoded version. If base64-encoded, DRMDTool decodes and temporarily saves it before use.
  • Keys: A comma-separated list of KID:key pairs (e.g., abcd1234ef567890:00112233445566778899aabbccddeeff). These are required for decrypting encrypted media streams and are passed directly to N_m3u8DL-RE using --key flags.
  • Filename: The name to be used for the final output file.
  • Subtitles: Comma-separated list of subtitle URLs in .vtt format. DRMDTool downloads and converts these to .srt, then muxes them into the final file.
  • Metadata: A semicolon-separated string like Title;Type;Season (e.g., Example Show;serie;1) used to determine directory structure (Movies/Title or Series/Title/Season).
  • Description and Poster: Optional fields used only for display in the web UI.

Example .drmd Structure

{
  "Items": [
    {
      "MPD": "aHR0cHM6Ly9leGFtcGxlLmNvbS9zdHJlYW0ubXBk",
      "Keys": "abcd1234ef567890:00112233445566778899aabbccddeeff",
      "Filename": "ExampleShow.S01E01",
      "Subtitles": "https://example.com/sub1.vtt,https://example.com/sub2.vtt",
      "Metadata": "Example Show;serie;1",
      "Description": "Pilot episode",
      "Poster": ""
    }
  ]
}

Processing Steps

  1. Detection: DRMDTool either watches a folder or receives .drmd uploads through the web UI.
  2. Validation: It waits for the file to finish writing (based on file size stability), then parses its contents.
  3. MPD Handling: If base64-encoded, the MPD is decoded and written to a temp file; otherwise, the URL is fetched or passed as-is.
  4. Command Generation: Using the MPD, KID:key pairs, output paths, and subtitles, DRMDTool builds a command line for N_m3u8DL-RE.
  5. Execution: The download is launched with live progress tracking. Users can pause, resume, or abort jobs, and optionally stream console output via WebSocket.

These files serve as portable job definitions. When DRMDTool detects or receives a .drmd file, it parses the items, decodes or downloads the MPD, applies the keys, and builds a download command using N_m3u8DL-RE. Files are saved in organized directories like Movies/Title or Series/Title/Season, and subtitles are embedded if available. Pausing, resuming, and aborting downloads is supported per file.


Architecture Overview

The configuration is handled via config.toml, with environment variable overrides for containerized or dynamic deployments. Once started, the tool can either monitor a specified folder or allow file uploads through the UI. Each .drmd file is parsed, grouped by series and season (if applicable), and processed sequentially with support for job pausing and resuming.


Web UI & CLI

To use:

./drmdtool

Visit http://localhost:8080 for the web interface, which supports drag-and-drop uploads, selection of episodes or movies, and real-time progress tracking. For headless operation:

./drmdtool -f /path/to/file.drmd

Jobs can be paused, resumed, or aborted through the web interface, which reflects the backend state via live updates.


Enhanced Download Logic

DRMDTool dynamically builds download commands using metadata from .drmd files and user preferences. It ensures that only the highest quality streams are kept, removing ad periods and duplicate segments from the MPD files. Subtitles are fetched and embedded automatically. Jobs are tracked with robust state management and logs for debugging and visibility.


Repository

Code and setup instructions are hosted here: https://git.directme.in/Joren/DRMDTool

DRMDtool

For advanced usage details, customization, and API structure, refer to the README.md in the repository.

UI Previews

Index Page

Index Page

Select Page

Select Page

Progress Page

Progress Page