add download Jellyfin for Android Apk

This commit is contained in:
Yutousama 2022-11-04 16:08:03 +08:00
parent 56e55bab44
commit ee089312f2

View File

@ -1,13 +1,13 @@
package com.yutou.nas.Controllers; package com.yutou.nas.Controllers;
import com.yutou.nas.utils.AppTools; import com.alibaba.fastjson2.JSONObject;
import com.yutou.nas.utils.JellyfinAPIManager; import com.yutou.nas.utils.*;
import com.yutou.nas.utils.QQBotManager;
import com.yutou.nas.utils.StringUtils;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import java.io.File;
@Controller @Controller
public class JellyfinController { public class JellyfinController {
@RequestMapping("/jellyfin/addItem") @RequestMapping("/jellyfin/addItem")
@ -28,4 +28,36 @@ public class JellyfinController {
new JellyfinAPIManager().refresh(); new JellyfinAPIManager().refresh();
return "ok"; 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;
}
} }