84 lines
2.7 KiB
YAML
84 lines
2.7 KiB
YAML
apiVersion: v1
|
|
kind: ConfigMap
|
|
metadata:
|
|
name: droppedneedle-transcoder-script
|
|
namespace: default
|
|
data:
|
|
transcode.sh: |
|
|
#!/bin/bash
|
|
WATCH_DIR="/music"
|
|
echo "Starting transcoder watch on $WATCH_DIR..."
|
|
|
|
inotifywait -m -r -e moved_to,close_write --format '%w%f' "$WATCH_DIR" | while read FILE
|
|
do
|
|
if [[ "${FILE,,}" == *.flac ]]; then
|
|
echo "Detected new FLAC via import: $FILE"
|
|
OPUS_FILE="${FILE%.*}.opus"
|
|
|
|
ffmpeg -y -i "$FILE" -acodec libopus -ac 2 -ab 160k "$OPUS_FILE"
|
|
|
|
if [ $? -eq 0 ]; then
|
|
echo "Transcode successful. Removing original FLAC..."
|
|
rm "$FILE"
|
|
|
|
echo "Triggering authenticated DroppedNeedle library scan..."
|
|
# 1. Authenticate and save the session cookie to a temporary jar
|
|
curl -s -X POST http://droppedneedle.default.svc.cluster.local:80/api/v1/auth/login \
|
|
-H "Content-Type: application/json" \
|
|
-d "{\"username\": \"$SERVICE_USER\", \"password\": \"$SERVICE_PASS\"}" \
|
|
-c /tmp/dn_cookies.txt
|
|
|
|
# 2. Trigger the scan using the saved session cookie
|
|
curl -s -X POST http://droppedneedle.default.svc.cluster.local:80/api/v1/library/scan/start \
|
|
-b /tmp/dn_cookies.txt
|
|
|
|
# 3. Clean up the cookie jar
|
|
rm /tmp/dn_cookies.txt
|
|
else
|
|
echo "Error: FFmpeg transcode failed for $FILE"
|
|
fi
|
|
fi
|
|
done
|
|
---
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: droppedneedle-transcoder
|
|
annotations:
|
|
keel.sh/policy: "all"
|
|
keel.sh/match-tag: "true"
|
|
keel.sh/schedule: "0 3 * * *"
|
|
spec:
|
|
replicas: 1
|
|
selector:
|
|
matchLabels:
|
|
app: droppedneedle-transcoder
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app: droppedneedle-transcoder
|
|
spec:
|
|
nodeSelector:
|
|
kubernetes.io/hostname: robin
|
|
containers:
|
|
- name: transcoder
|
|
image: alpine:latest
|
|
command: ["/bin/sh", "-c"]
|
|
args:
|
|
- "apk add --no-cache bash inotify-tools ffmpeg curl && bash /scripts/transcode.sh"
|
|
envFrom:
|
|
- secretRef:
|
|
name: droppedneedle-secret
|
|
volumeMounts:
|
|
- mountPath: /music
|
|
name: yarr
|
|
- mountPath: /scripts
|
|
name: script-volume
|
|
restartPolicy: Always
|
|
volumes:
|
|
- name: yarr
|
|
persistentVolumeClaim:
|
|
claimName: droppedneedle-transcode-pvc
|
|
- name: script-volume
|
|
configMap:
|
|
name: droppedneedle-transcoder-script
|