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) { public void uploadImage(File image, String id, String model) {
try { try {
HashMap<String, String> header = getHeader(); 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", String url = String.format("http://192.168.31.88:8096/Items/%s/Images/%s",
id, id,
model model
@ -203,7 +203,7 @@ public class JellyfinAPIManager {
public HashMap<String, String> getHeader() { public HashMap<String, String> getHeader() {
HashMap<String, String> header = new HashMap<>(); 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; return header;
} }
@ -330,13 +330,7 @@ public class JellyfinAPIManager {
public void login(){ public void login(){
String url="http://192.168.31.88:8096/Users/authenticatebyname"; String url="http://192.168.31.88:8096/Users/authenticatebyname";
Map<String, String> header = new HashMap<>(); HashMap<String, String> header=getHttpHeader();
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\"");
JSONObject json=new JSONObject(); JSONObject json=new JSONObject();
json.put("Pw","34864394"); json.put("Pw","34864394");
json.put("Username","home"); json.put("Username","home");
@ -345,12 +339,22 @@ public class JellyfinAPIManager {
token=json.getString("AccessToken"); token=json.getString("AccessToken");
userId=json.getJSONObject("User").getString("Id"); 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) { 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); //new JellyfinAPIManager().search(file.getName(), file);
JellyfinAPIManager manager = new JellyfinAPIManager(); JellyfinAPIManager manager = new JellyfinAPIManager();
manager.init(file,"326895"); manager.init(file,"359985");
// JSONArray search = manager.getAnimPaths(); // JSONArray search = manager.getAnimPaths();
// System.out.println(search); // System.out.println(search);
} }