Files
MeBox/internal/handler/nfo.go
T
truewhile 44ca451cd4 优化
优化
2026-08-24 17:40:43 +08:00

33 lines
848 B
Go

// Package handler — NFO export endpoints (Kodi / Jellyfin compatibility).
package handler
import (
"net/http"
"github.com/gin-gonic/gin"
"github.com/ShukeBta/MMTL/internal/service"
)
func exportNFOHandler(svc *service.Container) gin.HandlerFunc {
return func(c *gin.Context) {
path, err := svc.NFO.ExportOne(c.Request.Context(), c.Param("id"))
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
c.JSON(http.StatusOK, gin.H{"path": path})
}
}
func exportLibraryNFOHandler(svc *service.Container) gin.HandlerFunc {
return func(c *gin.Context) {
written, err := svc.NFO.ExportLibrary(c.Request.Context(), c.Param("id"))
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
c.JSON(http.StatusOK, gin.H{"written": written})
}
}