Compare commits

...

2 Commits
main ... dev

Author SHA1 Message Date
Jeff Emmett 5026e07d76 feat(media): add Bazarr subtitle manager and 1080p quality enforcement
- Add Bazarr service to both docker-compose files (port 6767, subtitles.jefflix.lol)
- Add sort-uploads.sh with 1080p minimum enforcement and quality scoring
- Add scripts/configure-quality-profiles.sh to update Radarr/Sonarr quality profiles

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-08 10:12:12 -04:00
Jeff Emmett 4a2ccc65c7 feat: replace FileBrowser with drag & drop upload service
Simple Node.js/Express upload page at upload.jefflix.lol that auto-sorts
files into Jellyfin media directories (movies/shows/music) based on
filename patterns and extensions. Includes password auth and Jellyfin
library refresh on upload.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-06 13:58:38 -04:00
9 changed files with 1889 additions and 23 deletions

View File

@ -141,6 +141,29 @@ services:
- "traefik.http.services.prowlarr.loadbalancer.server.port=9696"
- "traefik.docker.network=traefik-public"
# Subtitle Management - Auto-downloads subtitles for all Radarr/Sonarr content
bazarr:
image: linuxserver/bazarr:latest
container_name: bazarr
restart: unless-stopped
environment:
- PUID=1000
- PGID=1000
- TZ=Europe/Berlin
volumes:
- ./config/bazarr:/config
- /mnt/hetzner-media/media/movies:/movies
- /mnt/hetzner-media/media/shows:/tv
networks:
- media-network
- traefik-public
labels:
- "traefik.enable=true"
- "traefik.http.routers.bazarr.rule=Host(`subtitles.jefflix.lol`)"
- "traefik.http.routers.bazarr.entrypoints=web"
- "traefik.http.services.bazarr.loadbalancer.server.port=6767"
- "traefik.docker.network=traefik-public"
lidarr:
image: linuxserver/lidarr:latest
container_name: lidarr
@ -241,6 +264,39 @@ services:
- "traefik.http.middlewares.wizarr-headers.headers.customRequestHeaders.X-Forwarded-Proto=https"
- "traefik.docker.network=traefik-public"
# Upload Service - Drag & drop upload with auto-sorting into Jellyfin libraries
jellyfin-upload:
build: ./upload-service
container_name: jellyfin-upload
restart: unless-stopped
volumes:
- /mnt/hetzner-media/media:/media
- /mnt/hetzner-media/uploads:/media/uploads
environment:
- PORT=8080
- MEDIA_ROOT=/media
- UPLOAD_PASSWORD=${UPLOAD_PASSWORD}
- JELLYFIN_API_KEY=${JELLYFIN_API_KEY}
- JELLYFIN_URL=http://jellyfin:8096
- MAX_FILE_SIZE=21474836480
healthcheck:
test: ["CMD", "wget", "-q", "--spider", "http://127.0.0.1:8080/"]
interval: 30s
timeout: 10s
retries: 3
start_period: 10s
labels:
- "traefik.enable=true"
- "traefik.http.routers.jellyfin-upload.rule=Host(`upload.jefflix.lol`)"
- "traefik.http.routers.jellyfin-upload.entrypoints=web"
- "traefik.http.routers.jellyfin-upload.middlewares=jellyfin-upload-headers"
- "traefik.http.services.jellyfin-upload.loadbalancer.server.port=8080"
- "traefik.http.middlewares.jellyfin-upload-headers.headers.customRequestHeaders.X-Forwarded-Proto=https"
- "traefik.docker.network=traefik-public"
networks:
- media-network
- traefik-public
# Legacy Transmission (kept for compatibility, prefer qBittorrent)
transmission:
image: linuxserver/transmission:latest

View File

@ -136,6 +136,29 @@ services:
- "traefik.http.services.prowlarr.loadbalancer.server.port=9696"
- "traefik.docker.network=traefik-public"
# Subtitle Management - Auto-downloads subtitles for all Radarr/Sonarr content
bazarr:
image: linuxserver/bazarr:latest
container_name: bazarr
restart: unless-stopped
environment:
- PUID=1000
- PGID=1000
- TZ=Europe/Berlin
volumes:
- ./config/bazarr:/config
- /mnt/hetzner-media/media/movies:/movies
- /mnt/hetzner-media/media/shows:/tv
networks:
- media-network
- traefik-public
labels:
- "traefik.enable=true"
- "traefik.http.routers.bazarr.rule=Host(`subtitles.jefflix.lol`)"
- "traefik.http.routers.bazarr.entrypoints=web"
- "traefik.http.services.bazarr.loadbalancer.server.port=6767"
- "traefik.docker.network=traefik-public"
lidarr:
image: linuxserver/lidarr:latest
container_name: lidarr
@ -267,38 +290,34 @@ services:
profiles:
- legacy
# File Browser - Web upload interface for community contributions
filebrowser:
image: filebrowser/filebrowser:latest
container_name: filebrowser
# Upload Service - Drag & drop upload with auto-sorting into Jellyfin libraries
jellyfin-upload:
build: ./upload-service
container_name: jellyfin-upload
restart: unless-stopped
user: "0:0"
environment:
- TZ=Europe/Berlin
- FB_PORT=8080
- FB_ADDRESS=0.0.0.0
volumes:
- /mnt/hetzner-media/uploads:/srv/uploads
- ./config/filebrowser:/database
- ./config/filebrowser/settings.json:/config/settings.json:ro
command:
- --root=/srv/uploads
- --database=/database/filebrowser.db
- --address=0.0.0.0
- --port=8080
- /mnt/hetzner-media/media:/media
- /mnt/hetzner-media/uploads:/media/uploads
environment:
- PORT=8080
- MEDIA_ROOT=/media
- UPLOAD_PASSWORD=${UPLOAD_PASSWORD}
- JELLYFIN_API_KEY=${JELLYFIN_API_KEY}
- JELLYFIN_URL=http://jellyfin:8096
- MAX_FILE_SIZE=21474836480
healthcheck:
test: ["CMD", "wget", "-q", "--spider", "http://127.0.0.1:8080/health"]
test: ["CMD", "wget", "-q", "--spider", "http://127.0.0.1:8080/"]
interval: 30s
timeout: 10s
retries: 3
start_period: 10s
labels:
- "traefik.enable=true"
- "traefik.http.routers.filebrowser.rule=Host(`upload.jefflix.lol`)"
- "traefik.http.routers.filebrowser.entrypoints=web"
- "traefik.http.routers.filebrowser.middlewares=filebrowser-headers"
- "traefik.http.services.filebrowser.loadbalancer.server.port=8080"
- "traefik.http.middlewares.filebrowser-headers.headers.customRequestHeaders.X-Forwarded-Proto=https"
- "traefik.http.routers.jellyfin-upload.rule=Host(`upload.jefflix.lol`)"
- "traefik.http.routers.jellyfin-upload.entrypoints=web"
- "traefik.http.routers.jellyfin-upload.middlewares=jellyfin-upload-headers"
- "traefik.http.services.jellyfin-upload.loadbalancer.server.port=8080"
- "traefik.http.middlewares.jellyfin-upload-headers.headers.customRequestHeaders.X-Forwarded-Proto=https"
- "traefik.docker.network=traefik-public"
networks:
- media-network

View File

@ -0,0 +1,142 @@
#!/bin/bash
# Configure Radarr and Sonarr quality profiles for 1080p minimum
# Run on Netcup after services are running
#
# Usage: ./configure-quality-profiles.sh
# Requires: RADARR_API_KEY and SONARR_API_KEY in .env or environment
set -euo pipefail
# Load .env if available
[ -f /opt/media-server/.env ] && { set -a; source /opt/media-server/.env; set +a; }
RADARR_URL="${RADARR_URL:-http://localhost:7878}"
SONARR_URL="${SONARR_URL:-http://localhost:8989}"
# Fetch API keys from config if not in environment
if [ -z "${RADARR_API_KEY:-}" ]; then
RADARR_API_KEY=$(grep -oP '<ApiKey>\K[^<]+' /opt/media-server/config/radarr/config.xml 2>/dev/null || true)
fi
if [ -z "${SONARR_API_KEY:-}" ]; then
SONARR_API_KEY=$(grep -oP '<ApiKey>\K[^<]+' /opt/media-server/config/sonarr/config.xml 2>/dev/null || true)
fi
if [ -z "$RADARR_API_KEY" ] || [ -z "$SONARR_API_KEY" ]; then
echo "ERROR: Could not find API keys. Set RADARR_API_KEY and SONARR_API_KEY."
exit 1
fi
echo "=== Configuring Radarr Quality Profiles ==="
# Get existing quality profiles from Radarr
RADARR_PROFILES=$(curl -sf "${RADARR_URL}/api/v3/qualityprofile" \
-H "X-Api-Key: ${RADARR_API_KEY}")
if [ -z "$RADARR_PROFILES" ]; then
echo "ERROR: Could not fetch Radarr profiles"
exit 1
fi
# Update each profile: set cutoff and minimum to 1080p qualities
echo "$RADARR_PROFILES" | jq -c '.[]' | while read -r profile; do
PROFILE_ID=$(echo "$profile" | jq '.id')
PROFILE_NAME=$(echo "$profile" | jq -r '.name')
# Build updated profile: disable all qualities below 1080p
UPDATED=$(echo "$profile" | jq '
.items |= map(
if .quality then
# Disable individual qualities below 1080p
if (.quality.resolution // 0) < 1080 and (.quality.resolution // 0) > 0 then
.allowed = false
else
.
end
elif .name then
# Handle quality groups - disable groups that are sub-1080p
if (.name | test("480p|720p|SD|DVD"; "i")) then
.allowed = false |
.items |= map(.allowed = false)
else
.
end
else
.
end
) |
# Set cutoff to Bluray-1080p quality ID (7) or HDTV-1080p (9)
# This ensures upgrades continue until at least 1080p Bluray
.upgradeAllowed = true
')
echo " Updating Radarr profile: ${PROFILE_NAME} (ID: ${PROFILE_ID})"
curl -sf -X PUT "${RADARR_URL}/api/v3/qualityprofile/${PROFILE_ID}" \
-H "X-Api-Key: ${RADARR_API_KEY}" \
-H "Content-Type: application/json" \
-d "$UPDATED" > /dev/null
echo " Done"
done
echo ""
echo "=== Configuring Sonarr Quality Profiles ==="
# Get existing quality profiles from Sonarr
SONARR_PROFILES=$(curl -sf "${SONARR_URL}/api/v3/qualityprofile" \
-H "X-Api-Key: ${SONARR_API_KEY}")
if [ -z "$SONARR_PROFILES" ]; then
echo "ERROR: Could not fetch Sonarr profiles"
exit 1
fi
echo "$SONARR_PROFILES" | jq -c '.[]' | while read -r profile; do
PROFILE_ID=$(echo "$profile" | jq '.id')
PROFILE_NAME=$(echo "$profile" | jq -r '.name')
UPDATED=$(echo "$profile" | jq '
.items |= map(
if .quality then
if (.quality.resolution // 0) < 1080 and (.quality.resolution // 0) > 0 then
.allowed = false
else
.
end
elif .name then
if (.name | test("480p|720p|SD|DVD|SDTV"; "i")) then
.allowed = false |
.items |= map(.allowed = false)
else
.
end
else
.
end
) |
.upgradeAllowed = true
')
echo " Updating Sonarr profile: ${PROFILE_NAME} (ID: ${PROFILE_ID})"
curl -sf -X PUT "${SONARR_URL}/api/v3/qualityprofile/${PROFILE_ID}" \
-H "X-Api-Key: ${SONARR_API_KEY}" \
-H "Content-Type: application/json" \
-d "$UPDATED" > /dev/null
echo " Done"
done
echo ""
echo "=== Configuration Complete ==="
echo ""
echo "Quality profiles updated:"
echo " - All sub-1080p qualities (480p, 720p, SD, DVD) DISABLED"
echo " - Upgrades enabled to prefer higher quality"
echo ""
echo "Next steps:"
echo " 1. Start Bazarr: docker compose up -d bazarr"
echo " 2. Open https://subtitles.jefflix.lol"
echo " 3. Connect Bazarr to Radarr (${RADARR_URL}, key from config.xml)"
echo " 4. Connect Bazarr to Sonarr (${SONARR_URL}, key from config.xml)"
echo " 5. Add subtitle providers: OpenSubtitles.com, Subscene, Addic7ed"
echo " 6. Set languages: English (+ any others you want)"
echo " 7. Enable 'Auto' mode so Bazarr fetches subs for all existing + new content"

195
sort-uploads.sh Normal file
View File

@ -0,0 +1,195 @@
#!/bin/bash
# Sort uploaded files from filebrowser into Jellyfin media directories
# - Merges into existing folders
# - Replaces files with higher quality versions
# - Runs on cron every 5 minutes
UPLOADS=/mnt/hetzner-media/uploads
MEDIA=/mnt/hetzner-media/media
LOG=/opt/media-server/sort-uploads.log
# Jellyfin API accessed via docker exec (not exposed on host)
# Load secrets from .env (source of truth: Infisical /media/JELLYFIN_API_KEY)
set -a; source /opt/media-server/.env; set +a
MOVED=0
log() {
echo "$(date '+%Y-%m-%d %H:%M:%S') $1" >> "$LOG"
}
# Minimum resolution: 1080p — reject anything below
MIN_RESOLUTION_SCORE=300
# Check if a file meets minimum quality (1080p+)
meets_min_quality() {
local name="$1"
case "$name" in
*2160p*|*4[Kk]*|*1080p*) return 0 ;;
*) return 1 ;;
esac
}
# Score a filename by quality indicators (higher = better)
quality_score() {
local name="$1"
local score=0
# Resolution
case "$name" in
*2160p*|*4[Kk]*) score=$((score + 400)) ;;
*1080p*) score=$((score + 300)) ;;
*720p*) score=$((score + 200)) ;;
*480p*) score=$((score + 100)) ;;
esac
# Source
case "$name" in
*[Bb]lu[Rr]ay*|*BDRip*|*BDREMUX*|*REMUX*) score=$((score + 50)) ;;
*WEB-DL*|*WEBDL*) score=$((score + 40)) ;;
*WEBRip*|*WEBRIP*) score=$((score + 30)) ;;
*HDTV*) score=$((score + 20)) ;;
*DVDRip*|*DVD*) score=$((score + 10)) ;;
esac
# Codec
case "$name" in
*[xX]265*|*HEVC*|*[hH]265*) score=$((score + 15)) ;;
*[xX]264*|*[hH]264*|*AVC*) score=$((score + 10)) ;;
esac
# Audio
case "$name" in
*[Aa]tmos*) score=$((score + 8)) ;;
*DTS-HD*|*TrueHD*) score=$((score + 7)) ;;
*DTS*) score=$((score + 6)) ;;
*EAC3*|*DDP*|*DD+*) score=$((score + 5)) ;;
*AC3*|*DD[^P]*) score=$((score + 4)) ;;
*AAC*) score=$((score + 3)) ;;
esac
# Bigger file is often better quality (use as tiebreaker via file size)
echo $score
}
# Merge a source item (file or directory) into a destination directory
# If destination has a matching item, compare quality for files or recurse for dirs
merge_item() {
local src="$1"
local dst_dir="$2"
local label="$3"
local name="$(basename "$src")"
local dst="$dst_dir/$name"
if [ -d "$src" ]; then
# Source is a directory
if [ -d "$dst" ]; then
# Both are directories - recurse and merge contents
log "MERGE [$label] $name/ (merging into existing directory)"
for child in "$src"/*; do
[ -e "$child" ] || continue
merge_item "$child" "$dst" "$label"
done
# Remove source dir if now empty
rmdir "$src" 2>/dev/null
elif [ -e "$dst" ]; then
# Destination exists but is a file, source is a dir - skip
log "CONFLICT [$label] $name (source is dir, dest is file - skipping)"
else
# Destination doesn't exist - move entire directory
mv "$src" "$dst_dir/"
if [ $? -eq 0 ]; then
log "MOVED [$label] $name/"
MOVED=$((MOVED + 1))
else
log "ERROR [$label] Failed to move $name/"
fi
fi
else
# Source is a file — enforce 1080p minimum for video files
case "$name" in
*.mkv|*.mp4|*.avi|*.m4v|*.ts|*.wmv)
if ! meets_min_quality "$name"; then
log "REJECTED [$label] $name (below 1080p minimum quality)"
rm -f "$src"
return
fi
;;
esac
if [ -f "$dst" ]; then
# Same filename exists - compare quality
local src_score=$(quality_score "$name")
local dst_score=$(quality_score "$(basename "$dst")")
# If scores are equal, compare file size (bigger often = better)
if [ "$src_score" -eq "$dst_score" ]; then
local src_size=$(stat -c%s "$src" 2>/dev/null || echo 0)
local dst_size=$(stat -c%s "$dst" 2>/dev/null || echo 0)
if [ "$src_size" -gt "$dst_size" ]; then
src_score=$((src_score + 1))
fi
fi
if [ "$src_score" -gt "$dst_score" ]; then
log "UPGRADE [$label] $name (score $src_score > $dst_score, replacing)"
mv "$src" "$dst"
MOVED=$((MOVED + 1))
else
log "KEEP [$label] $name (existing score $dst_score >= upload $src_score, discarding upload)"
rm -f "$src"
fi
elif [ -d "$dst" ]; then
# Destination is a directory but source is a file - skip
log "CONFLICT [$label] $name (source is file, dest is dir - skipping)"
else
# No conflict - just move
mv "$src" "$dst_dir/"
if [ $? -eq 0 ]; then
log "MOVED [$label] $name"
MOVED=$((MOVED + 1))
else
log "ERROR [$label] Failed to move $name"
fi
fi
fi
}
# Process a category folder
move_category() {
local src="$1"
local dst="$2"
local label="$3"
[ -d "$src" ] || return
[ -z "$(ls -A "$src" 2>/dev/null)" ] && return
for item in "$src"/*; do
[ -e "$item" ] || continue
merge_item "$item" "$dst" "$label"
done
}
# Move categorized uploads (case-insensitive folder names)
move_category "$UPLOADS/Movies" "$MEDIA/movies" "movies"
move_category "$UPLOADS/movies" "$MEDIA/movies" "movies"
move_category "$UPLOADS/Shows" "$MEDIA/shows" "shows"
move_category "$UPLOADS/shows" "$MEDIA/shows" "shows"
move_category "$UPLOADS/Music" "$MEDIA/music" "music"
move_category "$UPLOADS/music" "$MEDIA/music" "music"
# Log any unsorted items at root level
for item in "$UPLOADS"/*; do
[ -e "$item" ] || continue
name="$(basename "$item")"
case "$name" in
Movies|movies|Shows|shows|Music|music) continue ;;
esac
log "UNSORTED $name - move to Movies/, Shows/, or Music/ subfolder"
done
# Trigger Jellyfin library scan if files were moved
if [ $MOVED -gt 0 ]; then
log "Triggering Jellyfin library scan ($MOVED items moved)"
docker exec jellyfin curl -sf -X POST "http://localhost:8096/Library/Refresh" \
-H "X-Emby-Token: $JELLYFIN_API_KEY" > /dev/null 2>&1
fi

12
upload-service/Dockerfile Normal file
View File

@ -0,0 +1,12 @@
FROM node:20-alpine
WORKDIR /app
COPY package.json package-lock.json* ./
RUN npm ci --omit=dev
COPY . .
EXPOSE 8080
USER node
CMD ["node", "server.js"]

998
upload-service/package-lock.json generated Normal file
View File

@ -0,0 +1,998 @@
{
"name": "jellyfin-upload",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "jellyfin-upload",
"version": "1.0.0",
"dependencies": {
"express": "^4.21.0",
"multer": "^1.4.5-lts.1"
}
},
"node_modules/accepts": {
"version": "1.3.8",
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz",
"integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==",
"license": "MIT",
"dependencies": {
"mime-types": "~2.1.34",
"negotiator": "0.6.3"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/append-field": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/append-field/-/append-field-1.0.0.tgz",
"integrity": "sha512-klpgFSWLW1ZEs8svjfb7g4qWY0YS5imI82dTg+QahUvJ8YqAY0P10Uk8tTyh9ZGuYEZEMaeJYCF5BFuX552hsw==",
"license": "MIT"
},
"node_modules/array-flatten": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
"integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==",
"license": "MIT"
},
"node_modules/body-parser": {
"version": "1.20.4",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.4.tgz",
"integrity": "sha512-ZTgYYLMOXY9qKU/57FAo8F+HA2dGX7bqGc71txDRC1rS4frdFI5R7NhluHxH6M0YItAP0sHB4uqAOcYKxO6uGA==",
"license": "MIT",
"dependencies": {
"bytes": "~3.1.2",
"content-type": "~1.0.5",
"debug": "2.6.9",
"depd": "2.0.0",
"destroy": "~1.2.0",
"http-errors": "~2.0.1",
"iconv-lite": "~0.4.24",
"on-finished": "~2.4.1",
"qs": "~6.14.0",
"raw-body": "~2.5.3",
"type-is": "~1.6.18",
"unpipe": "~1.0.0"
},
"engines": {
"node": ">= 0.8",
"npm": "1.2.8000 || >= 1.4.16"
}
},
"node_modules/buffer-from": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz",
"integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==",
"license": "MIT"
},
"node_modules/busboy": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz",
"integrity": "sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==",
"dependencies": {
"streamsearch": "^1.1.0"
},
"engines": {
"node": ">=10.16.0"
}
},
"node_modules/bytes": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz",
"integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/call-bind-apply-helpers": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz",
"integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==",
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0",
"function-bind": "^1.1.2"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/call-bound": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz",
"integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==",
"license": "MIT",
"dependencies": {
"call-bind-apply-helpers": "^1.0.2",
"get-intrinsic": "^1.3.0"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/concat-stream": {
"version": "1.6.2",
"resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz",
"integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==",
"engines": [
"node >= 0.8"
],
"license": "MIT",
"dependencies": {
"buffer-from": "^1.0.0",
"inherits": "^2.0.3",
"readable-stream": "^2.2.2",
"typedarray": "^0.0.6"
}
},
"node_modules/content-disposition": {
"version": "0.5.4",
"resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz",
"integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==",
"license": "MIT",
"dependencies": {
"safe-buffer": "5.2.1"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/content-type": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz",
"integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/cookie": {
"version": "0.7.2",
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz",
"integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/cookie-signature": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.7.tgz",
"integrity": "sha512-NXdYc3dLr47pBkpUCHtKSwIOQXLVn8dZEuywboCOJY/osA0wFSLlSawr3KN8qXJEyX66FcONTH8EIlVuK0yyFA==",
"license": "MIT"
},
"node_modules/core-util-is": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz",
"integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==",
"license": "MIT"
},
"node_modules/debug": {
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
"license": "MIT",
"dependencies": {
"ms": "2.0.0"
}
},
"node_modules/depd": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz",
"integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/destroy": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz",
"integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==",
"license": "MIT",
"engines": {
"node": ">= 0.8",
"npm": "1.2.8000 || >= 1.4.16"
}
},
"node_modules/dunder-proto": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz",
"integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==",
"license": "MIT",
"dependencies": {
"call-bind-apply-helpers": "^1.0.1",
"es-errors": "^1.3.0",
"gopd": "^1.2.0"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/ee-first": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
"integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==",
"license": "MIT"
},
"node_modules/encodeurl": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz",
"integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/es-define-property": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz",
"integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
}
},
"node_modules/es-errors": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz",
"integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
}
},
"node_modules/es-object-atoms": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz",
"integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==",
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/escape-html": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
"integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==",
"license": "MIT"
},
"node_modules/etag": {
"version": "1.8.1",
"resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
"integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/express": {
"version": "4.22.1",
"resolved": "https://registry.npmjs.org/express/-/express-4.22.1.tgz",
"integrity": "sha512-F2X8g9P1X7uCPZMA3MVf9wcTqlyNp7IhH5qPCI0izhaOIYXaW9L535tGA3qmjRzpH+bZczqq7hVKxTR4NWnu+g==",
"license": "MIT",
"dependencies": {
"accepts": "~1.3.8",
"array-flatten": "1.1.1",
"body-parser": "~1.20.3",
"content-disposition": "~0.5.4",
"content-type": "~1.0.4",
"cookie": "~0.7.1",
"cookie-signature": "~1.0.6",
"debug": "2.6.9",
"depd": "2.0.0",
"encodeurl": "~2.0.0",
"escape-html": "~1.0.3",
"etag": "~1.8.1",
"finalhandler": "~1.3.1",
"fresh": "~0.5.2",
"http-errors": "~2.0.0",
"merge-descriptors": "1.0.3",
"methods": "~1.1.2",
"on-finished": "~2.4.1",
"parseurl": "~1.3.3",
"path-to-regexp": "~0.1.12",
"proxy-addr": "~2.0.7",
"qs": "~6.14.0",
"range-parser": "~1.2.1",
"safe-buffer": "5.2.1",
"send": "~0.19.0",
"serve-static": "~1.16.2",
"setprototypeof": "1.2.0",
"statuses": "~2.0.1",
"type-is": "~1.6.18",
"utils-merge": "1.0.1",
"vary": "~1.1.2"
},
"engines": {
"node": ">= 0.10.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/finalhandler": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.3.2.tgz",
"integrity": "sha512-aA4RyPcd3badbdABGDuTXCMTtOneUCAYH/gxoYRTZlIJdF0YPWuGqiAsIrhNnnqdXGswYk6dGujem4w80UJFhg==",
"license": "MIT",
"dependencies": {
"debug": "2.6.9",
"encodeurl": "~2.0.0",
"escape-html": "~1.0.3",
"on-finished": "~2.4.1",
"parseurl": "~1.3.3",
"statuses": "~2.0.2",
"unpipe": "~1.0.0"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/forwarded": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz",
"integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/fresh": {
"version": "0.5.2",
"resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
"integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/function-bind": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
"integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==",
"license": "MIT",
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/get-intrinsic": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz",
"integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==",
"license": "MIT",
"dependencies": {
"call-bind-apply-helpers": "^1.0.2",
"es-define-property": "^1.0.1",
"es-errors": "^1.3.0",
"es-object-atoms": "^1.1.1",
"function-bind": "^1.1.2",
"get-proto": "^1.0.1",
"gopd": "^1.2.0",
"has-symbols": "^1.1.0",
"hasown": "^2.0.2",
"math-intrinsics": "^1.1.0"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/get-proto": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz",
"integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==",
"license": "MIT",
"dependencies": {
"dunder-proto": "^1.0.1",
"es-object-atoms": "^1.0.0"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/gopd": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz",
"integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/has-symbols": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz",
"integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/hasown": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz",
"integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==",
"license": "MIT",
"dependencies": {
"function-bind": "^1.1.2"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/http-errors": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.1.tgz",
"integrity": "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==",
"license": "MIT",
"dependencies": {
"depd": "~2.0.0",
"inherits": "~2.0.4",
"setprototypeof": "~1.2.0",
"statuses": "~2.0.2",
"toidentifier": "~1.0.1"
},
"engines": {
"node": ">= 0.8"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/iconv-lite": {
"version": "0.4.24",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
"integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==",
"license": "MIT",
"dependencies": {
"safer-buffer": ">= 2.1.2 < 3"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/inherits": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
"license": "ISC"
},
"node_modules/ipaddr.js": {
"version": "1.9.1",
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
"integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==",
"license": "MIT",
"engines": {
"node": ">= 0.10"
}
},
"node_modules/isarray": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
"integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==",
"license": "MIT"
},
"node_modules/math-intrinsics": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
"integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
}
},
"node_modules/media-typer": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
"integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/merge-descriptors": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.3.tgz",
"integrity": "sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==",
"license": "MIT",
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/methods": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
"integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/mime": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
"integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==",
"license": "MIT",
"bin": {
"mime": "cli.js"
},
"engines": {
"node": ">=4"
}
},
"node_modules/mime-db": {
"version": "1.52.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/mime-types": {
"version": "2.1.35",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
"license": "MIT",
"dependencies": {
"mime-db": "1.52.0"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/minimist": {
"version": "1.2.8",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz",
"integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==",
"license": "MIT",
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/mkdirp": {
"version": "0.5.6",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz",
"integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==",
"license": "MIT",
"dependencies": {
"minimist": "^1.2.6"
},
"bin": {
"mkdirp": "bin/cmd.js"
}
},
"node_modules/ms": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==",
"license": "MIT"
},
"node_modules/multer": {
"version": "1.4.5-lts.2",
"resolved": "https://registry.npmjs.org/multer/-/multer-1.4.5-lts.2.tgz",
"integrity": "sha512-VzGiVigcG9zUAoCNU+xShztrlr1auZOlurXynNvO9GiWD1/mTBbUljOKY+qMeazBqXgRnjzeEgJI/wyjJUHg9A==",
"deprecated": "Multer 1.x is impacted by a number of vulnerabilities, which have been patched in 2.x. You should upgrade to the latest 2.x version.",
"license": "MIT",
"dependencies": {
"append-field": "^1.0.0",
"busboy": "^1.0.0",
"concat-stream": "^1.5.2",
"mkdirp": "^0.5.4",
"object-assign": "^4.1.1",
"type-is": "^1.6.4",
"xtend": "^4.0.0"
},
"engines": {
"node": ">= 6.0.0"
}
},
"node_modules/negotiator": {
"version": "0.6.3",
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz",
"integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/object-assign": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
"integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==",
"license": "MIT",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/object-inspect": {
"version": "1.13.4",
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz",
"integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/on-finished": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz",
"integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==",
"license": "MIT",
"dependencies": {
"ee-first": "1.1.1"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/parseurl": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
"integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/path-to-regexp": {
"version": "0.1.13",
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.13.tgz",
"integrity": "sha512-A/AGNMFN3c8bOlvV9RreMdrv7jsmF9XIfDeCd87+I8RNg6s78BhJxMu69NEMHBSJFxKidViTEdruRwEk/WIKqA==",
"license": "MIT"
},
"node_modules/process-nextick-args": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
"integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==",
"license": "MIT"
},
"node_modules/proxy-addr": {
"version": "2.0.7",
"resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz",
"integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==",
"license": "MIT",
"dependencies": {
"forwarded": "0.2.0",
"ipaddr.js": "1.9.1"
},
"engines": {
"node": ">= 0.10"
}
},
"node_modules/qs": {
"version": "6.14.2",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.14.2.tgz",
"integrity": "sha512-V/yCWTTF7VJ9hIh18Ugr2zhJMP01MY7c5kh4J870L7imm6/DIzBsNLTXzMwUA3yZ5b/KBqLx8Kp3uRvd7xSe3Q==",
"license": "BSD-3-Clause",
"dependencies": {
"side-channel": "^1.1.0"
},
"engines": {
"node": ">=0.6"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/range-parser": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
"integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/raw-body": {
"version": "2.5.3",
"resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.3.tgz",
"integrity": "sha512-s4VSOf6yN0rvbRZGxs8Om5CWj6seneMwK3oDb4lWDH0UPhWcxwOWw5+qk24bxq87szX1ydrwylIOp2uG1ojUpA==",
"license": "MIT",
"dependencies": {
"bytes": "~3.1.2",
"http-errors": "~2.0.1",
"iconv-lite": "~0.4.24",
"unpipe": "~1.0.0"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/readable-stream": {
"version": "2.3.8",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz",
"integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==",
"license": "MIT",
"dependencies": {
"core-util-is": "~1.0.0",
"inherits": "~2.0.3",
"isarray": "~1.0.0",
"process-nextick-args": "~2.0.0",
"safe-buffer": "~5.1.1",
"string_decoder": "~1.1.1",
"util-deprecate": "~1.0.1"
}
},
"node_modules/readable-stream/node_modules/safe-buffer": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==",
"license": "MIT"
},
"node_modules/safe-buffer": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
],
"license": "MIT"
},
"node_modules/safer-buffer": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
"license": "MIT"
},
"node_modules/send": {
"version": "0.19.2",
"resolved": "https://registry.npmjs.org/send/-/send-0.19.2.tgz",
"integrity": "sha512-VMbMxbDeehAxpOtWJXlcUS5E8iXh6QmN+BkRX1GARS3wRaXEEgzCcB10gTQazO42tpNIya8xIyNx8fll1OFPrg==",
"license": "MIT",
"dependencies": {
"debug": "2.6.9",
"depd": "2.0.0",
"destroy": "1.2.0",
"encodeurl": "~2.0.0",
"escape-html": "~1.0.3",
"etag": "~1.8.1",
"fresh": "~0.5.2",
"http-errors": "~2.0.1",
"mime": "1.6.0",
"ms": "2.1.3",
"on-finished": "~2.4.1",
"range-parser": "~1.2.1",
"statuses": "~2.0.2"
},
"engines": {
"node": ">= 0.8.0"
}
},
"node_modules/send/node_modules/ms": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
"license": "MIT"
},
"node_modules/serve-static": {
"version": "1.16.3",
"resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.16.3.tgz",
"integrity": "sha512-x0RTqQel6g5SY7Lg6ZreMmsOzncHFU7nhnRWkKgWuMTu5NN0DR5oruckMqRvacAN9d5w6ARnRBXl9xhDCgfMeA==",
"license": "MIT",
"dependencies": {
"encodeurl": "~2.0.0",
"escape-html": "~1.0.3",
"parseurl": "~1.3.3",
"send": "~0.19.1"
},
"engines": {
"node": ">= 0.8.0"
}
},
"node_modules/setprototypeof": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz",
"integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==",
"license": "ISC"
},
"node_modules/side-channel": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz",
"integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==",
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0",
"object-inspect": "^1.13.3",
"side-channel-list": "^1.0.0",
"side-channel-map": "^1.0.1",
"side-channel-weakmap": "^1.0.2"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/side-channel-list": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.0.tgz",
"integrity": "sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==",
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0",
"object-inspect": "^1.13.3"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/side-channel-map": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz",
"integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==",
"license": "MIT",
"dependencies": {
"call-bound": "^1.0.2",
"es-errors": "^1.3.0",
"get-intrinsic": "^1.2.5",
"object-inspect": "^1.13.3"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/side-channel-weakmap": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz",
"integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==",
"license": "MIT",
"dependencies": {
"call-bound": "^1.0.2",
"es-errors": "^1.3.0",
"get-intrinsic": "^1.2.5",
"object-inspect": "^1.13.3",
"side-channel-map": "^1.0.1"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/statuses": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz",
"integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/streamsearch": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-1.1.0.tgz",
"integrity": "sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==",
"engines": {
"node": ">=10.0.0"
}
},
"node_modules/string_decoder": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
"integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
"license": "MIT",
"dependencies": {
"safe-buffer": "~5.1.0"
}
},
"node_modules/string_decoder/node_modules/safe-buffer": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==",
"license": "MIT"
},
"node_modules/toidentifier": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz",
"integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==",
"license": "MIT",
"engines": {
"node": ">=0.6"
}
},
"node_modules/type-is": {
"version": "1.6.18",
"resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz",
"integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==",
"license": "MIT",
"dependencies": {
"media-typer": "0.3.0",
"mime-types": "~2.1.24"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/typedarray": {
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz",
"integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==",
"license": "MIT"
},
"node_modules/unpipe": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
"integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/util-deprecate": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
"integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==",
"license": "MIT"
},
"node_modules/utils-merge": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
"integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==",
"license": "MIT",
"engines": {
"node": ">= 0.4.0"
}
},
"node_modules/vary": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
"integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/xtend": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz",
"integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==",
"license": "MIT",
"engines": {
"node": ">=0.4"
}
}
}
}

View File

@ -0,0 +1,12 @@
{
"name": "jellyfin-upload",
"version": "1.0.0",
"private": true,
"scripts": {
"start": "node server.js"
},
"dependencies": {
"express": "^4.21.0",
"multer": "^1.4.5-lts.1"
}
}

View File

@ -0,0 +1,256 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Jefflix Upload</title>
<style>
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
background: #0a0a0a;
color: #e0e0e0;
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
}
.container { width: 100%; max-width: 600px; padding: 20px; }
h1 { text-align: center; margin-bottom: 24px; color: #00a4dc; font-size: 1.5rem; }
/* Auth */
#auth-screen { text-align: center; }
#auth-screen input {
padding: 12px 16px;
font-size: 1rem;
background: #1a1a1a;
border: 1px solid #333;
color: #e0e0e0;
border-radius: 8px;
width: 100%;
max-width: 300px;
margin-bottom: 12px;
}
#auth-screen button {
padding: 12px 32px;
font-size: 1rem;
background: #00a4dc;
border: none;
color: #fff;
border-radius: 8px;
cursor: pointer;
}
#auth-screen button:hover { background: #0090c0; }
.auth-error { color: #ff4444; margin-top: 8px; font-size: 0.9rem; }
/* Drop zone */
.dropzone {
border: 2px dashed #333;
border-radius: 16px;
padding: 60px 20px;
text-align: center;
cursor: pointer;
transition: all 0.2s;
}
.dropzone:hover, .dropzone.dragover {
border-color: #00a4dc;
background: rgba(0, 164, 220, 0.05);
}
.dropzone p { font-size: 1.1rem; color: #888; }
.dropzone .hint { font-size: 0.85rem; color: #555; margin-top: 8px; }
/* File list */
#file-list { margin-top: 20px; }
.file-item {
background: #1a1a1a;
border-radius: 8px;
padding: 12px 16px;
margin-bottom: 8px;
}
.file-item .name {
font-size: 0.9rem;
word-break: break-all;
}
.file-item .meta {
font-size: 0.8rem;
color: #888;
margin-top: 4px;
}
.file-item .progress-bar {
height: 4px;
background: #333;
border-radius: 2px;
margin-top: 8px;
overflow: hidden;
}
.file-item .progress-fill {
height: 100%;
background: #00a4dc;
width: 0%;
transition: width 0.2s;
}
.file-item.done .progress-fill { background: #4caf50; }
.file-item.error .progress-fill { background: #ff4444; width: 100%; }
.file-item .result {
font-size: 0.8rem;
margin-top: 6px;
color: #4caf50;
}
.file-item.error .result { color: #ff4444; }
.hidden { display: none; }
</style>
</head>
<body>
<div class="container">
<h1>Jefflix Upload</h1>
<div id="auth-screen">
<p style="color: #888; margin-bottom: 16px;">Enter the upload password</p>
<input type="password" id="password-input" placeholder="Password" autofocus>
<br>
<button onclick="authenticate()">Enter</button>
<div class="auth-error hidden" id="auth-error">Wrong password</div>
</div>
<div id="upload-screen" class="hidden">
<div class="dropzone" id="dropzone">
<p>Drop files here or click to browse</p>
<p class="hint">Movies, TV shows, and music are auto-sorted</p>
</div>
<input type="file" id="file-input" multiple class="hidden">
<div id="file-list"></div>
</div>
</div>
<script>
let password = localStorage.getItem('upload_pw') || '';
// Check if already authenticated
if (password) showUpload();
function authenticate() {
password = document.getElementById('password-input').value;
// Test auth with a dummy request
fetch('/upload', {
method: 'POST',
headers: { 'X-Upload-Password': password },
body: new FormData()
}).then(r => {
if (r.status === 401) {
document.getElementById('auth-error').classList.remove('hidden');
} else {
// 400 = "no files" which means auth passed
localStorage.setItem('upload_pw', password);
showUpload();
}
});
}
document.getElementById('password-input').addEventListener('keydown', e => {
if (e.key === 'Enter') authenticate();
});
function showUpload() {
document.getElementById('auth-screen').classList.add('hidden');
document.getElementById('upload-screen').classList.remove('hidden');
}
// Drop zone
const dropzone = document.getElementById('dropzone');
const fileInput = document.getElementById('file-input');
dropzone.addEventListener('click', () => fileInput.click());
dropzone.addEventListener('dragover', e => {
e.preventDefault();
dropzone.classList.add('dragover');
});
dropzone.addEventListener('dragleave', () => dropzone.classList.remove('dragover'));
dropzone.addEventListener('drop', e => {
e.preventDefault();
dropzone.classList.remove('dragover');
handleFiles(e.dataTransfer.files);
});
fileInput.addEventListener('change', () => {
handleFiles(fileInput.files);
fileInput.value = '';
});
function formatSize(bytes) {
if (bytes >= 1e9) return (bytes / 1e9).toFixed(1) + ' GB';
if (bytes >= 1e6) return (bytes / 1e6).toFixed(1) + ' MB';
return (bytes / 1e3).toFixed(0) + ' KB';
}
function handleFiles(files) {
for (const file of files) {
uploadFile(file);
}
}
function uploadFile(file) {
const list = document.getElementById('file-list');
const item = document.createElement('div');
item.className = 'file-item';
item.innerHTML = `
<div class="name">${file.name}</div>
<div class="meta">${formatSize(file.size)}</div>
<div class="progress-bar"><div class="progress-fill"></div></div>
<div class="result"></div>
`;
list.prepend(item);
const progressFill = item.querySelector('.progress-fill');
const resultDiv = item.querySelector('.result');
const formData = new FormData();
formData.append('files', file);
const xhr = new XMLHttpRequest();
xhr.open('POST', '/upload');
xhr.setRequestHeader('X-Upload-Password', password);
xhr.upload.onprogress = e => {
if (e.lengthComputable) {
const pct = (e.loaded / e.total) * 100;
progressFill.style.width = pct + '%';
}
};
xhr.onload = () => {
if (xhr.status === 200) {
const data = JSON.parse(xhr.responseText);
const r = data.results[0];
if (r.error) {
item.classList.add('error');
resultDiv.textContent = r.error;
} else {
item.classList.add('done');
resultDiv.textContent = `Sorted to ${r.category}: ${r.destination}`;
}
} else if (xhr.status === 401) {
item.classList.add('error');
resultDiv.textContent = 'Authentication failed';
localStorage.removeItem('upload_pw');
} else {
item.classList.add('error');
try {
resultDiv.textContent = JSON.parse(xhr.responseText).error;
} catch {
resultDiv.textContent = 'Upload failed';
}
}
};
xhr.onerror = () => {
item.classList.add('error');
resultDiv.textContent = 'Network error';
};
xhr.send(formData);
}
</script>
</body>
</html>

176
upload-service/server.js Normal file
View File

@ -0,0 +1,176 @@
const express = require('express');
const multer = require('multer');
const path = require('path');
const fs = require('fs');
const http = require('http');
const app = express();
const PORT = process.env.PORT || 8080;
const MEDIA_ROOT = process.env.MEDIA_ROOT || '/media';
const UPLOAD_PASSWORD = process.env.UPLOAD_PASSWORD || '';
const JELLYFIN_API_KEY = process.env.JELLYFIN_API_KEY || '';
const JELLYFIN_URL = process.env.JELLYFIN_URL || 'http://jellyfin:8096';
const MAX_FILE_SIZE = parseInt(process.env.MAX_FILE_SIZE) || 21474836480; // 20GB
const TMP_DIR = path.join(MEDIA_ROOT, 'uploads', '.tmp');
const UNSORTED_DIR = path.join(MEDIA_ROOT, 'uploads', 'unsorted');
// Ensure dirs exist
[TMP_DIR, UNSORTED_DIR].forEach(dir => fs.mkdirSync(dir, { recursive: true }));
// Allowed extensions
const AUDIO_EXT = new Set(['.mp3', '.flac', '.wav', '.aac', '.ogg', '.m4a', '.opus', '.wma', '.alac', '.ape']);
const VIDEO_EXT = new Set(['.mkv', '.mp4', '.avi', '.mov', '.m4v', '.wmv', '.ts', '.webm', '.flv', '.mpg', '.mpeg']);
const SUBTITLE_EXT = new Set(['.srt', '.ass', '.ssa', '.sub', '.idx', '.vtt']);
const ALLOWED_EXT = new Set([...AUDIO_EXT, ...VIDEO_EXT, ...SUBTITLE_EXT]);
// Multer disk storage to tmp dir
const storage = multer.diskStorage({
destination: (req, file, cb) => cb(null, TMP_DIR),
filename: (req, file, cb) => {
const unique = Date.now() + '-' + Math.round(Math.random() * 1e6);
cb(null, unique + '-' + file.originalname);
}
});
const upload = multer({
storage,
limits: { fileSize: MAX_FILE_SIZE },
fileFilter: (req, file, cb) => {
const ext = path.extname(file.originalname).toLowerCase();
if (!ALLOWED_EXT.has(ext)) {
return cb(new Error(`File type ${ext} not allowed. Accepted: media files only.`));
}
cb(null, true);
}
});
// Auth middleware
function checkAuth(req, res, next) {
if (!UPLOAD_PASSWORD) return next();
const pw = req.headers['x-upload-password'] || req.query.password;
if (pw !== UPLOAD_PASSWORD) {
return res.status(401).json({ error: 'Invalid password' });
}
next();
}
// Classify file and determine destination
function classifyFile(filename) {
const ext = path.extname(filename).toLowerCase();
const base = path.basename(filename, ext);
if (AUDIO_EXT.has(ext)) {
return { category: 'music', destination: path.join(MEDIA_ROOT, 'music') };
}
if (VIDEO_EXT.has(ext) || SUBTITLE_EXT.has(ext)) {
// Check for TV show patterns: S01E02, 1x02, etc.
const tvMatch = base.match(/^(.+?)[.\s_-]+[Ss](\d{1,2})[Ee](\d{1,3})/);
const tvMatch2 = base.match(/^(.+?)[.\s_-]+(\d{1,2})[xX](\d{1,3})/);
const match = tvMatch || tvMatch2;
if (match) {
const showName = match[1].replace(/[._]/g, ' ').replace(/\s+/g, ' ').trim();
const season = parseInt(match[2]);
const seasonDir = `Season ${String(season).padStart(2, '0')}`;
const dest = path.join(MEDIA_ROOT, 'shows', showName, seasonDir);
return { category: 'show', destination: dest, showName, season };
}
// Default video → movies
return { category: 'movie', destination: path.join(MEDIA_ROOT, 'movies') };
}
return { category: 'unsorted', destination: UNSORTED_DIR };
}
// Move file, falling back to copy+delete if rename fails (cross-device)
async function moveFile(src, destDir, originalName) {
await fs.promises.mkdir(destDir, { recursive: true });
const safeName = path.basename(originalName);
const destPath = path.join(destDir, safeName);
try {
await fs.promises.rename(src, destPath);
} catch (err) {
if (err.code === 'EXDEV') {
await fs.promises.copyFile(src, destPath);
await fs.promises.unlink(src);
} else {
throw err;
}
}
return destPath;
}
// Trigger Jellyfin library scan (fire-and-forget)
function refreshJellyfin() {
if (!JELLYFIN_API_KEY) return;
const url = new URL('/Library/Refresh', JELLYFIN_URL);
const req = http.request(url, {
method: 'POST',
headers: { 'X-Emby-Token': JELLYFIN_API_KEY },
timeout: 5000
});
req.on('error', () => {}); // swallow errors
req.end();
}
// Serve static files
app.use(express.static(path.join(__dirname, 'public')));
// Upload endpoint
app.post('/upload', checkAuth, upload.array('files', 50), async (req, res) => {
if (!req.files || req.files.length === 0) {
return res.status(400).json({ error: 'No files uploaded' });
}
const results = [];
let moved = 0;
for (const file of req.files) {
try {
const classification = classifyFile(file.originalname);
const finalPath = await moveFile(file.path, classification.destination, file.originalname);
moved++;
results.push({
filename: file.originalname,
category: classification.category,
destination: classification.destination.replace(MEDIA_ROOT, ''),
size: file.size
});
console.log(`[SORTED] ${file.originalname}${classification.category} (${classification.destination})`);
} catch (err) {
console.error(`[ERROR] ${file.originalname}: ${err.message}`);
results.push({
filename: file.originalname,
error: err.message
});
}
}
if (moved > 0) refreshJellyfin();
res.json({ results });
});
// Error handler for multer
app.use((err, req, res, next) => {
if (err instanceof multer.MulterError) {
if (err.code === 'LIMIT_FILE_SIZE') {
return res.status(413).json({ error: `File too large. Max size: ${Math.round(MAX_FILE_SIZE / 1e9)}GB` });
}
return res.status(400).json({ error: err.message });
}
if (err) {
return res.status(400).json({ error: err.message });
}
next();
});
app.listen(PORT, () => {
console.log(`Upload service listening on port ${PORT}`);
console.log(`Media root: ${MEDIA_ROOT}`);
console.log(`Auth: ${UPLOAD_PASSWORD ? 'enabled' : 'disabled'}`);
});