From ee089312f2464ea67e06bf2df8b83c2f47a8d3bc Mon Sep 17 00:00:00 2001 From: Yutousama <583819556@qq.com> Date: Fri, 4 Nov 2022 16:08:03 +0800 Subject: [PATCH] add download Jellyfin for Android Apk --- .../nas/Controllers/JellyfinController.java | 40 +++++++++++++++++-- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/yutou/nas/Controllers/JellyfinController.java b/src/main/java/com/yutou/nas/Controllers/JellyfinController.java index b405721..0e2fe8c 100644 --- a/src/main/java/com/yutou/nas/Controllers/JellyfinController.java +++ b/src/main/java/com/yutou/nas/Controllers/JellyfinController.java @@ -1,13 +1,13 @@ package com.yutou.nas.Controllers; -import com.yutou.nas.utils.AppTools; -import com.yutou.nas.utils.JellyfinAPIManager; -import com.yutou.nas.utils.QQBotManager; -import com.yutou.nas.utils.StringUtils; +import com.alibaba.fastjson2.JSONObject; +import com.yutou.nas.utils.*; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; +import java.io.File; + @Controller public class JellyfinController { @RequestMapping("/jellyfin/addItem") @@ -28,4 +28,36 @@ public class JellyfinController { new JellyfinAPIManager().refresh(); return "ok"; } + @ResponseBody + @RequestMapping("/jellyfin/setAppVersion") + public String setAppVersion(String version){ + RedisTools.set("jellyfin_app_version",version); + return ""; + } + @ResponseBody + @RequestMapping("/jellyfin/updateApp.do") + public JSONObject updateApp(String version){ + JSONObject json=new JSONObject(); + String appVersion=RedisTools.get("jellyfin_app_version"); + if(appVersion==null){ + json.put("code",0); + }else{ + File dir=new File("web"+File.separator+"apk"+File.separator+"jellyfin"+File.separator); + json.put("code",0); + if(dir.exists()){ + for (File file : dir.listFiles()) { + if(file.getName().endsWith(".apk")){ + json.put("code",1); + JSONObject data=new JSONObject(); + data.put("version",appVersion); + data.put("url","http://nas.cnmglz.com:9999/apk"+file.getAbsolutePath().replace(new File("web"+File.separator+"apk"+File.separator).getAbsolutePath(),"")); + json.put("data",data); + break; + } + } + } + + } + return json; + } }