### Binary Installation: Run Decypharr Executable Source: https://github.com/sirrobot01/decypharr/blob/main/docs/docs/installation.md This bash snippet outlines the steps to run the Decypharr binary after downloading it. It includes making the binary executable and then running it with a specified configuration path. ```bash chmod +x decypharr ./decypharr --config /path/to/config/folder ``` -------------------------------- ### Docker Compose: Setup Decypharr Service Source: https://github.com/sirrobot01/decypharr/blob/main/docs/docs/installation.md This YAML configuration defines a Decypharr service for Docker Compose. It specifies the Docker image, container name, port mappings, volume mounts for data and configuration, restart policy, and necessary device and capability configurations for the container. ```yaml services: decypharr: image: cy01/blackhole:latest container_name: decypharr ports: - "8282:8282" volumes: - /mnt/:/mnt:rshared - ./config/:/app restart: unless-stopped devices: - /dev/fuse:/dev/fuse:rwm cap_add: - SYS_ADMIN security_opt: - apparmor:unconfined ``` -------------------------------- ### Setup Rclone Filesystem Mount for WebDAV (Go) Source: https://context7.com/sirrobot01/decypharr/llms.txt Illustrates setting up an Rclone-based filesystem mount for a WebDAV endpoint. It covers creating an Rclone manager, starting the RC server, creating a mount configuration for a specific provider, mounting the WebDAV URL locally, checking the mount status, retrieving mount information, refreshing directories, and ensuring cleanup via unmounting. Dependencies include 'context', 'rclone' package, and 'config' package. ```go package main import ( "context" "github.com/sirrobot01/decypharr/pkg/rclone" "github.com/sirrobot01/decypharr/internal/config" ) func setupRcloneMount() error { ctx := context.Background() // Create Rclone manager cfg := config.Get() rcManager := rclone.NewManager(&cfg.Rclone) // Start Rclone RC server if err := rcManager.Start(ctx); err != nil { return fmt.Errorf("failed to start: %w", err) } // Create mount for provider mount := rclone.NewMount( "realdebrid", // provider "/mnt/realdebrid", // local path "http://localhost:8282/webdav", // WebDAV URL rcManager, ) // Mount WebDAV if err := mount.Mount(ctx); err != nil { return fmt.Errorf("mount failed: %w", err) } // Check mount status if mount.IsMounted() { fmt.Println("Mount is active") } // Get mount info info, ok := mount.GetMountInfo() if ok { fmt.Printf("Mount point: %s\n", info.MountPoint) fmt.Printf("Remote: %s\n", info.Remote) } // Refresh directories dirs := []string{"/Movie.2024"} if err := mount.RefreshDir(dirs); err != nil { return fmt.Errorf("refresh failed: %w", err) } // Cleanup defer mount.Unmount() return nil } ``` -------------------------------- ### Docker CLI: Pull and Run Decypharr Container Source: https://github.com/sirrobot01/decypharr/blob/main/docs/docs/installation.md This snippet demonstrates how to pull the Decypharr Docker image from Docker Hub and then run it as a detached container. It configures port mapping, volume mounts for persistent data and configuration, automatic restart, and necessary device/capability additions for proper functionality. ```bash docker pull cy01/blackhole:latest docker run -d \ --name decypharr \ --restart unless-stopped \ -p 8282:8282 \ -v /mnt/:/mnt:rshared \ -v ./config/:/app \ --device /dev/fuse:/dev/fuse:rwm \ --cap-add SYS_ADMIN \ --security-opt apparmor:unconfined \ cy01/blackhole:latest ``` -------------------------------- ### Start a Repair Job via API Source: https://github.com/sirrobot01/decypharr/blob/main/docs/docs/api.md This example shows how to initiate a repair job for media items using the Decypharr API. It uses a POST request to the `/api/repair` endpoint and requires authentication. The request body is JSON, specifying the Arr name, media IDs, and optional flags for auto-processing and asynchronous execution. ```bash # With API token curl -H "Authorization: Bearer $API_TOKEN" -X POST http://localhost:8080/api/repair \ -H "Content-Type: application/json" \ -d '{ "arrName": "sonarr", "mediaIds": ["123", "456"], "autoProcess": true, "async": true }' ``` -------------------------------- ### Setup Event Listeners and Initial Load (JavaScript) Source: https://github.com/sirrobot01/decypharr/blob/main/pkg/web/templates/stats.html Attaches event listeners to refresh and retry buttons, triggering the `loadStats` function. It also sets up an interval to automatically refresh statistics every 30 seconds and performs an initial load on page setup. ```javascript // Event listeners refreshBtn.addEventListener('click', loadStats); retryBtn.addEventListener('click', loadStats); // Auto-refresh every 30 seconds setInterval(loadStats, 30000); // Initial load loadStats(); ``` -------------------------------- ### Get Torrents via API Source: https://github.com/sirrobot01/decypharr/blob/main/docs/docs/api.md This example demonstrates how to retrieve a list of all configured torrents using the Decypharr API. It requires authentication, typically via an `Authorization` header with a Bearer token. The endpoint `/api/torrents` is used with a GET request. ```bash # With API token curl -H "Authorization: Bearer $API_TOKEN" -X GET http://localhost:8080/api/torrents ``` -------------------------------- ### GET /api/config and POST /api/config Source: https://context7.com/sirrobot01/decypharr/llms.txt Manages application configuration settings. The GET method retrieves the current configuration, while the POST method allows for updating various settings including debrid providers, *Arr connections, and system parameters. ```APIDOC ## GET /api/config ### Description Retrieves the current application configuration. ### Method GET ### Endpoint `/api/config` ### Response #### Success Response (200) - **configuration** (object) - Contains all current application settings. ## POST /api/config ### Description Updates application configuration settings. Allows modification of debrid providers, *Arr connections, and system settings. ### Method POST ### Endpoint `/api/config` ### Parameters #### Request Body - **log_level** (string) - Optional - The desired logging level (e.g., "debug", "info"). - **min_file_size** (string) - Optional - The minimum acceptable file size (e.g., "100MB"). - **max_file_size** (string) - Optional - The maximum acceptable file size (e.g., "50GB"). - **debrids** (array) - Optional - A list of debrid provider configurations. - **name** (string) - Required - The name of the debrid provider (e.g., "realdebrid"). - **api_key** (string) - Required - The API key for the debrid provider. - **folder** (string) - Optional - The download folder path. - **use_webdav** (boolean) - Optional - Whether to use WebDAV for this provider. - **rate_limit** (string) - Optional - The rate limit for the provider (e.g., "200/minute"). - **qbittorrent** (object) - Optional - qBittorrent client configuration. - **download_folder** (string) - Required - The download folder for qBittorrent. - **categories** (array of strings) - Optional - Categories to use for qBittorrent. - **arrs** (array) - Optional - A list of *Arr application configurations. - **name** (string) - Required - The name of the *Arr application (e.g., "sonarr"). - **host** (string) - Required - The host address of the *Arr application. - **token** (string) - Required - The API token for the *Arr application. - **cleanup** (boolean) - Optional - Whether to enable cleanup functionality. - **skip_repair** (boolean) - Optional - Whether to skip repair operations. - **download_uncached** (boolean) - Optional - Whether to download uncached items. - **selected_debrid** (string) - Optional - The default debrid provider to use for this *Arr. - **source** (string) - Optional - The source of the configuration. ### Request Example (Update Configuration) ```json { "log_level": "debug", "min_file_size": "100MB", "max_file_size": "50GB", "debrids": [ { "name": "realdebrid", "api_key": "YOUR_API_KEY", "folder": "/downloads", "use_webdav": true, "rate_limit": "200/minute" } ], "qbittorrent": { "download_folder": "/downloads", "categories": ["sonarr", "radarr"] }, "arrs": [ { "name": "sonarr", "host": "http://sonarr:8989", "token": "SONARR_API_KEY", "cleanup": true } ] } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the operation was successful. Example: "success" #### Response Example ```json { "status": "success" } ``` ``` -------------------------------- ### Get All Torrents Info (QBittorrent API) Source: https://context7.com/sirrobot01/decypharr/llms.txt Retrieves information about all torrents managed by Decypharr, providing status updates to *Arr applications. Requires authentication. ```bash curl -X GET "http://localhost:8282/api/v2/torrents/info" \ -u "admin:password" ``` -------------------------------- ### Get Specific Torrent Info by Hash (QBittorrent API) Source: https://context7.com/sirrobot01/decypharr/llms.txt Retrieves information for a specific torrent managed by Decypharr using its hash. This is useful for getting status updates for individual media. Requires authentication. ```bash curl -X GET "http://localhost:8282/api/v2/torrents/info?hashes=ABC123" \ -u "admin:password" ``` -------------------------------- ### Start Repair Job (Web API) Source: https://context7.com/sirrobot01/decypharr/llms.txt Initiates a media repair job in Decypharr via the Web API. Scans for missing or broken files and can optionally re-download them. This operation is asynchronous. Requires an API token and JSON content. ```bash curl -X POST "http://localhost:8282/api/repair" \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "arrName": "sonarr", "mediaIds": ["123", "456"], "autoProcess": true, "async": true }' ``` -------------------------------- ### Docker Compose: Enable Decypharr Health Checks Source: https://github.com/sirrobot01/decypharr/blob/main/docs/docs/installation.md This snippet shows how to add a health check configuration to a Decypharr service within a Docker Compose file. It defines the test command to run, the interval between checks, the timeout for each check, and the number of retries before marking the service as unhealthy. ```yaml services: decypharr: ... ... healthcheck: test: ["CMD", "/usr/bin/healthcheck", "--config", "/app/"] interval: 10s timeout: 10s retries: 3 ``` -------------------------------- ### Docker Compose Configuration for Decypharr Source: https://github.com/sirrobot01/decypharr/blob/main/docs/docs/guides/internal-mounting.md This Docker Compose configuration sets up the Decypharr service, mapping ports, volumes for configuration persistence, and enabling necessary devices and capabilities for internal mounting. Ensure to adjust PUID and PGID to match your user and group IDs. ```yaml version: '3.8' services: decypharr: image: sirrobot01/decypharr:latest container_name: decypharr ports: - "8282:8282" volumes: - ./config:/config - /mnt:/mnt:rshared # Important: use 'rshared' for mount propagation devices: - /dev/fuse:/dev/fuse:rwm cap_add: - SYS_ADMIN security_opt: - apparmor:unconfined environment: - UMASK=002 - PUID=1000 # Change to your user ID - PGID=1000 # Change to your group ID ``` -------------------------------- ### Web API: Configuration Management Source: https://context7.com/sirrobot01/decypharr/llms.txt Manages application configuration, including debrid providers, Arr connections (like Sonarr), and system-wide settings. Supports both retrieving the current configuration via GET and updating it via POST with a JSON payload. ```bash # Get configuration curl -X GET "http://localhost:8282/api/config" \ -H "Authorization: Bearer YOUR_API_TOKEN" ``` ```bash # Update configuration curl -X POST "http://localhost:8282/api/config" \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "log_level": "debug", "min_file_size": "100MB", "max_file_size": "50GB", "debrids": [ { "name": "realdebrid", "api_key": "YOUR_API_KEY", "folder": "/downloads", "use_webdav": true, "rate_limit": "200/minute" } ], "qbittorrent": { "download_folder": "/downloads", "categories": ["sonarr", "radarr"] }, "arrs": [ { "name": "sonarr", "host": "http://sonarr:8989", "token": "SONARR_API_KEY", "cleanup": true } ] }' ``` -------------------------------- ### GET /api/torrents Source: https://context7.com/sirrobot01/decypharr/llms.txt Retrieves all torrents managed by Decypharr with detailed status information. ```APIDOC ## GET /api/torrents ### Description Retrieves all torrents managed by Decypharr with detailed status information. ### Method GET ### Endpoint `/api/torrents` ### Parameters No parameters required. ### Request Example ```bash curl -X GET "http://localhost:8282/api/torrents" \ -H "Authorization: Bearer YOUR_API_TOKEN" ``` ### Response #### Success Response (200) Returns a list of torrent objects with detailed status information. #### Response Example ```json [ { "hash": "ABC123", "name": "Movie.2024.1080p", "size": 2147483648, "status": "completed", "category": "radarr", "debrid": "realdebrid", "added_on": 1704067200, "files": [ { "name": "movie.mkv", "size": 2147483648, "path": "/downloads/Movie.2024.1080p/movie.mkv" } ] } ] ``` ``` -------------------------------- ### Get All Torrents (Web API) Source: https://context7.com/sirrobot01/decypharr/llms.txt Retrieves all torrents managed by Decypharr via the Web API, including detailed status information and file structure. Requires an API token for authentication. ```bash curl -X GET "http://localhost:8282/api/torrents" \ -H "Authorization: Bearer YOUR_API_TOKEN" ``` -------------------------------- ### WebDAV Server Access Source: https://context7.com/sirrobot01/decypharr/llms.txt Provides a WebDAV interface for accessing files directly from debrid services. This allows for mounting the debrid storage as a local filesystem or accessing it with tools like rclone. Examples include listing providers and mounting on Linux/macOS. ```bash # List available providers curl -X PROPFIND "http://localhost:8282/webdav/" \ -H "Depth: 1" ``` ```bash # Mount WebDAV (Linux) mount -t davfs http://localhost:8282/webdav/realdebrid /mnt/debrid ``` ```bash # Mount WebDAV (macOS) mount_webdav http://localhost:8282/webdav/realdebrid /Volumes/debrid ``` ```bash # Access via rclone rclone lsd webdav:realdebrid/ ``` -------------------------------- ### Torrent Management - Get All Torrents Source: https://github.com/sirrobot01/decypharr/blob/main/docs/docs/api.md Retrieve a list of all torrents currently being managed by Decypharr. ```APIDOC ## GET /api/torrents ### Description Get all torrents. ### Method GET ### Endpoint /api/torrents ### Parameters None ### Response #### Success Response (200) - **torrents** (array) - A list of torrent objects, each containing details like hash, name, status, etc. ``` -------------------------------- ### GET /api/v2/torrents/info Source: https://context7.com/sirrobot01/decypharr/llms.txt Retrieves information about torrents managed by Decypharr, providing status updates to *Arr applications. ```APIDOC ## GET /api/v2/torrents/info ### Description Retrieves information about torrents managed by Decypharr, providing status updates to *Arr applications. Compatible with QBittorrent API standards. ### Method GET ### Endpoint `/api/v2/torrents/info` ### Parameters #### Query Parameters - **hashes** (string) - Optional - Comma-separated list of torrent hashes to retrieve information for. ### Request Example ```bash # Get all torrents curl -X GET "http://localhost:8282/api/v2/torrents/info" \ -u "admin:password" # Get specific torrent by hash curl -X GET "http://localhost:8282/api/v2/torrents/info?hashes=ABC123" \ -u "admin:password" ``` ### Response #### Success Response (200) Returns a list of torrent objects with their status information. #### Response Example ```json [ { "hash": "ABC123", "name": "Movie.2024.1080p", "size": 2147483648, "progress": 1.0, "dlspeed": 0, "upspeed": 0, "state": "pausedUP", "category": "radarr", "save_path": "/downloads", "added_on": 1704067200, "completion_on": 1704067800 } ] ``` ``` -------------------------------- ### Add Content via API using API Token Source: https://github.com/sirrobot01/decypharr/blob/main/docs/docs/api.md This example demonstrates how to add torrents or magnet links using the Decypharr API with an API token for authentication. It requires specifying the Arr service, debrid provider, URLs or a torrent file, and optionally a callback URL. The `Authorization` header must contain the Bearer token. ```bash curl -H "Authorization: Bearer $API_TOKEN" -X POST http://localhost:8080/api/add \ -F "arr=sonarr" \ -F "debrid=realdebrid" \ -F "urls=magnet:?xt=urn:btih:..." \ -F "downloadUncached=true" -F "file=@/path/to/torrent/file.torrent" \ -F "callbackUrl=http://your.callback.url/endpoint" ``` -------------------------------- ### Repair Operations - Start Repair Source: https://github.com/sirrobot01/decypharr/blob/main/docs/docs/api.md Initiate the repair process for specified media items within an Arr application. This can be configured to process automatically. ```APIDOC ## POST /api/repair ### Description Start repair process for media items. ### Method POST ### Endpoint /api/repair ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **arrName** (string) - The name of the Arr application. - **mediaIds** (array of strings) - A list of media IDs to repair. - **autoProcess** (boolean) - Whether to automatically process the repair job. - **async** (boolean) - Whether to run the process asynchronously. ### Request Example ```bash curl -H "Authorization: Bearer $API_TOKEN" -X POST http://localhost:8080/api/repair \ -H "Content-Type: application/json" \ -d '{ \ "arrName": "sonarr", \ "mediaIds": ["123", "456"], \ "autoProcess": true, \ "async": true \ }' ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message. - **jobId** (string) - The ID of the created repair job. ``` -------------------------------- ### Add Content via API using Session Cookies Source: https://github.com/sirrobot01/decypharr/blob/main/docs/docs/api.md This example shows how to add torrents or magnet links using the Decypharr API with session-based authentication. It involves two steps: first, logging in to obtain a session cookie, and second, using that cookie in subsequent API requests to the `/api/add` endpoint. Similar parameters as token authentication are used. ```bash # Login first (this sets the session cookie) curl -c cookies.txt -X POST http://localhost:8080/login \ -H "Content-Type: application/json" \ -d '{"username": "your_username", "password": "your_password"}' # Then use the session cookie for API calls curl -b cookies.txt -X POST http://localhost:8080/api/add \ -F "arr=sonarr" \ -F "debrid=realdebrid" \ -F "urls=magnet:?xt=urn:btih:..." \ -F "downloadUncached=true" ``` -------------------------------- ### Load and Validate Application Configuration (Go) Source: https://context7.com/sirrobot01/decypharr/llms.txt Demonstrates how to initialize, load, validate, and update application configuration using the 'config' package. It includes setting the configuration path, accessing configuration values, performing validation, modifying settings, saving changes, and reloading the configuration. Assumes 'config' package provides singleton access and validation functions. ```go package main import ( "github.com/sirrobot01/decypharr/internal/config" "fmt" ) func initializeConfig() error { // Set config path before first use config.SetConfigPath("/app/data") // Get configuration (loads on first call) cfg := config.Get() // Validate configuration if err := config.ValidateConfig(cfg); err != nil { return fmt.Errorf("invalid config: %w", err) } // Access configuration fmt.Printf("Port: %s\n", cfg.Port) fmt.Printf("Log Level: %s\n", cfg.LogLevel) fmt.Printf("Debrids: %d\n", len(cfg.Debrids)) // Check file size constraints size := int64(150000000) // 150MB if !cfg.IsSizeAllowed(size) { return fmt.Errorf("file size not allowed") } // Update configuration cfg.LogLevel = "debug" cfg.MinFileSize = "50MB" cfg.MaxFileSize = "20GB" // Save changes if err := cfg.Save(); err != nil { return fmt.Errorf("failed to save: %w", err) } // Reload configuration after external changes config.Reload() return nil } ``` -------------------------------- ### Docker Compose Configuration for Decypharr Source: https://github.com/sirrobot01/decypharr/blob/main/README.md This Docker Compose configuration sets up Decypharr as a service. It maps ports, mounts volumes for configuration and storage, and adds necessary device access and security capabilities for features like WebDAV mounting. ```yaml services: decypharr: image: cy01/blackhole:latest container_name: decypharr ports: - "8282:8282" volumes: - /mnt/:/mnt:rshared - ./configs/:/app # config.json must be in this directory restart: unless-stopped devices: - /dev/fuse:/dev/fuse:rwm cap_add: - SYS_ADMIN security_opt: - apparmor:unconfined ``` -------------------------------- ### GET /api/repair/jobs Source: https://context7.com/sirrobot01/decypharr/llms.txt Retrieves the status of ongoing or completed repair jobs. ```APIDOC ## GET /api/repair/jobs ### Description Retrieves the status of ongoing or completed repair jobs initiated by the `/api/repair` endpoint. ### Method GET ### Endpoint `/api/repair/jobs` ### Parameters No parameters required. ### Request Example ```bash curl -X GET "http://localhost:8282/api/repair/jobs" \ -H "Authorization: Bearer YOUR_API_TOKEN" ``` ### Response #### Success Response (200) Returns a list of repair job statuses. (The exact structure of the response is not detailed in the provided text but would typically include job IDs, status, progress, etc.) #### Response Example (Example response structure would be provided if available in source documentation) ``` -------------------------------- ### Initialize Torrent Dashboard (JavaScript) Source: https://github.com/sirrobot01/decypharr/blob/main/pkg/web/templates/index.html Initializes the TorrentDashboard class once the DOM is fully loaded. This sets up the interactive elements for managing torrents on the page. It has no external dependencies beyond the DOM. ```javascript document.addEventListener('DOMContentLoaded', () => { window.dashboard = new TorrentDashboard(); }); ``` -------------------------------- ### Initialize Download Manager (JavaScript) Source: https://github.com/sirrobot01/decypharr/blob/main/pkg/web/templates/download.html Initializes the DownloadManager when the DOM is fully loaded. It accepts an optional download folder path. This script assumes the existence of a DownloadManager class. ```javascript document.addEventListener('DOMContentLoaded', () => { let downloadFolder = "" || ''; window.downloadManager = new DownloadManager(downloadFolder); }); ``` -------------------------------- ### POST /api/add Source: https://context7.com/sirrobot01/decypharr/llms.txt Direct API for adding torrents with advanced options including debrid selection and download behavior. ```APIDOC ## POST /api/add ### Description Direct API for adding torrents with advanced options including debrid selection, download behavior, and callback URLs. ### Method POST ### Endpoint `/api/add` ### Parameters #### Form Data - **urls** (string) - Optional - Magnet links for the torrents. - **files** (file) - Optional - Torrent files to upload. - **arr** (string) - Required - The *Arr application (e.g., sonarr, radarr, lidarr). - **debrid** (string) - Optional - The debrid service to use (e.g., realdebrid, torbox). - **action** (string) - Optional - The action to perform (e.g., download, stream). - **downloadUncached** (boolean) - Optional - Whether to download uncached torrents. - **skipMultiSeason** (boolean) - Optional - Whether to skip multi-season torrents. - **callbackUrl** (string) - Optional - URL for webhook notifications. ### Request Example ```bash # Add content with full control curl -X POST "http://localhost:8282/api/add" \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -F "urls=magnet:?xt=urn:btih:HASH" \ -F "arr=radarr" \ -F "debrid=realdebrid" \ -F "action=download" \ -F "downloadUncached=false" \ -F "skipMultiSeason=false" \ -F "callbackUrl=http://myserver.com/webhook" # Upload torrent files curl -X POST "http://localhost:8282/api/add" \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -F "files=@movie1.torrent" \ -F "files=@movie2.torrent" \ -F "arr=radarr" \ -F "debrid=torbox" ``` ### Response #### Success Response (200) Returns a JSON object with results and errors. #### Response Example ```json { "results": [ { "magnet": {...}, "arr": {...}, "debrid": "realdebrid", "action": "download" } ], "errors": [] } ``` ``` -------------------------------- ### Repair Operations - Get Jobs Source: https://github.com/sirrobot01/decypharr/blob/main/docs/docs/api.md Retrieve a list of all ongoing and completed repair jobs managed by Decypharr. ```APIDOC ## GET /api/repair/jobs ### Description Get all repair jobs. ### Method GET ### Endpoint /api/repair/jobs ### Parameters None ### Response #### Success Response (200) - **jobs** (array) - A list of repair job objects, each containing details about the job status and progress. ``` -------------------------------- ### Add Torrent via Magnet Link (QBittorrent API) Source: https://context7.com/sirrobot01/decypharr/llms.txt Adds a torrent to Decypharr using a magnet link, compatible with *Arr applications. It submits the magnet link to configured debrid services. Requires authentication. ```bash curl -X POST "http://localhost:8282/api/v2/torrents/add" \ -u "admin:password" \ -F "urls=magnet:?xt=urn:btih:HASH&dn=Movie.2024" \ -F "category=radarr" ``` -------------------------------- ### Add Torrent via File Upload (QBittorrent API) Source: https://context7.com/sirrobot01/decypharr/llms.txt Adds a torrent to Decypharr by uploading a torrent file, compatible with *Arr applications. It submits the torrent file to configured debrid services. Requires authentication and a save path. ```bash curl -X POST "http://localhost:8282/api/v2/torrents/add" \ -u "admin:password" \ -F "torrents=@movie.torrent" \ -F "category=sonarr" \ -F "savepath=/downloads" ``` -------------------------------- ### CSS: Styling for File Listing Source: https://github.com/sirrobot01/decypharr/blob/main/pkg/webdav/templates/directory.html Provides styling for the file listing interface. It defines styles for body, headings, lists, list items, links, file information, parent directory links, file numbers, file names, delete buttons, and general buttons. It also includes styles for disabled states and parent directory entries. ```css body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; margin: 0 auto; padding: 20px; } h1 { color: #2c3e50; } ul { list-style: none; padding: 0; } li { margin: 10px 0; display: flex; align-items: center; justify-content: space-between; } a { color: #3498db; text-decoration: none; padding: 10px; flex: 1; border: 1px solid #eee; border-radius: 4px; position: relative; padding-left: 50px; /* room for number */ } a:hover { background-color: #f7f9fa; } .file-info { color: #666; font-size: 0.9em; float: right; } .parent-dir { background-color: #f8f9fa; } .file-number { position: absolute; left: 10px; top: 10px; width: 30px; color: #777; font-weight: bold; text-align: right; } .file-name { display: inline-block; max-width: 70%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .delete-btn { background: transparent; border: none; color: #c00; cursor: pointer; font-size: 0.9em; margin-left: 12px; } .btn { display: inline-block; padding: 4px 8px; font-size: 0.9em; text-decoration: none; border: 1px solid #ccc; border-radius: 4px; color: #333; background-color: #f8f8f8; cursor: pointer; } .btn:hover { background-color: #e8e8e8; } .delete-btn:disabled { color: #ccc; cursor: not-allowed; } .disabled a { color: #999; pointer-events: none; border-color: #f0f0f0; background-color: #f8f8f8; } ``` -------------------------------- ### Get Repair Job Status (Web API) Source: https://context7.com/sirrobot01/decypharr/llms.txt Retrieves the status of ongoing or completed repair jobs managed by Decypharr via the Web API. Useful for monitoring the repair process. Requires an API token. ```bash curl -X GET "http://localhost:8282/api/repair/jobs" \ -H "Authorization: Bearer YOUR_API_TOKEN" ``` -------------------------------- ### Initialize Repair Manager and Utilities (JavaScript) Source: https://github.com/sirrobot01/decypharr/blob/main/pkg/web/templates/repair.html This script initializes the RepairManager and RepairUtils classes when the DOM is fully loaded. It's essential for enabling the repair management functionalities on the page. ```javascript document.addEventListener('DOMContentLoaded', () => { window.repairManager = new RepairManager(); window.RepairUtils = RepairUtils; }); ``` -------------------------------- ### Arrs Management Source: https://github.com/sirrobot01/decypharr/blob/main/docs/docs/api.md Retrieve a list of all configured Arr applications (e.g., Sonarr, Radarr) integrated with Decypharr. ```APIDOC ## GET /api/arrs ### Description Get all configured Arr applications (Sonarr, Radarr, etc.). ### Method GET ### Endpoint /api/arrs ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```bash curl -H "Authorization: Bearer $API_TOKEN" -X GET http://localhost:8080/api/arrs ``` ### Response #### Success Response (200) - **apps** (array) - A list of configured Arr applications. ``` -------------------------------- ### Copy API Token to Clipboard - JavaScript Source: https://github.com/sirrobot01/decypharr/blob/main/pkg/web/templates/config.html Copies the content of the API token display field to the user's clipboard. It handles cases where no token is available and displays appropriate toast messages for success or failure. This function requires `window.decypharrUtils.copyToClipboard` and `window.decypharrUtils.createToast`. ```javascript async function copyAPIToken() { const tokenDisplay = document.getElementById('api-token-display'); const token = tokenDisplay.value; if (!token || token === 'No token generated') { window.decypharrUtils.createToast('No token to copy. Please refresh the token first.', 'warning'); return; } try { await window.decypharrUtils.copyToClipboard(token); } catch (error) { console.error('Failed to copy token:', error); window.decypharrUtils.createToast('Failed to copy token to clipboard', 'error'); } } ``` -------------------------------- ### Add Content with Full Control (Web API) Source: https://context7.com/sirrobot01/decypharr/llms.txt Adds content to Decypharr via the Web API with advanced options, including debrid service selection and download behavior. Requires an API token for authentication. ```bash curl -X POST "http://localhost:8282/api/add" \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -F "urls=magnet:?xt=urn:btih:HASH" \ -F "arr=radarr" \ -F "debrid=realdebrid" \ -F "action=download" \ -F "downloadUncached=false" \ -F "skipMultiSeason=false" \ -F "callbackUrl=http://myserver.com/webhook" ``` -------------------------------- ### Client-side Theme Detection and URL Base Configuration (JavaScript) Source: https://github.com/sirrobot01/decypharr/blob/main/pkg/web/templates/layout.html This JavaScript code snippet initializes theme detection to prevent Flash of Unstyled Content (FOUC) by checking local storage, user preferences, or defaulting to a light theme. It also sets a global URL base for the application. ```javascript // Early theme detection to prevent FOUC (function() { const savedTheme = localStorage.getItem('theme'); if (savedTheme) { document.documentElement.setAttribute('data-theme', savedTheme); } else if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) { document.documentElement.setAttribute('data-theme', 'dark'); } else { document.documentElement.setAttribute('data-theme', 'light'); } })(); // Set global URL base window.urlBase = "{{.URLBase}}"; ``` -------------------------------- ### JavaScript: Handle User Registration Form Submission Source: https://github.com/sirrobot01/decypharr/blob/main/pkg/web/templates/register.html Handles the submission of the user registration form. It validates that the passwords match, collects form data, and sends it to the '/register' endpoint using a POST request. Upon successful registration, it redirects the user to the homepage; otherwise, it displays an error toast. Dependencies include `window.decypharrUtils` for utility functions. ```javascript document.addEventListener('DOMContentLoaded', function() { const authForm = document.getElementById('authForm'); authForm.addEventListener('submit', async function (e) { e.preventDefault(); const password = document.getElementById('password').value; const confirmPassword = document.getElementById('confirmPassword').value; if (password !== confirmPassword) { alert('Passwords do not match!'); return; } let formData = new FormData(); formData.append('username', document.getElementById('username').value); formData.append('password', password); formData.append('confirmPassword', confirmPassword); await fetcher('/register', { method: 'POST', body: formData }) .then(response => { if (!response.ok) { return response.text().then(errorText => { window.decypharrUtils.createToast(errorText || 'Registration failed', 'error'); }); } else { window.location.href = window.decypharrUtils.joinURL(window.urlBase, '/'); } }) .catch(error => { alert('Registration failed: ' + error.message); }); }); }); ``` -------------------------------- ### Update Authentication Settings - JavaScript Source: https://github.com/sirrobot01/decypharr/blob/main/pkg/web/templates/config.html Updates user authentication settings (username and password) by sending a POST request to '/api/update-auth'. It performs client-side password match validation and provides user feedback via toast notifications. Relies on `window.decypharrUtils` for loading states, fetching, and toasts. ```javascript async function updateAuthSettings() { const username = document.getElementById('auth-username').value; const password = document.getElementById('auth-password').value; const confirmPassword = document.getElementById('auth-password-confirm').value; const updateBtn = document.getElementById('update-auth-btn'); if (password !== confirmPassword) { window.decypharrUtils.createToast('Passwords do not match', 'error'); return false; } window.decypharrUtils.setButtonLoading(updateBtn, true, 'Update Authentication'); try { const response = await window.decypharrUtils.fetcher('/api/update-auth', { method: 'POST', body: JSON.stringify({ username: username, password: password, confirm_password: confirmPassword }) }); if (!response.ok) { const errorText = await response.text(); throw new Error(errorText || 'Failed to update authentication settings'); } const data = await response.json(); window.decypharrUtils.createToast(data.message, 'success'); document.getElementById('auth-password').value = ''; document.getElementById('auth-password-confirm').value = ''; return true; } catch (error) { console.error('Error updating authentication:', error); window.decypharrUtils.createToast('Failed to update authentication: ' + error.message, 'error'); return false; } finally { window.decypharrUtils.setButtonLoading(updateBtn, false); } } ``` -------------------------------- ### Handle Tab Navigation with URL Hash - JavaScript Source: https://github.com/sirrobot01/decypharr/blob/main/pkg/web/templates/config.html Manages tabbed content switching, updating the URL hash for bookmarking and browser history. It requires DOMContentLoaded event and assumes the existence of ConfigManager class and HTML elements with 'tab-button', 'tab-content', 'data-tab', and 'data-tab-content' attributes. ```javascript document.addEventListener('DOMContentLoaded', function() { window.configManager = new ConfigManager(); const tabButtons = document.querySelectorAll('.tab-button'); const tabContents = document.querySelectorAll('.tab-content'); function switchTab(targetTab) { tabButtons.forEach(btn => { btn.classList.remove('active'); }); const activeButton = document.querySelector(`[data-tab="${targetTab}"]`); if (activeButton) { activeButton.classList.add('active'); } tabContents.forEach(content => { content.classList.add('hidden'); }); const activeContent = document.querySelector(`[data-tab-content="${targetTab}"]`); if (activeContent) { activeContent.classList.remove('hidden'); } window.location.hash = `tab-${targetTab}`; } tabButtons.forEach(button => { button.addEventListener('click', (e) => { e.preventDefault(); const tabId = button.getAttribute('data-tab'); switchTab(tabId); }); }); const hash = window.location.hash; if (hash.startsWith('#tab-')) { const tabId = hash.replace('#tab-', ''); switchTab(tabId); } else { switchTab('general'); } window.addEventListener('hashchange', () => { const hash = window.location.hash; if (hash.startsWith('#tab-')) { const tabId = hash.replace('#tab-', ''); switchTab(tabId); } }); }); ``` -------------------------------- ### Page Routing and Templating Logic (Go Template) Source: https://github.com/sirrobot01/decypharr/blob/main/pkg/web/templates/layout.html This Go template code defines the main layout and conditional rendering logic for different pages within the Decypharr application. It uses 'if-else if' statements to determine which template to render based on the '.Page' variable. ```gohtml {{ define "layout" }} Decypharr - {{.Title}} {{ if eq .Page "index" }} {{ template "index" . }} {{ else if eq .Page "download" }} {{ template "download" . }} {{ else if eq .Page "repair" }} {{ template "repair" . }} {{ else if eq .Page "stats" }} {{ template "stats" . }} {{ else if eq .Page "config" }} {{ template "config" . }} {{ else if eq .Page "login" }} {{ template "login" . }} {{ else if eq .Page "register" }} {{ template "register" . }} {{ else }} 404 === Page not found. The page you're looking for doesn't exist. [Go Home]({{.URLBase}}) {{ end }} {{ end }} {{ end }} ``` -------------------------------- ### Upload Torrent Files (Web API) Source: https://context7.com/sirrobot01/decypharr/llms.txt Uploads torrent files to Decypharr via the Web API for processing. Supports multiple files and specifies the debrid service and target application. Requires an API token. ```bash curl -X POST "http://localhost:8282/api/add" \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -F "files=@movie1.torrent" \ -F "files=@movie2.torrent" \ -F "arr=radarr" \ -F "debrid=torbox" ``` -------------------------------- ### Handle Auth Update Errors in JavaScript Source: https://github.com/sirrobot01/decypharr/blob/main/pkg/web/templates/config.html This JavaScript code snippet handles errors that occur during the authentication settings update process. It logs the error, displays a user-friendly toast message, and resets the button's loading state. It assumes the existence of `window.decypharrUtils` for utility functions like `createToast` and `setButtonLoading`. ```javascript } catch (error) { console.error('Error updating auth settings:', error); window.decypharrUtils.createToast('Failed to update authentication: ' + error.message, 'error'); return false; } finally { window.decypharrUtils.setButtonLoading(updateBtn, false); } } ``` -------------------------------- ### Refresh API Token - JavaScript Source: https://github.com/sirrobot01/decypharr/blob/main/pkg/web/templates/config.html Asynchronously refreshes an API token by making a POST request to '/api/refresh-token'. It updates a token display field and shows toast notifications for success or failure. This function depends on `window.decypharrUtils` for button loading, fetching, and toast display. ```javascript async function refreshAPIToken() { const refreshBtn = document.getElementById('refresh-token-btn'); const tokenDisplay = document.getElementById('api-token-display'); window.decypharrUtils.setButtonLoading(refreshBtn, true, 'Refresh Token'); try { const response = await window.decypharrUtils.fetcher('/api/refresh-token', { method: 'POST' }); if (!response.ok) { throw new Error('Failed to refresh token'); } const data = await response.json(); tokenDisplay.value = data.token; window.decypharrUtils.createToast(data.message || 'Token refreshed successfully', 'success'); } catch (error) { console.error('Error refreshing token:', error); window.decypharrUtils.createToast('Failed to refresh token: ' + error.message, 'error'); } finally { window.decypharrUtils.setButtonLoading(refreshBtn, false); } } ``` -------------------------------- ### WebDAV Server Access Source: https://context7.com/sirrobot01/decypharr/llms.txt Provides access to files via a WebDAV interface, allowing direct file access from debrid services. This enables mounting and streaming of content. ```APIDOC ## WebDAV Server Access ### Description Provides a WebDAV interface for direct file access from debrid services, enabling mounting and streaming. ### Method PROPFIND ### Endpoint `/webdav/` ### Parameters #### Query Parameters - **Depth** (string) - Required - Specifies the scope of the PROPFIND request. Use "1" to list immediate children. ### Request Example (List available providers) ```bash curl -X PROPFIND "http://localhost:8282/webdav/" \ -H "Depth: 1" ``` ### Response #### Success Response (200) - **XML Response** - Returns an XML document listing available debrid providers as collections. #### Response Example (XML) ```xml /webdav/realdebrid/ realdebrid ``` ### Mounting WebDAV #### Linux ```bash mount -t davfs http://localhost:8282/webdav/realdebrid /mnt/debrid ``` #### macOS ```bash mount_webdav http://localhost:8282/webdav/realdebrid /Volumes/debrid ``` #### rclone ```bash rclone lsd webdav:realdebrid/ ``` ```