jellyfin:修复图片上传失败

This commit is contained in:
Yutousama 2022-07-02 12:26:13 +08:00
parent 72c2752128
commit 3997ee91ac

View File

@ -111,7 +111,7 @@ public class JellyfinAPIManager {
public void uploadImage(File image, String id, String model) {
try {
HashMap<String, String> header = getHeader();
header.put("Content-Type", "image/jpg");
header.put("Content-Type", "image/jpeg");
String url = String.format("http://192.168.31.88:8096/Items/%s/Images/%s",
id,
model
@ -203,7 +203,7 @@ public class JellyfinAPIManager {
public HashMap<String, String> getHeader() {
HashMap<String, String> header = new HashMap<>();
header.put("X-Emby-Authorization", "MediaBrowser Client=\"Jellyfin CLI\", Device=\"Jellyfin-CLI\", DeviceId=\"None\", Version=\"10.7.6\", Token=\""+token+"\"");
header.put("X-Emby-Authorization", "MediaBrowser Client=\"Jellyfin Web\", Device=\"Chrome\", DeviceId=\"TW96aWxsYS81LjAgKFdpbmRvd3MgTlQgMTAuMDsgV2luNjQ7IHg2NCkgQXBwbGVXZWJLaXQvNTM3LjM2IChLSFRNTCwgbGlrZSBHZWNrbykgQ2hyb21lLzg2LjAuNDI0MC43NSBTYWZhcmkvNTM3LjM2fDE2MDI4NDYzMDc5NjE1\", Version=\"10.8.1\",Token=\""+token+"\"");
return header;
}
@ -330,13 +330,7 @@ public class JellyfinAPIManager {
public void login(){
String url="http://192.168.31.88:8096/Users/authenticatebyname";
Map<String, String> header = new HashMap<>();
header.put("content-type", "application/json");
header.put("accept", "application/json");
header.put("Connection", "keep-alive");
header.put("User-Agent", HttpTools.getUa());
header.put("Origin", "http://192.168.31.88:8096");
header.put("X-Emby-Authorization", "MediaBrowser Client=\"Jellyfin Web\", Device=\"Chrome\", DeviceId=\"TW96aWxsYS81LjAgKFdpbmRvd3MgTlQgMTAuMDsgV2luNjQ7IHg2NCkgQXBwbGVXZWJLaXQvNTM3LjM2IChLSFRNTCwgbGlrZSBHZWNrbykgQ2hyb21lLzg2LjAuNDI0MC43NSBTYWZhcmkvNTM3LjM2fDE2MDI4NDYzMDc5NjE1\", Version=\"10.8.1\"");
HashMap<String, String> header=getHttpHeader();
JSONObject json=new JSONObject();
json.put("Pw","34864394");
json.put("Username","home");
@ -345,12 +339,22 @@ public class JellyfinAPIManager {
token=json.getString("AccessToken");
userId=json.getJSONObject("User").getString("Id");
}
private HashMap<String, String> getHttpHeader(){
HashMap<String, String> header = new HashMap<>();
header.put("content-type", "application/json");
header.put("accept", "application/json");
header.put("Connection", "keep-alive");
header.put("User-Agent", HttpTools.getUa());
header.put("Origin", "http://192.168.31.88:8096");
header.put("X-Emby-Authorization", "MediaBrowser Client=\"Jellyfin Web\", Device=\"Chrome\", DeviceId=\"TW96aWxsYS81LjAgKFdpbmRvd3MgTlQgMTAuMDsgV2luNjQ7IHg2NCkgQXBwbGVXZWJLaXQvNTM3LjM2IChLSFRNTCwgbGlrZSBHZWNrbykgQ2hyb21lLzg2LjAuNDI0MC43NSBTYWZhcmkvNTM3LjM2fDE2MDI4NDYzMDc5NjE1\", Version=\"10.8.1\"");
return header;
}
public static void main(String[] args) {
File file = new File("Z:\\download\\anim\\夏日重现");
File file = new File("Z:\\download\\anim\\神渣☆偶像");
//new JellyfinAPIManager().search(file.getName(), file);
JellyfinAPIManager manager = new JellyfinAPIManager();
manager.init(file,"326895");
manager.init(file,"359985");
// JSONArray search = manager.getAnimPaths();
// System.out.println(search);
}