完善BT下载器,机器人可以控制刷新下载了
This commit is contained in:
@@ -14,7 +14,7 @@ public class AudioTools {
|
||||
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/");
|
||||
init = true;
|
||||
System.out.println("讯飞语音已初始化");
|
||||
com.yutou.nas.utils.Log.i("讯飞语音已初始化");
|
||||
}
|
||||
|
||||
public static void playText(String text) {
|
||||
@@ -50,7 +50,7 @@ public class AudioTools {
|
||||
|
||||
@Override
|
||||
public void onCompleted(SpeechError speechError) {
|
||||
System.out.println(speechError.getErrorDesc() + " code " + speechError.getErrorCode());
|
||||
com.yutou.nas.utils.Log.i(speechError.getErrorDesc() + " code " + speechError.getErrorCode());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -39,12 +39,18 @@ public class BTDownloadManager implements ApplicationContextAware {
|
||||
|
||||
public void start() {
|
||||
List<BangumiItem> list = bangumiService.getAllBangumi();
|
||||
AnimationData data = new AnimationData();
|
||||
for (BangumiItem item : list) {
|
||||
String url = getRSSUrl(item);
|
||||
String _json = HttpTools.get(url);
|
||||
if (!StringUtils.isEmpty(_json)) {
|
||||
JSONObject json = JSONObject.parseObject(_json);
|
||||
item.setAuthor(data.nameToValue(item.getAuthor(),true)+"");
|
||||
item.setCategories(data.nameToValue(item.getCategories(),false)+"");
|
||||
download(item, json);
|
||||
}else{
|
||||
QQBotManager.getInstance().sendMessage(item.getTitle()+"\n下载失败");
|
||||
Log.i(item.getTitle()+"\n下载失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -76,7 +82,7 @@ public class BTDownloadManager implements ApplicationContextAware {
|
||||
//发通知到QQ
|
||||
JSONArray array = getDownload(bangumiItem.getTitle());
|
||||
array.add(item.getString("title"));
|
||||
RedisTools.set(bangumiItem.getTitle(), item.getString("title"));
|
||||
RedisTools.set(bangumiItem.getTitle(), array.toJSONString());
|
||||
if (item.containsKey("thumbnail")) {
|
||||
HttpTools.download(item.getString("thumbnail"), bangumiItem.getTitle() + ".jpg", new DownloadInterface() {
|
||||
@Override
|
||||
@@ -102,8 +108,9 @@ public class BTDownloadManager implements ApplicationContextAware {
|
||||
}
|
||||
}
|
||||
|
||||
public void onSend(File file, JSONObject item) {
|
||||
private void onSend(File file, JSONObject item) {
|
||||
String text = "启动下载器\n已提交到下载:" + item.getString("title");
|
||||
Log.i(text);
|
||||
if (file == null) {
|
||||
QQBotManager.getInstance().sendMessage(text);
|
||||
} else {
|
||||
@@ -154,7 +161,7 @@ public class BTDownloadManager implements ApplicationContextAware {
|
||||
item.setTitle("無職轉生~到了異世界就拿出真本事~");
|
||||
item.setTitlekey("无职转生");
|
||||
String url = new BTDownloadManager().getRSSUrl(item);
|
||||
System.out.println(url);
|
||||
com.yutou.nas.utils.Log.i(url);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -163,7 +170,7 @@ public class BTDownloadManager implements ApplicationContextAware {
|
||||
BTDownloadManager.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
public static <T> T getBean(Class<T> clazz) {
|
||||
private static <T> T getBean(Class<T> clazz) {
|
||||
return applicationContext.getBean(clazz);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public class ConfigTools {
|
||||
}
|
||||
public static Object load(String type,String key){
|
||||
File file=new File(type);
|
||||
//System.out.println(type+"配置文件地址:"+file.getAbsolutePath());
|
||||
//com.yutou.nas.utils.Log.i(type+"配置文件地址:"+file.getAbsolutePath());
|
||||
String src=readFile(file);
|
||||
if(src!=null){
|
||||
try {
|
||||
|
||||
@@ -124,7 +124,7 @@ public class HttpTools {
|
||||
}
|
||||
});
|
||||
}*/
|
||||
System.out.println(url);
|
||||
com.yutou.nas.utils.Log.i(url);
|
||||
//String str=get(url);
|
||||
}
|
||||
private static String donwloadPath="tmp"+File.separator;
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
package com.yutou.nas.utils;
|
||||
|
||||
public class Log {
|
||||
public static void i(String tag,Object log){
|
||||
i('['+tag+']'+log);
|
||||
public static void i(String tag, Object log) {
|
||||
i('[' + tag + ']' + log);
|
||||
}
|
||||
public static void i(Object log){
|
||||
System.out.printf("[%s]%s%n",
|
||||
AppTools.getToDayNowTimeToString(),
|
||||
log
|
||||
);
|
||||
|
||||
public static void i(Object log) {
|
||||
if (ConfigTools.load(ConfigTools.CONFIG, "logout").equals("true"))
|
||||
System.out.printf("[%s]%s%n",
|
||||
AppTools.getToDayNowTimeToString(),
|
||||
log
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,14 +57,14 @@ public class MusicToolsServiceImpl implements IMusicToolsService {
|
||||
}
|
||||
musicPath = (String) ConfigTools.load(ConfigTools.CONFIG, "musicDir");
|
||||
musicDataDao.truncate();
|
||||
System.out.println("执行扫描:" + musicPath);
|
||||
com.yutou.nas.utils.Log.i("执行扫描:" + musicPath);
|
||||
new Thread(() -> {
|
||||
long startTime = System.currentTimeMillis();
|
||||
QQBotManager.getInstance().sendMessage("开始扫描音乐夹");
|
||||
isScan = true;
|
||||
scan(new File(musicPath));
|
||||
isScan = false;
|
||||
System.out.println("扫描完成");
|
||||
com.yutou.nas.utils.Log.i("扫描完成");
|
||||
QQBotManager.getInstance().sendMessage("音乐扫描完成,共" + getLength() + "首歌,耗时:"
|
||||
+ (System.currentTimeMillis() - startTime));
|
||||
}).start();
|
||||
@@ -131,7 +131,7 @@ public class MusicToolsServiceImpl implements IMusicToolsService {
|
||||
MusicData tmp = main.get(0);
|
||||
t2.setFile(new File(tmp.getLastdir()).getAbsolutePath());
|
||||
}
|
||||
System.out.println("查询地址:" + path + " 设置返回地址:" + t2.getFile());
|
||||
com.yutou.nas.utils.Log.i("查询地址:" + path + " 设置返回地址:" + t2.getFile());
|
||||
t2.setIsdir(1);
|
||||
list.add(t2);
|
||||
}
|
||||
@@ -158,7 +158,7 @@ public class MusicToolsServiceImpl implements IMusicToolsService {
|
||||
|
||||
private void getDirList(String path, List<MusicData> list) {
|
||||
File file = new File(path);
|
||||
System.out.println("扫描文件:"+path);
|
||||
com.yutou.nas.utils.Log.i("扫描文件:"+path);
|
||||
if(file.isDirectory()) {
|
||||
for (File listFile : file.listFiles()) {
|
||||
if (listFile.isDirectory()) {
|
||||
@@ -538,7 +538,7 @@ public class MusicToolsServiceImpl implements IMusicToolsService {
|
||||
File file = new File("Z:\\音乐\\总之就是非常酸\\ED\\カノエラナ - 月と星空\\カノエラナ.wav");
|
||||
file = new File("Z:\\音乐\\终将成为你\\[OP]君にふれて\\rise.flac");
|
||||
// file = new File("Z:\\音乐\\周董\\2012 十二新作\\03 公公偏头痛.ape");
|
||||
System.out.println(new MusicToolsServiceImpl().getMetadataOfFFmpeg(file));
|
||||
com.yutou.nas.utils.Log.i(new MusicToolsServiceImpl().getMetadataOfFFmpeg(file));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ public class QQBotManager {
|
||||
private final static String QQ_AUDIO = "!语音";
|
||||
private final static String QQ_AUDIO_OPEN_LAMP = "!开灯";
|
||||
private final static String QQ_AUDIO_OPEN_AIR = "!开空调";
|
||||
private final static String QQ_BT_RELOAD = "!刷BT";
|
||||
}
|
||||
|
||||
private static QQBotManager botManager = null;
|
||||
@@ -92,7 +93,7 @@ public class QQBotManager {
|
||||
e.printStackTrace();
|
||||
}
|
||||
String str = sendMessage("姬妻酱上线拉~");
|
||||
System.out.println(str);
|
||||
com.yutou.nas.utils.Log.i(str);
|
||||
|
||||
}
|
||||
}).start();
|
||||
@@ -251,6 +252,9 @@ public class QQBotManager {
|
||||
getInstance().sendMessage("获取中...");
|
||||
getInstance().sendMessage(BangumiTools.reportBangumiList());
|
||||
break;
|
||||
case QQCommands.QQ_BT_RELOAD:
|
||||
BTDownloadManager.getInstance().start();
|
||||
break;
|
||||
|
||||
case QQCommands.QQ_HELP:
|
||||
StringBuilder builder = new StringBuilder();
|
||||
@@ -323,7 +327,7 @@ public class QQBotManager {
|
||||
private void send(int size, String text) {
|
||||
if ((files.size() + index) == size) {
|
||||
String str = getInstance().sendMessage(files, text);
|
||||
System.out.println("str = " + str);
|
||||
com.yutou.nas.utils.Log.i("str = " + str);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ public class RedisTools {
|
||||
Jedis jedis = getRedis();
|
||||
jedis.select(dbIndex);
|
||||
String ret = jedis.set(key, value);
|
||||
System.out.println("Redis set =" + ret);
|
||||
com.yutou.nas.utils.Log.i("Redis set =" + ret);
|
||||
jedis.close();
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
@@ -176,13 +176,13 @@ public class RedisTools {
|
||||
}
|
||||
|
||||
public static void pullMsg(String channel, String msg) {
|
||||
System.out.println("1");
|
||||
com.yutou.nas.utils.Log.i("1");
|
||||
Jedis jedis = getPoolRedis();
|
||||
System.out.println("2");
|
||||
com.yutou.nas.utils.Log.i("2");
|
||||
jedis.publish(channel, msg);
|
||||
System.out.println("3");
|
||||
com.yutou.nas.utils.Log.i("3");
|
||||
jedis.close();
|
||||
System.out.println("4");
|
||||
com.yutou.nas.utils.Log.i("4");
|
||||
}
|
||||
|
||||
private static boolean init = false;
|
||||
@@ -191,7 +191,7 @@ public class RedisTools {
|
||||
if (init)
|
||||
return;
|
||||
init = true;
|
||||
System.out.println("初始化订阅");
|
||||
com.yutou.nas.utils.Log.i("初始化订阅");
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -207,7 +207,7 @@ public class RedisTools {
|
||||
@Override
|
||||
public void onPMessage(String pattern, String channel, String message) {
|
||||
super.onPMessage(pattern, channel, message);
|
||||
System.out.println("onPMessage: channel=" + channel + " msg=" + message + " pattern=" + pattern);
|
||||
com.yutou.nas.utils.Log.i("onPMessage: channel=" + channel + " msg=" + message + " pattern=" + pattern);
|
||||
switch (channel) {
|
||||
case "system":
|
||||
switch (message) {
|
||||
@@ -234,7 +234,7 @@ public class RedisTools {
|
||||
@Override
|
||||
public void onMessage(String channel, String message) {
|
||||
super.onMessage(channel, message);
|
||||
System.out.println("onMessage: channel=" + channel + " msg=" + message);
|
||||
com.yutou.nas.utils.Log.i("onMessage: channel=" + channel + " msg=" + message);
|
||||
}
|
||||
|
||||
public static void system(String type, String value) {
|
||||
@@ -288,9 +288,9 @@ public class RedisTools {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
System.out.println("cmd > " + str);
|
||||
com.yutou.nas.utils.Log.i("cmd > " + str);
|
||||
QQBotManager.getInstance().sendMessage(str.toString());
|
||||
System.out.println("线程结束");
|
||||
com.yutou.nas.utils.Log.i("线程结束");
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
RedisTools.pullMsg("msg", "abc");
|
||||
|
||||
@@ -77,7 +77,7 @@ public class Tools {
|
||||
public static String deleteCookie(HttpServletRequest request, HttpServletResponse response, String key) {
|
||||
for (Cookie cookie : request.getCookies()) {
|
||||
if (cookie.getName().equals(key)) {
|
||||
System.out.println("删除key=" + key);
|
||||
com.yutou.nas.utils.Log.i("删除key=" + key);
|
||||
cookie.setMaxAge(0);
|
||||
cookie.setPath("/");
|
||||
cookie.setValue(null);
|
||||
@@ -89,7 +89,7 @@ public class Tools {
|
||||
|
||||
public static void sendServer(String title, String msg) {
|
||||
try {
|
||||
System.out.println("title=" + title + " msg=" + msg);
|
||||
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);
|
||||
@@ -144,7 +144,7 @@ public class Tools {
|
||||
+ "&imgUrl=" + img
|
||||
+ "&token=zIrsh9TUZP2lfRW753PannG49E7VJvor";
|
||||
}
|
||||
System.out.println(url);
|
||||
com.yutou.nas.utils.Log.i(url);
|
||||
HttpTools.get(url);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@@ -220,7 +220,7 @@ public class Tools {
|
||||
array = JSONArray.parseArray(RedisTools.get("bean"));
|
||||
}
|
||||
if (array.contains(Tools.getRemoteAddress(request))) {
|
||||
System.out.println("IP已被封禁");
|
||||
com.yutou.nas.utils.Log.i("IP已被封禁");
|
||||
return -100;
|
||||
}
|
||||
Cookie cookie = Tools.getCookie(request, "user");
|
||||
@@ -259,7 +259,7 @@ public class Tools {
|
||||
}
|
||||
file.transferTo(saveFile);
|
||||
fileName = URLEncoder.encode(fileName, "UTF-8");
|
||||
System.out.println("上传文件保存路径:" + saveFile.getAbsolutePath());
|
||||
com.yutou.nas.utils.Log.i("上传文件保存路径:" + saveFile.getAbsolutePath());
|
||||
return path + fileName;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user