### Start Database Services for Local Development Source: https://github.com/mhdzumair/mediafusion/blob/main/deployment/README.md Commands to start PostgreSQL and Redis using a minimal Docker Compose configuration. ```bash cd deployment/docker-compose # Start PostgreSQL and Redis docker compose -f docker-compose-minimal.yml up -d # Verify services are running docker compose -f docker-compose-minimal.yml ps ``` -------------------------------- ### Locust load testing quick start Source: https://github.com/mhdzumair/mediafusion/blob/main/docs/performance.md Starts a load test using Locust with specified parameters. ```bash pip install locust locust -f perf/locustfile.py --headless -u 30 -r 5 -t 15m \ --host http://localhost:8000 \ --html perf/results/soak-$(date +%Y%m%d).html ``` -------------------------------- ### Start Rust API Server for Local Development Source: https://github.com/mhdzumair/mediafusion/blob/main/deployment/README.md Command to start the Rust API server for local development. Database migrations run automatically on startup. ```bash ``` -------------------------------- ### Makefile Shortcut Source: https://github.com/mhdzumair/mediafusion/blob/main/deployment/README.md Use the Makefile shortcut from the repository root to start the development server. ```bash make rust-dev ``` -------------------------------- ### Development Setup Source: https://github.com/mhdzumair/mediafusion/blob/main/deployment/docker-compose/README.md Command to set up databases only for local development. ```bash docker compose -f docker-compose-minimal.yml up -d ``` -------------------------------- ### Install Ingress Addon Source: https://github.com/mhdzumair/mediafusion/blob/main/deployment/k8s/README.md Enables the Ingress addon for Minikube. ```bash minikube addons enable ingress ``` -------------------------------- ### Download Direct Binary Source: https://github.com/mhdzumair/mediafusion/blob/main/deployment/README.md Example commands to download the API server and worker binaries for a specific release and architecture. ```bash # Example: download amd64 binaries for a specific release RELEASE=6.0.0-beta.5 ARCH=amd64 # or arm64 curl -Lo mediafusion-api \ "https://github.com/mhdzumair/MediaFusion/releases/download/${RELEASE}/mediafusion-api-linux-${ARCH}" curl -Lo mediafusion-worker \ "https://github.com/mhdzumair/MediaFusion/releases/download/${RELEASE}/mediafusion-worker-linux-${ARCH}" chmod +x mediafusion-api mediafusion-worker ``` -------------------------------- ### Development Setup Source: https://github.com/mhdzumair/mediafusion/blob/main/CONTRIBUTING.md Commands to set up the development environment. ```bash pipenv install ``` -------------------------------- ### Local Development Setup Source: https://github.com/mhdzumair/mediafusion/blob/main/AGENTS.md Commands to start minimal Docker services (PostgreSQL and Redis) for local development. ```bash # Start only PostgreSQL and Redis (minimal Docker) cd deployment/docker-compose && docker compose -f docker-compose-minimal.yml up -d # Migrations run automatically on API startup — no manual step needed make rust-dev ``` -------------------------------- ### Prometheus Metrics Endpoint Source: https://github.com/mhdzumair/mediafusion/blob/main/docs/performance.md Example command to access Prometheus metrics. ```bash curl http://localhost:8000/metrics ``` -------------------------------- ### Clone & Setup Local Development Source: https://github.com/mhdzumair/mediafusion/blob/main/deployment/README.md Commands to clone the MediaFusion repository and navigate to the project directory for local development. ```bash # Clone the repository git clone https://github.com/mhdzumair/MediaFusion cd MediaFusion ``` -------------------------------- ### Environment Variables for Local Deployment Source: https://github.com/mhdzumair/mediafusion/blob/main/deployment/k8s/README.md Example environment variables to configure in `deployment/local-deployment.yaml`. ```yaml - name: HOST_URL value: "https://mediafusion.local" - name: CONTACT_EMAIL value: "admin@example.com" - name: ENABLE_TAMILMV_SEARCH_SCRAPER value: "false" - name: PROWLARR_IMMEDIATE_MAX_PROCESS value: "3" - name: PROWLARR_SEARCH_INTERVAL_HOUR value: "24" - name: IS_SCRAP_FROM_TORRENTIO value: "false" ``` -------------------------------- ### Start Direct Binary Source: https://github.com/mhdzumair/mediafusion/blob/main/deployment/README.md Commands to run the MediaFusion API server and background worker after downloading the binaries. ```bash ./mediafusion-api ``` ```bash ./mediafusion-worker ``` -------------------------------- ### Rust Logs Example Source: https://github.com/mhdzumair/mediafusion/blob/main/deployment/README.md Combine debug logging with running the API server to see detailed Rust output during development. ```bash RUST_LOG=mediafusion_api=debug,tower_http=debug cargo run --manifest-path backend/Cargo.toml --bin mediafusion-api ``` -------------------------------- ### Per-Route Redis Metrics Endpoint Source: https://github.com/mhdzumair/mediafusion/blob/main/docs/performance.md Example command to access per-route Redis metrics. ```bash curl -H "X-API-Key: $API_PASSWORD" http://localhost:8000/api/v1/admin/metrics/request-metrics/endpoint-stats ``` -------------------------------- ### Configure Environment Variables for Local Development Source: https://github.com/mhdzumair/mediafusion/blob/main/deployment/README.md Example script to create a .env file with essential configuration for local development. ```bash # Generate a secret key SECRET_KEY=$(openssl rand -hex 16) # Create .env file with essential configuration cat > .env << EOF # Core Settings HOST_URL=http://127.0.0.1:8000 SECRET_KEY=${SECRET_KEY} API_PASSWORD=dev_password STREAM_RS_PORT=8000 # Rust server port (default: 8000) # Database URIs (matching docker-compose-minimal.yml) POSTGRES_URI=postgresql://mediafusion:mediafusion@localhost:5432/mediafusion REDIS_URL=redis://localhost:6379 # Development Settings LOGGING_LEVEL=DEBUG USE_CONFIG_SOURCE=local # Optional: Disable schedulers during development DISABLE_ALL_SCHEDULER=true EOF ``` -------------------------------- ### View Docker Logs Source: https://github.com/mhdzumair/mediafusion/blob/main/deployment/qbittorrent-webdav/README.md Command to view the logs of the qbittorrent-webdav Docker container to find the initial password. ```bash docker logs qbittorrent-webdav ``` -------------------------------- ### Install Metrics Server Addon Source: https://github.com/mhdzumair/mediafusion/blob/main/deployment/k8s/README.md Enables the Metrics Server addon for Minikube, which is required for Horizontal Pod Autoscaler (HPA) functionality. ```bash minikube addons enable metrics-server ``` -------------------------------- ### Get Docker Container IP Address Source: https://github.com/mhdzumair/mediafusion/blob/main/deployment/qbittorrent-webdav/README.md Command to retrieve the IP address of a Docker container. ```bash docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ``` -------------------------------- ### Clone the Repository Source: https://github.com/mhdzumair/mediafusion/blob/main/deployment/k8s/README.md Clones the MediaFusion repository and navigates into the directory. ```bash git clone https://github.com/mhdzumair/MediaFusion cd MediaFusion ``` -------------------------------- ### High Availability Deployment Commands Source: https://github.com/mhdzumair/mediafusion/blob/main/deployment/k8s/README.md Commands to deploy MediaFusion with PostgreSQL HA setup for production environments. ```bash # First apply PostgreSQL HA setup kubectl apply -f deployment/k8s/postgres-ha-deployment.yaml # Then apply main deployment kubectl apply -f deployment/k8s/local-deployment.yaml ``` -------------------------------- ### Generate .htpasswd file Source: https://github.com/mhdzumair/mediafusion/blob/main/deployment/qbittorrent-webdav/README.md Use the htpasswd command to generate a .htpasswd file for WebDAV password protection. ```bash htpasswd -cBm .htpasswd username ``` -------------------------------- ### Setting Up Secrets Source: https://github.com/mhdzumair/mediafusion/blob/main/deployment/k8s/README.md Generates random secrets for MediaFusion operation and creates a Kubernetes secret. ```bash # Generate a random 32-character string for the SECRET_KEY SECRET_KEY=$(openssl rand -hex 16) # Generate a random API key for Prowlarr PROWLARR_API_KEY=$(openssl rand -hex 16) # Set a password to secure the API endpoints API_PASSWORD="your_password" # If using Premiumize, fill in your OAuth client ID and secret. Otherwise, leave these empty. # You can obtain OAuth credentials from the https://www.premiumize.me/registerclient with free user account. PREMIUMIZE_OAUTH_CLIENT_ID="" PREMIUMIZE_OAUTH_CLIENT_SECRET="" kubectl create secret generic mediafusion-secrets \ --from-literal=SECRET_KEY=$SECRET_KEY \ --from-literal=API_PASSWORD=$API_PASSWORD \ --from-literal=PROWLARR_API_KEY=$PROWLARR_API_KEY \ --from-literal=PREMIUMIZE_OAUTH_CLIENT_ID=$PREMIUMIZE_OAUTH_CLIENT_ID \ --from-literal=PREMIUMIZE_OAUTH_CLIENT_SECRET=$PREMIUMIZE_OAUTH_CLIENT_SECRET ``` -------------------------------- ### Episode Name Parser Examples Source: https://github.com/mhdzumair/mediafusion/blob/main/clients/browser-extension/popup/popup.html Examples of regular expressions for parsing episode names in series and sports content. ```regex S\d+E\d+\.(?P.*?)\.1080p ``` ```regex Episode\.(\d+)\.(?P.*?)\.720p ``` ```regex Grand\.Prix\.(?P.*?)\.Sky ``` -------------------------------- ### Clone the Repository Source: https://github.com/mhdzumair/mediafusion/blob/main/deployment/docker-compose/README.md Steps to clone the MediaFusion repository and navigate to the docker-compose directory. ```bash git clone https://github.com/mhdzumair/MediaFusion cd MediaFusion # goto deployment/docker-compose cd deployment/docker-compose ``` -------------------------------- ### Install Dependencies and Tools Source: https://github.com/mhdzumair/mediafusion/blob/main/docs/TorrentWebCreator.ipynb Installs necessary Python packages, aria2 for downloading, and the torrenttools AppImage, making it executable. ```python !pip install ipywidgets requests !apt-get -qq install aria2 !wget -qO torrenttools.AppImage https://github.com/fbdtemme/torrenttools/releases/download/v0.6.2/torrenttools-0.6.2-linux-x86_64.AppImage !chmod +x torrenttools.AppImage !./torrenttools.AppImage --appimage-extract > /dev/null ``` -------------------------------- ### Add Hosts Entry on Linux/macOS Source: https://github.com/mhdzumair/mediafusion/blob/main/deployment/k8s/README.md Command to add an entry to the hosts file on Linux or macOS. ```bash echo "$(minikube ip) mediafusion.local" | sudo tee -a /etc/hosts ``` -------------------------------- ### Standard Deployment Command Source: https://github.com/mhdzumair/mediafusion/blob/main/deployment/k8s/README.md Command to deploy MediaFusion to a local Kubernetes cluster. ```bash kubectl apply -f deployment/k8s/local-deployment.yaml ``` -------------------------------- ### Release Build Source: https://github.com/mhdzumair/mediafusion/blob/main/deployment/README.md Run a release build for a faster, production-like executable. This build is optimized for performance. ```bash cargo run --manifest-path backend/Cargo.toml --bin mediafusion-api --release ``` -------------------------------- ### Add Hosts Entry on Windows Source: https://github.com/mhdzumair/mediafusion/blob/main/deployment/k8s/README.md PowerShell command to add an entry to the Windows hosts file. ```powershell Add-Content -Path C:\Windows\System32\drivers\etc\hosts -Value "$(minikube ip) mediafusion.local" ``` -------------------------------- ### Prowlarr Configuration - Windows Source: https://github.com/mhdzumair/mediafusion/blob/main/deployment/docker-compose/README.md Script to run for Prowlarr configuration on Windows. ```powershell .\setup-prowlarr.ps1 ``` -------------------------------- ### Prowlarr Configuration - Linux/macOS Source: https://github.com/mhdzumair/mediafusion/blob/main/deployment/docker-compose/README.md Script to run for Prowlarr configuration on Linux/macOS. ```bash ./setup-prowlarr.sh ``` -------------------------------- ### Kubernetes Secret for Managed PostgreSQL Source: https://github.com/mhdzumair/mediafusion/blob/main/deployment/k8s/README.md Command to create Kubernetes secrets for managed PostgreSQL connection strings. ```bash kubectl create secret generic mediafusion-secrets \ --from-literal=POSTGRES_URI="postgresql+asyncpg://user:password@your-rds-endpoint:5432/mediafusion" \ --from-literal=POSTGRES_READ_URI="postgresql+asyncpg://user:password@your-rds-read-replica:5432/mediafusion" \ # ... other secrets --dry-run=client -o yaml | kubectl apply -f - ``` -------------------------------- ### Get recent requests Source: https://github.com/mhdzumair/mediafusion/blob/main/docs/performance.md Retrieves recent requests from Redis for correlation. ```bash curl -H "X-API-Key: $API_PASSWORD" http://localhost:8000/api/v1/admin/metrics/request-metrics/recent ``` -------------------------------- ### Run qBittorrent-WebDAV Docker Image Source: https://github.com/mhdzumair/mediafusion/blob/main/deployment/qbittorrent-webdav/README.md Command to run the qBittorrent-WebDAV Docker image, including port mappings and volume mounts for configuration and downloads. ```bash docker run -d \ --name=qbittorrent-webdav \ --restart unless-stopped \ -p 8080:80 \ -p 6881:6881/tcp \ -p 6881:6881/udp \ -v /path/to/htpasswd:/etc/apache2/.htpasswd \# Optional: For WebDAV password protection -v /path/to/downloads:/downloads \ mhdzumair/qbittorrent-webdav:latest ``` -------------------------------- ### Get slow queries Source: https://github.com/mhdzumair/mediafusion/blob/main/docs/performance.md Retrieves the top-N slowest query fingerprints from pg_stat_statements. ```bash curl -H "X-API-Key: $API_PASSWORD" \ "http://localhost:8000/api/v1/admin/db/slow-queries?limit=20&order_by=total_exec_time" ``` -------------------------------- ### Check Migration Status Source: https://github.com/mhdzumair/mediafusion/blob/main/deployment/README.md Set the MEDIAFUSION_MIGRATE environment variable to 'status' and run either the API or worker binary to check the current migration status without starting the service. ```bash MEDIAFUSION_MIGRATE=status ./mediafusion-api ``` ```bash docker run --rm --env-file .env -e MEDIAFUSION_MIGRATE=status mhdzumair/mediafusion:6.0.0-beta.5 ``` -------------------------------- ### Frontend (React + TypeScript) Commands Source: https://github.com/mhdzumair/mediafusion/blob/main/AGENTS.md Commands for installing dependencies, running the development server, building, linting, and checking formatting for the React frontend. ```bash make frontend-install # cd clients/frontend && npm ci make frontend-dev # cd clients/frontend && npm run dev make frontend-build # cd clients/frontend && npm run build make frontend-lint # cd clients/frontend && npm run lint make frontend-fmt # cd clients/frontend && npm run format:check ``` -------------------------------- ### Reset slow queries Source: https://github.com/mhdzumair/mediafusion/blob/main/docs/performance.md Resets the slow query statistics in pg_stat_statements. ```bash curl -X POST -H "X-API-Key: $API_PASSWORD" http://localhost:8000/api/v1/admin/db/slow-queries/reset ``` -------------------------------- ### Stop MediaFusion Source: https://github.com/mhdzumair/mediafusion/blob/main/deployment/docker-compose/README.md Command to stop MediaFusion containers. ```bash docker compose -f docker-compose.yml down ``` -------------------------------- ### MediaFusion Browser Extension - Chrome/Edge Manual Installation Source: https://github.com/mhdzumair/mediafusion/blob/main/README.md Instructions for manually loading the MediaFusion browser extension in Chrome or Edge. ```bash 1. Download the extension package from [Releases](https://github.com/mhdzumair/MediaFusion/releases/tag/4.3.35) 2. Extract the downloaded ZIP file (`mediafusion-extension-chrome.zip`) 3. Open Chrome/Edge and go to Extensions page (`chrome://extensions/` or `edge://extensions/`) 4. Enable "Developer mode" 5. Click "Load unpacked" and select the extracted folder 6. Configure your MediaFusion instance URL in the extension settings ``` -------------------------------- ### Standard Deployment Source: https://github.com/mhdzumair/mediafusion/blob/main/deployment/docker-compose/README.md Command to deploy MediaFusion using Docker Compose with a single PostgreSQL instance. ```bash docker compose -f docker-compose.yml up -d ``` -------------------------------- ### Generate per-request flamegraph Source: https://github.com/mhdzumair/mediafusion/blob/main/docs/performance.md Generates a pyinstrument HTML flamegraph for a specific endpoint by enabling the profiler. ```bash curl -H "X-API-Key: $API_PASSWORD" \ "http://localhost:8000/stream/movie/tt0111161.json?_profile=1" \ -o flame.html && open flame.html ``` -------------------------------- ### Reset MediaFusion Source: https://github.com/mhdzumair/mediafusion/blob/main/deployment/docker-compose/README.md Command to reset MediaFusion by removing containers and volumes. ```bash docker compose -f docker-compose.yml down -v ``` -------------------------------- ### Windows Configuration Source: https://github.com/mhdzumair/mediafusion/blob/main/deployment/docker-compose/README.md PowerShell commands to set up the .env file for Windows, including generating a secret key, API password, contact email, and optional Premiumize credentials. ```powershell # Copy .env-sample to .env Copy-Item .env-sample .env # Generate and update SECRET_KEY in the .env file $guid = [System.Guid]::NewGuid().ToString("N").Substring(0, 32) Add-Content -Path .env -Value "SECRET_KEY=$guid" # Set API Password to secure the API endpoints Add-Content -Path .env -Value "API_PASSWORD=your_password" # Set contact email shown in addon metadata Add-Content -Path .env -Value "CONTACT_EMAIL=admin@example.com" # Optional: # Update .env with your Premiumize credentials if available # You can obtain OAuth credentials from the https://www.premiumize.me/registerclient with free user account. $clientId = 'your_client_id' $clientSecret = 'your_client_secret' Add-Content -Path .env -Value "PREMIUMIZE_OAUTH_CLIENT_ID=$clientId" Add-Content -Path .env -Value "PREMIUMIZE_OAUTH_CLIENT_SECRET=$clientSecret" # Open the .env file to verify the values notepad.exe .env ``` -------------------------------- ### MediaFlow Environment Variables Source: https://github.com/mhdzumair/mediafusion/blob/main/docs/acestream-mediaflow-setup.md Environment variables to configure for MediaFlow Proxy to enable AceStream support. ```env API_PASSWORD= ENABLE_ACESTREAM=true ACESTREAM_HOST= ACESTREAM_PORT=6878 ``` -------------------------------- ### TorrentWebCreator Initialization and Directory Creation Source: https://github.com/mhdzumair/mediafusion/blob/main/docs/TorrentWebCreator.ipynb Initializes the creator with a base path for local storage and creates necessary subdirectories for downloads and torrents. ```python def __init__(self, base_path: str = "./media_storage"): """Initialize the creator with local storage paths""" self.base_path = base_path self.create_storage_directories() def create_storage_directories(self): """Create necessary directories for local storage""" directories = ["downloads", "torrents"] for dir_name in directories: path = os.path.join(self.base_path, dir_name) os.makedirs(path, exist_ok=True) print(f"Created directory: {path}") ```