Created
May 21, 2026 23:37
-
-
Save shmick/f935fb570231542630b4e747801ec451 to your computer and use it in GitHub Desktop.
Use HDHomeRun EPG with Jellyfin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| set -euo pipefail | |
| OUTPUT="/mnt/pool0/docker-vols/jellyfin/config/hdhr-epg.xml" | |
| TMPFILE="$(mktemp)" | |
| IPS=("192.168.1.31" "192.168.1.32") | |
| AUTH="" | |
| SUCCESS=0 | |
| log() { | |
| echo "[$(date '+%Y-%m-%d %H:%M:%S')] $*" | |
| } | |
| # Try each device until we get a valid DeviceAuth | |
| for ip in "${IPS[@]}"; do | |
| log "Trying HDHomeRun at $ip" | |
| AUTH=$(curl -fsS --max-time 5 "http://$ip/discover.json" | jq -r '.DeviceAuth' || true) | |
| if [[ -n "$AUTH" && "$AUTH" != "null" ]]; then | |
| log "Got DeviceAuth from $ip" | |
| # Download XMLTV data | |
| if curl -fsS --max-time 20 \ | |
| -H 'Accept-Encoding: gzip' --compressed \ | |
| "https://api.hdhomerun.com/api/xmltv?DeviceAuth=$AUTH" \ | |
| -o "$TMPFILE"; then | |
| # Validate XML | |
| if xmllint --noout "$TMPFILE" 2>/dev/null; then | |
| log "XML validated successfully" | |
| SUCCESS=1 | |
| break | |
| else | |
| log "Invalid XML from $ip, trying next..." | |
| fi | |
| else | |
| log "Failed to download XML from API using auth from $ip" | |
| fi | |
| else | |
| log "Failed to get DeviceAuth from $ip" | |
| fi | |
| done | |
| # Replace the file only if everything succeeded | |
| if [[ $SUCCESS -eq 1 ]]; then | |
| mv "$TMPFILE" "$OUTPUT" | |
| log "EPG successfully updated at $OUTPUT" | |
| else | |
| log "Failed to update EPG from all sources" | |
| rm -f "$TMPFILE" | |
| exit 1 | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment