新增对Jellyfin的搜刮(但未完成自动化)

This commit is contained in:
Yutousama 2021-09-30 09:32:51 +08:00
parent f30530d61d
commit ef1ba6f61f
14 changed files with 446 additions and 113 deletions

21
pom.xml
View File

@ -144,6 +144,25 @@
<sourceDirectory>${project.basedir}/src/main/java</sourceDirectory>
<!-- <testSourceDirectory>${project.basedir}/src/test/java</testSourceDirectory>-->
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo>复制正式文件</echo>
<copy file="src/main/resources/application.properties.release" tofile="${project.build.outputDirectory}/application.properties" overwrite="true"/>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
@ -184,7 +203,7 @@
<configuration>
<outputDirectory>
Z:\servier\tools\
X:\servier\tools\
</outputDirectory>
</configuration>

View File

@ -1,5 +1,5 @@
package com.yutou.nas.Datas;
public class AppData {
public static String defaultMusicPath = "/media/yutou/4t/public/音乐";
public static String defaultMusicPath = "/media/yutou/disk_lvm/public/音乐";
}

View File

@ -12,7 +12,7 @@ import org.springframework.context.annotation.Import;
@Import(BTDownloadManager.class)
@SpringBootApplication
public class NasApplication {
public static final String version="1.1.6";
public static final String version="1.1.9";
public static void main(String[] args) {
SpringApplication.run(NasApplication.class, args);
AppData.defaultMusicPath = (String) ConfigTools.load(ConfigTools.CONFIG, "musicDir");

View File

@ -6,10 +6,7 @@ import com.yutou.nas.mybatis.model.MusicData;
import com.yutou.nas.mybatis.model.MusicDataExample;
import com.yutou.nas.Services.IMusicToolsService;
import com.yutou.nas.utils.ConfigTools;
import com.yutou.nas.utils.OSSManager;
import com.yutou.nas.utils.QQBotManager;
import com.yutou.nas.utils.Tools;
import com.yutou.nas.utils.*;
import ealvatag.audio.AudioFile;
import ealvatag.audio.AudioFileIO;
import ealvatag.audio.AudioHeader;
@ -22,7 +19,6 @@ import net.bramp.ffmpeg.probe.FFmpegFormat;
import net.bramp.ffmpeg.probe.FFmpegProbeResult;
import net.bramp.ffmpeg.probe.FFmpegStream;
import org.springframework.stereotype.Service;
import com.yutou.nas.utils.StringUtils;
import javax.annotation.Resource;
import java.io.File;
@ -39,7 +35,7 @@ public class MusicToolsServiceImpl implements IMusicToolsService {
public static final int FIND_TITLE = 1;
public static final int FIND_ARTIST = 2;
private String musicPath = "/media/yutou/4t/public/音乐";
private String musicPath = "/media/yutou/disk_lvm/public/音乐";
private boolean isScan = false;
@Resource
@ -75,6 +71,10 @@ public class MusicToolsServiceImpl implements IMusicToolsService {
private void scan(File path) {
if(!path.exists()){
Log.i("MusicScan","文件夹不存在,取消扫描");
return;
}
if (path.isFile()) {
add(path);
} else if (path.isDirectory()) {

View File

@ -2,10 +2,7 @@ package com.yutou.nas.bangumi;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yutou.nas.utils.HttpTools;
import com.yutou.nas.utils.RedisTools;
import com.yutou.nas.utils.Tools;
import com.yutou.nas.utils.StringUtils;
import com.yutou.nas.utils.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@ -63,6 +60,48 @@ public class BangumiTools {
return JSONObject.parseObject(str);
}
public static JSONArray getPeople(int id) {
/**
* Actor 演员
* Composer 作曲家
* Director 导演
* GuestStar 特邀明星
* Producer 制片人
* Writer 编剧
*/
JSONArray people = new JSONArray();
JSONObject bangumi = getBangumiInfo(id);
JSONArray crt = bangumi.getJSONArray("crt");
for (Object o : crt) {
JSONObject item = (JSONObject) o;
JSONObject pel = new JSONObject();
pel.put("Name", item.getString("name_cn"));
pel.put("Role", item.getString("role_name"));
pel.put("Type", "Actor");
people.add(pel);
}
crt = bangumi.getJSONArray("staff");
for (Object o : crt) {
JSONObject item = (JSONObject) o;
JSONObject pel = new JSONObject();
pel.put("Name", item.getString("name_cn"));
String jobsName="";
for (Object _jobs : item.getJSONArray("jobs")) {
jobsName+=_jobs+"";
}
jobsName=jobsName.substring(0,jobsName.length()-1);
pel.put("Role", jobsName);
pel.put("Type", "");
if (jobsName.contains("导演")) {
pel.put("Type", "Director");
} else if (jobsName.contains("脚本")) {
pel.put("Type", "DirectorDirector");
}
people.add(pel);
}
return people;
}
/**
* 搜索番剧
*
@ -106,10 +145,10 @@ public class BangumiTools {
* @return 详细内容
*/
public static List<String> reportBangumiInfo(int id) {
List<String> bangumiList=new ArrayList<>();
List<String> bangumiList = new ArrayList<>();
JSONObject json = getBangumiInfo(id);
if(json.containsKey("code")){
bangumiList.add("error = "+json.toJSONString());
if (json.containsKey("code")) {
bangumiList.add("error = " + json.toJSONString());
return bangumiList;
}
JSONArray eps = json.getJSONArray("eps");
@ -190,44 +229,45 @@ public class BangumiTools {
/**
* 格式化输出新番列表
*
* @return 新番信息
*/
public static String reportBangumiList(){
public static String reportBangumiList() {
try {
JSONObject json=getBangumi(-1);
StringBuilder builder=new StringBuilder();
JSONObject json = getBangumi(-1);
StringBuilder builder = new StringBuilder();
assert json != null;
JSONArray array=json.getJSONArray("bangumi");
JSONArray array = json.getJSONArray("bangumi");
for (Object o : array) {
JSONObject data= (JSONObject) o;
JSONObject weekday=data.getJSONObject("weekday");
JSONArray items=data.getJSONArray("items");
JSONObject data = (JSONObject) o;
JSONObject weekday = data.getJSONObject("weekday");
JSONArray items = data.getJSONArray("items");
builder.append(weekday.getString("cn")).append("(").append(weekday.getString("ja")).append(")");
builder.append(":").append("\n");
reportBangumi(builder, items,false);
reportBangumi(builder, items, false);
builder.append("\n");
}
return builder.toString();
}catch (Exception e){
} catch (Exception e) {
e.printStackTrace();
return e.getMessage();
}
}
private static void reportBangumi(StringBuilder builder, JSONArray items,boolean reportEp) {
private static void reportBangumi(StringBuilder builder, JSONArray items, boolean reportEp) {
int epIndex = 0;
String epName = "N/A";
for (Object oj : items) {
JSONObject item = (JSONObject) oj;
builder.append("[").append(item.getInteger("id")).append("]");
builder.append(StringUtils.isEmpty(item.getString("name_cn"))
?item.getString("name"):item.getString("name_cn"));
if(!reportEp){
? item.getString("name") : item.getString("name_cn"));
if (!reportEp) {
builder.append("\n");
continue;
}
JSONObject info=getBangumiInfo(item.getInteger("id"));
if(info.get("eps")==null){
JSONObject info = getBangumiInfo(item.getInteger("id"));
if (info.get("eps") == null) {
continue;
}
JSONArray eps = info.getJSONArray("eps");
@ -264,7 +304,7 @@ public class BangumiTools {
JSONArray items = toDay.getJSONArray("items");
builder.append("今日 ").append(weekday.get("cn")).append("(").append(weekday.get("ja")).append(")");
builder.append(" 放送列表:").append("\n");
reportBangumi(builder, items,true);
reportBangumi(builder, items, true);
}
RedisTools.set("toDayBangumi", builder.toString());
return builder.toString();
@ -281,7 +321,7 @@ public class BangumiTools {
* @return 详细内容
*/
public static List<String> reportSearchBangumi(String key) {
List<String> bangumiList=new ArrayList<>();
List<String> bangumiList = new ArrayList<>();
JSONObject main = search(key);
if (main.getInteger("results") > 0) {
StringBuilder builder = new StringBuilder();
@ -289,7 +329,7 @@ public class BangumiTools {
Collections.reverse(list);
for (Object items : list) {
JSONObject item = (JSONObject) items;
builder=new StringBuilder();
builder = new StringBuilder();
builder.append("标题:").append(item.getString("name_cn")).append("\n");
builder.append("日文标题:").append(item.getString("name")).append("\n");
String type;
@ -332,10 +372,36 @@ public class BangumiTools {
}
}
public static void main(String[] args) {
RedisTools.remove("reportToDayBangumi");
String str = reportToDayBangumi();
System.out.println(str);
public static void saveInfoToJellyfin(String name) {
JSONObject json = search(name);
JSONArray array = json.getJSONArray("list");
int id = 0;
StringBuilder bangumiName = new StringBuilder();
for (Object o : array) {
JSONObject _item = (JSONObject) o;
bangumiName.append(_item.getString("name_cn"))
.append(":")
.append(QQBotManager.QQCommands.QQ_BANGUMI_INFO)
.append(_item.getString("id"))
.append("\n");
if (_item.getString("name_cn").equals(name)) {
id = _item.getInteger("id");
break;
}
}
if (id == 0) {
QQBotManager.getInstance().sendMessage("没有与《" + name + "》完全匹配的信息,请填写。 \n" + bangumiName.toString());
return;
}
json = getBangumiInfo(id);
}
public static void main(String[] args) {
JSONObject json = search("小林家的龙女仆S");
System.out.println(json);
json = getBangumiInfo(274234);
System.err.println("------------");
System.out.println(json);
}
}

View File

@ -151,5 +151,10 @@ public class tools {
videoToolsService.scanVideo();
return "ok";
}
@ResponseBody
@RequestMapping("/public/getUPSPower.do")
public float getUPSPower(){
return Tools.getSystemUPSPower();
}
}

View File

@ -26,12 +26,30 @@ public class ApplicationInit implements ApplicationRunner {
public void run(ApplicationArguments args) throws Exception {
AudioTools.init();
new Timer().schedule(new TimerTask() {
boolean powerOffice=false;
boolean powerLow=false;
@Override
public void run() {
String time = new SimpleDateFormat("HH:mm").format(new Date());
if (time.equals(oldTime)) {
return;
}
float power=Tools.getSystemUPSPower();
if(power>0) {
if (power == 100) {
AppTools.exec("wakeonlan 00:F0:D2:D0:6B:B5", null, false, true);
powerLow=false;
powerOffice=false;
}
if (power < 99 && !powerOffice) {
powerOffice = true;
QQBotManager.getInstance().sendMessage("UPS进入电池模式:" + power);
}
if (power < 50 && !powerLow) {
powerLow = true;
QQBotManager.getInstance().sendMessage("UPS电池低于50%,即将关机");
}
}
oldTime = time;
switch (time) {
case "00:00":

View File

@ -11,8 +11,8 @@ public class AudioTools {
}
SpeechUtility.createUtility(SpeechConstant.APPID + "=601f7f7d");
SpeechUtility.getUtility().setParameter(SpeechConstant.VOLUME,"100");
SpeechUtility.getUtility().setParameter(SpeechConstant.LIB_NAME_64,"/media/yutou/4t/public/servier/tools/");
SpeechUtility.getUtility().setParameter(SpeechConstant.LIB_NAME_32,"/media/yutou/4t/public/servier/tools/");
SpeechUtility.getUtility().setParameter(SpeechConstant.LIB_NAME_64,"/media/yutou/disk_lvm/public/servier/tools/");
SpeechUtility.getUtility().setParameter(SpeechConstant.LIB_NAME_32,"/media/yutou/disk_lvm/public/servier/tools/");
init = true;
com.yutou.nas.utils.Log.i("讯飞语音已初始化");
}

View File

@ -23,6 +23,7 @@ public class BTDownloadManager implements ApplicationContextAware {
@Resource
IBangumiService bangumiService;
private static BTDownloadManager manager;
private static final String DownloadHomePath="/media/yutou/disk_lvm/public/";
public static BTDownloadManager getInstance() {
if (manager == null) {
@ -41,6 +42,11 @@ public class BTDownloadManager implements ApplicationContextAware {
List<BangumiItem> list = bangumiService.getAllBangumi();
AnimationData data = new AnimationData();
Log.i("BT","启动BT检测总数:"+list.size());
File path=new File(DownloadHomePath);
if(!path.exists()){
Log.i("BT","下载目录已离线,取消扫描");
return;
}
for (BangumiItem item : list) {
if(item.getEnable()==0){
continue;
@ -119,16 +125,18 @@ public class BTDownloadManager implements ApplicationContextAware {
public boolean download(String title, String url) {
try {
String exec = String.format("transmission-remote -n yutou:34864394 -w /media/yutou/4t/public/download/anim/%s -a \"%s\" "
String exec = String.format("transmission-remote -n yutou:34864394 -w %sanim/%s -a \"%s\" "
,DownloadHomePath
, title
, url
);
Log.i(exec);
Runtime.getRuntime().exec(new String[]{"sh"
Process process=Runtime.getRuntime().exec(new String[]{"sh"
, "-c"
, exec});
process.exitValue();
return true;
} catch (IOException e) {
} catch (Exception e) {
e.printStackTrace();
}
return false;

View File

@ -3,7 +3,6 @@ package com.yutou.nas.utils;
import com.alibaba.fastjson.JSONObject;
import com.yutou.nas.interfaces.DownloadInterface;
import com.yutou.nas.utils.Interfaces.NetworkInterface;
import com.yutou.nas.utils.StringUtils;
import javax.net.ssl.HttpsURLConnection;
import java.io.*;
@ -11,25 +10,35 @@ import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.util.Map;
import java.util.Set;
public class HttpTools {
public static final String serverKey="zIrsh9TUZP2lfRW753PannG49E7VJvor";
private static final int HttpRequestIndex=3;
public static final String serverKey = "zIrsh9TUZP2lfRW753PannG49E7VJvor";
private static final int HttpRequestIndex = 3;
public static String get(String url){
return new HttpTools().http_get(url,0);
public static String get(String url) {
return https_get(url, null);
}
public static void post(final String url, final byte[] body, final NetworkInterface networkInterface){
new HttpTools().http_post(url, body,0, networkInterface);
public static String post(final String url, final byte[] body) {
return http_post(url, body, 0, null);
}
public static File syncDownload(final String url, final String saveName){
public static File syncDownload(final String url, final String saveName) {
return new HttpTools().http_syncDownload(url, saveName);
}
public String http_get(String url,int index) {
public static String https_get(String url, Map<String, String> header) {
try {
HttpsURLConnection connection = (HttpsURLConnection) new URL(url).openConnection();
URLConnection connection;
connection = new URL(url).openConnection();
connection.setRequestProperty("User-Agent", getExtUa());
if (header != null) {
for (String key : header.keySet()) {
connection.addRequestProperty(key, header.get(key));
}
}
connection.connect();
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
StringBuilder str = new StringBuilder();
@ -38,68 +47,57 @@ public class HttpTools {
str.append(tmp);
}
reader.close();
connection.disconnect();
return str.toString();
} catch (Exception e) {
if(index<HttpRequestIndex){
return http_get(url,++index);
}
System.err.println("error url = "+url);
System.err.println("error url = " + url);
e.printStackTrace();
}
return null;
}
public void http_post(final String url, final byte[] body,final int index, final NetworkInterface networkInterface) {
new Thread(new Runnable() {
@Override
public void run() {
String tmp;
StringBuilder str = new StringBuilder();
try {
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
connection.setRequestMethod("POST");
connection.setDoOutput(true);
connection.setDoInput(true);
connection.addRequestProperty("User-Agent", getExtUa());
connection.setConnectTimeout(5 * 1000);
connection.setReadTimeout(10 * 1000);
//connection.addRequestProperty("Connection", "keep-alive");
//connection.addRequestProperty("User-Agent", getExtUa());
//connection.addRequestProperty("content-type", "application/json");
connection.addRequestProperty("charset", "UTF-8");
OutputStream outputStream = connection.getOutputStream();
outputStream.write(body);
outputStream.flush();
outputStream.close();
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
while ((tmp = reader.readLine()) != null) {
str.append(tmp);
}
final String finalStr = str.toString();
// Log.i(TAG + "[" + url + "?" + toGetSplice(body) + "]", "body:" + str + " (" + connection.getResponseCode() + ")");
if (networkInterface != null) {
try {
networkInterface.httpGetData(str.toString(), connection.getResponseCode());
} catch (IOException e) {
e.printStackTrace();
}
}
connection.disconnect();
reader.close();
} catch (Exception e) {
if(index<HttpRequestIndex){
http_post(url, body, index+1, networkInterface);
}else {
e.printStackTrace();
}
public static String http_post(String url, byte[] body, int index, Map<String, String> headers) {
String tmp;
StringBuilder str = new StringBuilder();
try {
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
connection.setRequestMethod("POST");
if (headers != null) {
for (String key : headers.keySet()) {
connection.addRequestProperty(key, headers.get(key));
}
}
}).start();
connection.setDoOutput(true);
connection.setDoInput(true);
connection.addRequestProperty("User-Agent", getExtUa());
connection.setConnectTimeout(5 * 1000);
connection.setReadTimeout(10 * 1000);
//connection.addRequestProperty("Connection", "keep-alive");
//connection.addRequestProperty("User-Agent", getExtUa());
//connection.addRequestProperty("content-type", "application/json");
connection.addRequestProperty("charset", "UTF-8");
OutputStream outputStream = connection.getOutputStream();
//System.out.println(new String(body));
outputStream.write(body);
outputStream.flush();
outputStream.close();
connection.connect();
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
while ((tmp = reader.readLine()) != null) {
str.append(tmp);
}
String finalStr = str.toString();
connection.disconnect();
reader.close();
return finalStr;
} catch (Exception e) {
if (index < HttpRequestIndex) {
return http_post(url, body, index + 1, headers);
} else {
e.printStackTrace();
return null;
}
}
}
private static String getExtUa() {
@ -205,14 +203,15 @@ public class HttpTools {
if (jar != null) {
jar.delete();
}
downloadInterface.onError(e);
if (downloadInterface != null)
downloadInterface.onError(e);
}
}
}).start();
}
public synchronized File http_syncDownload(final String url, final String saveName) {
if(StringUtils.isEmpty(url)){
if (StringUtils.isEmpty(url)) {
return null;
}
File jar = null;

View File

@ -0,0 +1,195 @@
package com.yutou.nas.utils;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yutou.nas.bangumi.BangumiTools;
import com.yutou.nas.interfaces.DownloadInterface;
import lombok.Data;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.time.OffsetDateTime;
import java.util.*;
public class JellyfinAPIManager {
public static LibsItem getLibs(String key) {
HashMap<String, String> header = getHeader();
String httpText = HttpTools.https_get("http://192.168.31.88:8096/Users/e8a13675bb64466dbd81f1e5985ef8c7/Items", header);
JSONObject json = JSONObject.parseObject(httpText);
if (key == null) {
return null;
}
JSONArray items = json.getJSONArray("Items");
for (Object o : items) {
LibsItem item = JSONObject.parseObject(o.toString(), LibsItem.class);
if (item.getName().equals(key)) {
return item;
}
}
return null;
}
public static List<JellyfinAPIManager.LibsItem> getLibsItems(String id) {
String httpText = HttpTools.https_get("http://192.168.31.88:8096/Users/e8a13675bb64466dbd81f1e5985ef8c7/Items?ParentId=" + id, getHeader());
JSONObject json = JSONObject.parseObject(httpText);
JSONArray items = json.getJSONArray("Items");
return JSONArray.parseArray(items.toJSONString(), LibsItem.class);
}
public static JSONObject getItemShows(String id) {
String data=HttpTools.https_get(String.format("http://192.168.31.88:8096/Shows/%s/Seasons?userId=e8a13675bb64466dbd81f1e5985ef8c7",
id
),getHeader());
return JSONObject.parseObject(data);
}
public static void uploadImage(File image, String id, String model) {
try {
HashMap<String, String> header = getHeader();
header.put("Content-Type", "image/jpg");
String url = String.format("http://192.168.31.88:8096/Items/%s/Images/%s",
id,
model
);
//url="http://tools.yutou233.cn/public/request.do";
HttpTools.http_post(
url,
Base64.getEncoder().encode(StreamTools.fileToByte(image)),
4,
header
);
} catch (Exception e) {
e.printStackTrace();
}
}
public static void saveJellyfinMetaData(JSONObject info, JellyfinAPIManager.LibsItem item) {
JSONArray airDate = new JSONArray();
airDate.add(info.getString("air_date"));
JSONObject providerIds = new JSONObject();
providerIds.put("Imdb", "");
providerIds.put("Tmdb", "");
providerIds.put("Zap2It", "");
JSONObject metadata = new JSONObject();
metadata.put("Id", item.getId());
metadata.put("Name", info.getString("name_cn"));
metadata.put("OriginalTitle", info.getString("name"));
metadata.put("ForcedSortName", "");
metadata.put("CommunityRating", info.getJSONObject("rating").getFloat("score") + "");
metadata.put("CriticRating", "");
metadata.put("IndexNumber", "null");
metadata.put("AirsBeforeSeasonNumber", "");
metadata.put("AirsAfterSeasonNumber", "");
metadata.put("AirsBeforeEpisodeNumber", "");
metadata.put("ParentIndexNumber", "null");
metadata.put("DisplayOrder", "");
metadata.put("Album", "");
metadata.put("AlbumArtists", new JSONArray());
metadata.put("ArtistItems", new JSONArray());
metadata.put("Overview", info.getString("summary"));
metadata.put("Status", "");
metadata.put("AirDays", new JSONArray());
metadata.put("AirTime", "");
metadata.put("Genres", new JSONArray());
metadata.put("Tags", new JSONArray());
metadata.put("Studios", new JSONArray());
metadata.put("PremiereDate", "null");
metadata.put("DateCreated", new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").format(new Date()));
metadata.put("EndDate", "null");
metadata.put("ProductionYear", info.getString("air_date").split("-")[0]);
metadata.put("AspectRatio", "");
metadata.put("Video3DFormat", "");
metadata.put("OfficialRating", "14+");
metadata.put("CustomRating", "");
metadata.put("People", BangumiTools.getPeople(info.getInteger("id")));
metadata.put("LockData", false);
metadata.put("LockedFields", new JSONArray());
metadata.put("ProviderIds", providerIds);
// metadata.put("Path", path);
metadata.put("PreferredMetadataLanguage", "");
metadata.put("PreferredMetadataCountryCode", "");
metadata.put("RunTimeTicks", 0);
metadata.put("Taglines", new JSONArray());
HashMap<String, String> headers = JellyfinAPIManager.getHeader();
headers.put("Content-Type", "application/json");
System.out.println(metadata.toString().replace("\"null\"", "null"));
String ret = HttpTools.http_post("http://192.168.31.88:8096/Items/" + item.getId()
, metadata.toString().replace("\"null\"", "null").getBytes(StandardCharsets.UTF_8)
, 4
, headers);
System.out.println(ret);
HttpTools.download(
info.getJSONObject("images").getString("large").replace("http:", "https:"),
"poster.jpg",
new DownloadInterface() {
@Override
public void onDownload(File file) {
super.onDownload(file);
JellyfinAPIManager.uploadImage(file, item.getId(), "Primary");
JSONObject items = JellyfinAPIManager.getItemShows(item.getId());
for (Object o : items.getJSONArray("Items")) {
JSONObject json = (JSONObject) o;
JellyfinAPIManager.uploadImage(file, json.getString("Id"), "Primary");
}
}
}
);
}
public static 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=\"81be0169523e463a8c36a7b752d60ab2\"");
return header;
}
@Data
public static class LibsItem {
private String name;
private String serverID;
private String id;
private Object channelID;
private boolean isFolder;
private String type;
private UserData userData;
private String collectionType;
private ImageTags imageTags;
private List<Object> backdropImageTags;
private Object imageBlurHashes;
private String locationType;
}
@Data
public static class UserData {
private long playbackPositionTicks;
private long playCount;
private boolean isFavorite;
private boolean played;
private String key;
}
@Data
public static class ImageTags {
private String primary;
}
public static void main(String[] args) {
JellyfinAPIManager.LibsItem item = JellyfinAPIManager.getLibs("番剧");
if (item != null) {
List<JellyfinAPIManager.LibsItem> list;
list = JellyfinAPIManager.getLibsItems(item.getId());
for (JellyfinAPIManager.LibsItem libsItem : list) {
if ("寒蝉鸣泣之时_卒".equals(libsItem.getName())) {
saveJellyfinMetaData(
BangumiTools.getBangumiInfo(331033),
libsItem
);
}
}
}
}
}

View File

@ -29,7 +29,7 @@ import java.util.regex.Pattern;
public class QQBotManager {
private static class QQCommands {
public static class QQCommands {
private final static String QQ_HELP = "!help";
private final static String QQ_SYSTEM_RESTART = "!restart";
private final static String QQ_UPDATE_IP = "!更新ip";
@ -47,6 +47,8 @@ public class QQBotManager {
private final static String QQ_TOOLS_IDEA = "!idea";
private final static String QQ_TOOLS_IDEA_FILE = "!idea>";
private final static String QQ_TOOLS_IDEA_URL = "!idea_url";
public final static String QQ_BANGUMI_INFO="!保存动画信息>";
}
private static QQBotManager botManager = null;
@ -136,7 +138,7 @@ public class QQBotManager {
}
public String sendMessage(String text) {
if (bot != null) {
if (bot != null&&!StringUtils.isEmpty(text)) {
try {
return Objects.requireNonNull(bot.getGroup(qqGroup)).sendMessage(text).toString();
} catch (Exception e) {
@ -266,7 +268,7 @@ public class QQBotManager {
case QQCommands.QQ_SYSTEM_RESTART:
getInstance().sendMessage("正在重启服务");
System.out.println("结束进程");
AppTools.exec("cd /media/yutou/4t/public/servier/tools && ./start.sh",null,true,false);
AppTools.exec("cd /home/yutou/public/servier/tools && ./start.sh",null,true,false);
break;
case QQCommands.QQ_HELP:
builder = new StringBuilder();

View File

@ -251,7 +251,7 @@ public class RedisTools {
exec = value;
break;
case "updateIP":
exec = "python3 /media/yutou/4t/public/Python/tools/ip.py";
exec = "python3 /media/yutou/disk_lvm/public/Python/tools/ip.py";
break;
}
if (exec != null) {

View File

@ -3,6 +3,7 @@ package com.yutou.nas.utils;
import com.alibaba.fastjson.JSONArray;
import com.yutou.nas.Controllers.UpdateIp;
import com.yutou.nas.interfaces.DownloadInterface;
import com.yutou.nas.interfaces.ObjectInterface;
import org.springframework.core.io.FileSystemResource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
@ -24,8 +25,11 @@ import java.text.SimpleDateFormat;
import java.util.Base64;
import java.util.Date;
import java.util.Random;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Tools {
private static float UPSPower=-1.0f;
/**
* 设置Cookie
*
@ -91,8 +95,7 @@ public class Tools {
try {
com.yutou.nas.utils.Log.i("title=" + title + " msg=" + msg);
HttpTools.post("https://sctapi.ftqq.com/SCT2619Tpqu93OYtQCrK4LOZYEfr2irm.send",
("title="+URLEncoder.encode(title, "UTF-8") + "&desp=" + URLEncoder.encode(msg, "UTF-8")).getBytes(StandardCharsets.UTF_8),
null);
("title="+URLEncoder.encode(title, "UTF-8") + "&desp=" + URLEncoder.encode(msg, "UTF-8")).getBytes(StandardCharsets.UTF_8));
if (ConfigTools.load(ConfigTools.CONFIG, "model").equals("nas")) {
String img = null;
msg = msg.replace("<br/>", "\n");
@ -384,4 +387,22 @@ public class Tools {
public static String getToDayTime() {
return new SimpleDateFormat("yyyy-MM-dd").format(new Date());
}
public static float getSystemUPSPower(){
AppTools.exec("/sbin/apcaccess |grep BCHARGE ", new ObjectInterface() {
@Override
public void out(String data) {
super.out(data);
System.out.println("尝试获取电量:"+data);
Pattern pattern=Pattern.compile("[0-9]*\\.?[0-9]");
Matcher matcher=pattern.matcher(data);
if(matcher.find()) {
String ups = matcher.group();
UPSPower=Float.parseFloat(ups);
System.out.println("电量:"+UPSPower);
}
}
},false,true);
return UPSPower;
}
}