预设视频相关内容

This commit is contained in:
2021-08-17 08:10:58 +08:00
parent d8acadf2d7
commit 2f1bd267bf
21 changed files with 3728 additions and 24 deletions

View File

@@ -1,5 +1,6 @@
package com.yutou.nas.utils;
import com.yutou.nas.interfaces.ObjectInterface;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;
import org.springframework.core.annotation.AnnotationUtils;
@@ -20,7 +21,7 @@ public class AppTools {
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
}
public static void exec(String exec) {
public static void exec(String exec, ObjectInterface objectInterface, boolean isOutQQBot, boolean isInput) {
try {
Process process;
if (AppTools.isRuntimeSystemOfWindow()) {
@@ -38,10 +39,15 @@ public class AppTools {
}
);
}
processOut(process.getInputStream());
processOut(process.getErrorStream());
if (isInput) {
processOut(process.getInputStream(), objectInterface, isOutQQBot);
processOut(process.getErrorStream());
} else {
processOut(process.getErrorStream(), objectInterface, isOutQQBot);
processOut(process.getInputStream());
}
process.destroy();
}catch (Exception e){
} catch (Exception e) {
e.printStackTrace();
}
}
@@ -82,17 +88,17 @@ public class AppTools {
return classList;
}
public static List<String> getUrls(String packageName,String className){
List<Class> list= AppTools.scanClass(packageName, Controller.class);
List<String> urls=new ArrayList<>();
public static List<String> getUrls(String packageName, String className) {
List<Class> list = AppTools.scanClass(packageName, Controller.class);
List<String> urls = new ArrayList<>();
for (Class aClass : list) {
if(className!=null&&!aClass.getSimpleName().equals(className)){
if (className != null && !aClass.getSimpleName().equals(className)) {
continue;
}
Method[] methods= aClass.getDeclaredMethods();
Method[] methods = aClass.getDeclaredMethods();
for (Method method : methods) {
RequestMapping ls=method.getAnnotation(RequestMapping.class);
if(ls!=null) {
RequestMapping ls = method.getAnnotation(RequestMapping.class);
if (ls != null) {
urls.add(ls.value()[0]);
}
}

View File

@@ -5,18 +5,32 @@ 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.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.util.Set;
public class HttpTools {
public static final String serverKey="zIrsh9TUZP2lfRW753PannG49E7VJvor";
public static String get(String url) {
private static final int HttpRequestIndex=3;
public static String get(String url){
return new HttpTools().http_get(url,0);
}
public static void post(final String url, final byte[] body, final NetworkInterface networkInterface){
new HttpTools().http_post(url, body,0, networkInterface);
}
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) {
try {
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
HttpsURLConnection connection = (HttpsURLConnection) new URL(url).openConnection();
connection.setRequestProperty("User-Agent", getExtUa());
connection.connect();
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
StringBuilder str = new StringBuilder();
String tmp;
@@ -27,12 +41,16 @@ public class HttpTools {
connection.disconnect();
return str.toString();
} catch (Exception e) {
if(index<HttpRequestIndex){
return http_get(url,++index);
}
System.err.println("error url = "+url);
e.printStackTrace();
}
return null;
}
public static void post(final String url, final byte[] body, final NetworkInterface networkInterface) {
public void http_post(final String url, final byte[] body,final int index, final NetworkInterface networkInterface) {
new Thread(new Runnable() {
@@ -74,7 +92,11 @@ public class HttpTools {
connection.disconnect();
reader.close();
} catch (Exception e) {
e.printStackTrace();
if(index<HttpRequestIndex){
http_post(url, body, index+1, networkInterface);
}else {
e.printStackTrace();
}
}
}
}).start();
@@ -189,7 +211,7 @@ public class HttpTools {
}).start();
}
public synchronized static File syncDownload(final String url, final String saveName) {
public synchronized File http_syncDownload(final String url, final String saveName) {
if(StringUtils.isEmpty(url)){
return null;
}

View File

@@ -265,7 +265,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");
AppTools.exec("cd /media/yutou/4t/public/servier/tools && ./start.sh",null,true,false);
break;
case QQCommands.QQ_HELP:
builder = new StringBuilder();

View File

@@ -1,6 +1,8 @@
package com.yutou.nas.utils;
import com.alibaba.fastjson.JSONObject;
import com.yutou.nas.interfaces.DownloadInterface;
import com.yutou.nas.interfaces.ObjectInterface;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
@@ -276,9 +278,11 @@ public class RedisTools {
}
}
public static void processOut(InputStream inputStream) {
processOut(inputStream,null,true);
}
public static void processOut(InputStream inputStream, ObjectInterface objectInterface, boolean isOutQQBot){
String tmp;
StringBuilder str = new StringBuilder("null");
StringBuilder str = new StringBuilder();
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
while ((tmp = reader.readLine()) != null) {
@@ -289,8 +293,13 @@ public class RedisTools {
} catch (Exception e) {
e.printStackTrace();
}
com.yutou.nas.utils.Log.i("cmd > " + str);
QQBotManager.getInstance().sendMessage(str.toString());
if(objectInterface!=null){
objectInterface.out(str.toString());
}
// com.yutou.nas.utils.Log.i("cmd > " + str);
if(isOutQQBot) {
QQBotManager.getInstance().sendMessage(str.toString());
}
}
public static void main(String[] args) {
RedisTools.pullMsg("msg", "abc");