Add NixOS module and deployment guide for lidarr-mb-gap

- Introduced a new NixOS module for the lidarr-mb-gap service, allowing users to configure and manage the report generation process through NixOS.
- Added a comprehensive deployment guide in `nixos/DEPLOYMENT.md`, detailing setup instructions, configuration options, and troubleshooting tips for deploying the service on NixOS and serving reports via Caddy.
- Updated `flake.nix` to export the new NixOS module.
- Enhanced the report generation scripts to support customizable output paths for generated reports.
This commit is contained in:
Danilo Reyes
2025-11-11 11:04:01 -06:00
parent d38fb12e17
commit e6f96107aa
5 changed files with 438 additions and 7 deletions

View File

@@ -2,12 +2,15 @@
import logging
from html import escape
from pathlib import Path
from typing import Dict, List
logger = logging.getLogger(__name__)
def generate_html_report(albums_to_add: List[Dict], albums_to_update: List[Dict]):
def generate_html_report(
albums_to_add: List[Dict], albums_to_update: List[Dict], output_path: Path = Path("missing_albums.html")
):
"""Generate an HTML report with clickable submission links"""
html_content = """<!DOCTYPE html>
<html lang="en">
@@ -355,6 +358,6 @@ def generate_html_report(albums_to_add: List[Dict], albums_to_update: List[Dict]
html_footer = "\n</body>\n</html>\n"
html_content = html_header + albums_html + html_footer
with open("missing_albums.html", "w", encoding="utf-8") as f:
with open(output_path, "w", encoding="utf-8") as f:
f.write(html_content)
logger.info("HTML report saved to missing_albums.html")
logger.info(f"HTML report saved to {output_path}")

View File

@@ -8,6 +8,7 @@ import json
import logging
import os
import sys
from pathlib import Path
from typing import Dict, List, Optional, Tuple
from urllib.parse import quote
@@ -260,6 +261,10 @@ def main():
LIDARR_API_KEY = os.getenv("LIDARR_API_KEY")
SAMBL_URL = os.getenv("SAMBL_URL") or None
MAX_ARTISTS = int(os.getenv("MAX_ARTISTS", "5"))
OUTPUT_DIR = os.getenv("OUTPUT_DIR", ".")
output_dir = Path(OUTPUT_DIR)
output_dir.mkdir(parents=True, exist_ok=True)
if not LIDARR_URL:
logger.error("LIDARR_URL not set")
@@ -347,11 +352,13 @@ def main():
"total": len(all_albums),
},
}
with open("missing_albums.json", "w", encoding="utf-8") as f:
json_path = output_dir / "missing_albums.json"
with open(json_path, "w", encoding="utf-8") as f:
json.dump(output_data, f, indent=2, ensure_ascii=False)
logger.info("Results saved to missing_albums.json")
logger.info(f"Results saved to {json_path}")
generate_html_report(all_albums_to_add, all_albums_to_update)
html_path = output_dir / "missing_albums.html"
generate_html_report(all_albums_to_add, all_albums_to_update, html_path)
if __name__ == "__main__":