jellyfin:改为登录后获取token
This commit is contained in:
parent
81f91f756a
commit
72c2752128
@ -12,7 +12,7 @@ import org.springframework.context.annotation.Import;
|
|||||||
@Import(BTDownloadManager.class)
|
@Import(BTDownloadManager.class)
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
public class NasApplication {
|
public class NasApplication {
|
||||||
public static final String version = "1.2.14";
|
public static final String version = "1.2.15";
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(NasApplication.class, args);
|
SpringApplication.run(NasApplication.class, args);
|
||||||
|
@ -2,9 +2,7 @@ package com.yutou.nas.utils;
|
|||||||
|
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.yutou.nas.interfaces.DownloadInterface;
|
import com.yutou.nas.interfaces.DownloadInterface;
|
||||||
import com.yutou.nas.utils.Interfaces.NetworkInterface;
|
|
||||||
|
|
||||||
import javax.net.ssl.HttpsURLConnection;
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
@ -33,7 +31,7 @@ public class HttpTools {
|
|||||||
try {
|
try {
|
||||||
URLConnection connection;
|
URLConnection connection;
|
||||||
connection = new URL(url).openConnection();
|
connection = new URL(url).openConnection();
|
||||||
connection.setRequestProperty("User-Agent", getExtUa());
|
connection.setRequestProperty("User-Agent", getUa());
|
||||||
if (header != null) {
|
if (header != null) {
|
||||||
for (String key : header.keySet()) {
|
for (String key : header.keySet()) {
|
||||||
connection.addRequestProperty(key, header.get(key));
|
connection.addRequestProperty(key, header.get(key));
|
||||||
@ -68,7 +66,7 @@ public class HttpTools {
|
|||||||
}
|
}
|
||||||
connection.setDoOutput(true);
|
connection.setDoOutput(true);
|
||||||
connection.setDoInput(true);
|
connection.setDoInput(true);
|
||||||
connection.addRequestProperty("User-Agent", getExtUa());
|
connection.addRequestProperty("User-Agent", getUa());
|
||||||
connection.setConnectTimeout(5 * 1000);
|
connection.setConnectTimeout(5 * 1000);
|
||||||
connection.setReadTimeout(10 * 1000);
|
connection.setReadTimeout(10 * 1000);
|
||||||
//connection.addRequestProperty("Connection", "keep-alive");
|
//connection.addRequestProperty("Connection", "keep-alive");
|
||||||
@ -100,8 +98,8 @@ public class HttpTools {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getExtUa() {
|
public static String getUa() {
|
||||||
return "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36";
|
return "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36";
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getKuKuUA() {
|
private static String getKuKuUA() {
|
||||||
@ -165,7 +163,7 @@ public class HttpTools {
|
|||||||
}
|
}
|
||||||
Log.i("DOWNLOAD", "下载文件:" + url + " 保存文件:" + saveName);
|
Log.i("DOWNLOAD", "下载文件:" + url + " 保存文件:" + saveName);
|
||||||
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
|
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
|
||||||
connection.addRequestProperty("User-Agent", getExtUa());
|
connection.addRequestProperty("User-Agent", getUa());
|
||||||
// Log.i(TAG,"获取到网络请求:"+connection.getResponseCode());
|
// Log.i(TAG,"获取到网络请求:"+connection.getResponseCode());
|
||||||
|
|
||||||
|
|
||||||
@ -222,7 +220,7 @@ public class HttpTools {
|
|||||||
}
|
}
|
||||||
Log.i("DOWNLOAD", "下载文件:" + url + " 保存文件:" + saveName);
|
Log.i("DOWNLOAD", "下载文件:" + url + " 保存文件:" + saveName);
|
||||||
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
|
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
|
||||||
connection.addRequestProperty("User-Agent", getExtUa());
|
connection.addRequestProperty("User-Agent", getUa());
|
||||||
// Log.i(TAG,"获取到网络请求:"+connection.getResponseCode());
|
// Log.i(TAG,"获取到网络请求:"+connection.getResponseCode());
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,10 +18,11 @@ import java.util.*;
|
|||||||
|
|
||||||
public class JellyfinAPIManager {
|
public class JellyfinAPIManager {
|
||||||
private List<LibsItem> mediaItem = new ArrayList<>();
|
private List<LibsItem> mediaItem = new ArrayList<>();
|
||||||
private static final String userId="389438aeda0a4972ac66a23cbe5c289c";
|
private static String userId="389438aeda0a4972ac66a23cbe5c289c";
|
||||||
private static final String token="7f8efec6c950415cbaa8a0b54b3a832b";
|
private static String token="7f8efec6c950415cbaa8a0b54b3a832b";
|
||||||
|
|
||||||
public JellyfinAPIManager() {
|
public JellyfinAPIManager() {
|
||||||
|
login();
|
||||||
mediaItem = getAllItem();
|
mediaItem = getAllItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -327,6 +328,24 @@ public class JellyfinAPIManager {
|
|||||||
|
|
||||||
public static String mainPath = "Z:\\download\\anim\\";
|
public static String mainPath = "Z:\\download\\anim\\";
|
||||||
|
|
||||||
|
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\"");
|
||||||
|
JSONObject json=new JSONObject();
|
||||||
|
json.put("Pw","34864394");
|
||||||
|
json.put("Username","home");
|
||||||
|
String post = HttpTools.http_post(url, json.toJSONString().getBytes(StandardCharsets.UTF_8), 3, header);
|
||||||
|
json=JSONObject.parseObject(post,JSONObject.class);
|
||||||
|
token=json.getString("AccessToken");
|
||||||
|
userId=json.getJSONObject("User").getString("Id");
|
||||||
|
}
|
||||||
|
|
||||||
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);
|
||||||
|
Loading…
Reference in New Issue
Block a user