diff --git a/server/controllers/other.go b/server/controllers/other.go index 24cf7dac..05bad442 100644 --- a/server/controllers/other.go +++ b/server/controllers/other.go @@ -1,10 +1,60 @@ package controllers import ( + "encoding/base64" + "fmt" "github.com/Xhofe/alist/conf" + "github.com/Xhofe/alist/server/common" + "github.com/Xhofe/alist/utils" "github.com/gin-gonic/gin" + "strings" ) func Favicon(c *gin.Context) { c.Redirect(302, conf.GetStr("favicon")) } + +func Plist(c *gin.Context) { + data := c.Param("data") + bytes, err := base64.StdEncoding.DecodeString(data) + if err != nil { + common.ErrorResp(c, err, 500) + return + } + u := string(bytes) + name := utils.Base(u) + name = strings.TrimRight(name, ".ipa") + plist := fmt.Sprintf(` + + + items + + + assets + + + kind + software-package + url + %s + + + metadata + + bundle-identifier + ci.nn.alist-doc + bundle-version + 1 + kind + software + title + %s + + + + +`, u, name) + c.Status(200) + c.Header("Content-Type", "application/xml;charset=utf-8") + _, _ = c.Writer.WriteString(plist) +} diff --git a/server/router.go b/server/router.go index 2f0aae0d..3dc669af 100644 --- a/server/router.go +++ b/server/router.go @@ -16,6 +16,7 @@ func InitApiRouter(r *gin.Engine) { r.GET("/d/*path", middlewares.DownCheck, controllers.Down) r.GET("/p/*path", middlewares.DownCheck, controllers.Proxy) r.GET("/favicon.ico", controllers.Favicon) + r.GET("/i/:data/ipa.plist", controllers.Plist) api := r.Group("/api") public := api.Group("/public")