mirror of
https://github.com/LamGC/ContentGrabbingJi.git
synced 2025-07-04 06:17:26 +00:00
Compare commits
8 Commits
v2.5.2-202
...
v2.5.2-202
Author | SHA1 | Date | |
---|---|---|---|
04724168aa | |||
89ded96336 | |||
af0346e952 | |||
4ccf2fafbc | |||
f1e58d72ac | |||
9242a1d474 | |||
065d21c4e4 | |||
5eab94c429 |
17
pom.xml
17
pom.xml
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>net.lamgc</groupId>
|
<groupId>net.lamgc</groupId>
|
||||||
<artifactId>ContentGrabbingJi</artifactId>
|
<artifactId>ContentGrabbingJi</artifactId>
|
||||||
<version>2.5.2-20200609.2-SNAPSHOT</version>
|
<version>2.5.2-20200610.2-SNAPSHOT</version>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
@ -110,21 +110,6 @@
|
|||||||
<artifactId>gson</artifactId>
|
<artifactId>gson</artifactId>
|
||||||
<version>2.8.5</version>
|
<version>2.8.5</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>net.sourceforge.htmlunit</groupId>
|
|
||||||
<artifactId>htmlunit</artifactId>
|
|
||||||
<version>2.29</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.rholder</groupId>
|
|
||||||
<artifactId>guava-retrying</artifactId>
|
|
||||||
<version>2.0.0</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>mysql</groupId>
|
|
||||||
<artifactId>mysql-connector-java</artifactId>
|
|
||||||
<version>8.0.19</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.lz1998</groupId>
|
<groupId>net.lz1998</groupId>
|
||||||
<artifactId>spring-cq</artifactId>
|
<artifactId>spring-cq</artifactId>
|
||||||
|
@ -19,12 +19,12 @@ import net.lamgc.plps.PixivLoginProxyServer;
|
|||||||
import net.lamgc.utils.base.runner.Argument;
|
import net.lamgc.utils.base.runner.Argument;
|
||||||
import net.lamgc.utils.base.runner.ArgumentsRunner;
|
import net.lamgc.utils.base.runner.ArgumentsRunner;
|
||||||
import net.lamgc.utils.base.runner.Command;
|
import net.lamgc.utils.base.runner.Command;
|
||||||
import org.apache.commons.io.IOUtils;
|
|
||||||
import org.apache.http.HttpHost;
|
import org.apache.http.HttpHost;
|
||||||
import org.apache.http.HttpResponse;
|
import org.apache.http.HttpResponse;
|
||||||
import org.apache.http.client.CookieStore;
|
import org.apache.http.client.CookieStore;
|
||||||
import org.apache.http.client.methods.HttpGet;
|
import org.apache.http.client.methods.HttpGet;
|
||||||
import org.apache.http.util.EntityUtils;
|
import org.apache.http.util.EntityUtils;
|
||||||
|
import org.apache.tomcat.util.http.fileupload.util.Streams;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
@ -127,7 +127,7 @@ public class Main {
|
|||||||
ZipEntry entry = new ZipEntry(link.substring(link.lastIndexOf("/") + 1));
|
ZipEntry entry = new ZipEntry(link.substring(link.lastIndexOf("/") + 1));
|
||||||
log.info("正在写入: " + entry.getName());
|
log.info("正在写入: " + entry.getName());
|
||||||
zos.putNextEntry(entry);
|
zos.putNextEntry(entry);
|
||||||
IOUtils.copy(inputStream, zos);
|
Streams.copy(inputStream, zos, false);
|
||||||
zos.flush();
|
zos.flush();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error("写入文件项时发生异常", e);
|
log.error("写入文件项时发生异常", e);
|
||||||
@ -159,7 +159,7 @@ public class Main {
|
|||||||
ZipEntry entry = new ZipEntry(link.substring(link.lastIndexOf("/") + 1));
|
ZipEntry entry = new ZipEntry(link.substring(link.lastIndexOf("/") + 1));
|
||||||
log.info("正在写入: " + entry.getName());
|
log.info("正在写入: " + entry.getName());
|
||||||
zos.putNextEntry(entry);
|
zos.putNextEntry(entry);
|
||||||
IOUtils.copy(inputStream, zos);
|
Streams.copy(inputStream, zos, false);
|
||||||
zos.flush();
|
zos.flush();
|
||||||
log.info("已成功写入 {}", entry.getName());
|
log.info("已成功写入 {}", entry.getName());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -230,7 +230,7 @@ public class Main {
|
|||||||
entry.setComment(rankInfo.toString());
|
entry.setComment(rankInfo.toString());
|
||||||
log.info("正在写入: " + entry.getName());
|
log.info("正在写入: " + entry.getName());
|
||||||
zos.putNextEntry(entry);
|
zos.putNextEntry(entry);
|
||||||
IOUtils.copy(inputStream, zos);
|
Streams.copy(inputStream, zos, false);
|
||||||
zos.flush();
|
zos.flush();
|
||||||
log.info("已成功写入 {}", entry.getName());
|
log.info("已成功写入 {}", entry.getName());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
@ -5,11 +5,11 @@ import net.lamgc.cgj.bot.cache.exception.HttpRequestException;
|
|||||||
import net.lamgc.cgj.pixiv.PixivURL;
|
import net.lamgc.cgj.pixiv.PixivURL;
|
||||||
import net.lamgc.cgj.util.URLs;
|
import net.lamgc.cgj.util.URLs;
|
||||||
import net.lamgc.utils.event.EventHandler;
|
import net.lamgc.utils.event.EventHandler;
|
||||||
import org.apache.commons.io.IOUtils;
|
|
||||||
import org.apache.http.HttpResponse;
|
import org.apache.http.HttpResponse;
|
||||||
import org.apache.http.client.HttpClient;
|
import org.apache.http.client.HttpClient;
|
||||||
import org.apache.http.client.methods.HttpGet;
|
import org.apache.http.client.methods.HttpGet;
|
||||||
import org.apache.http.impl.client.HttpClientBuilder;
|
import org.apache.http.impl.client.HttpClientBuilder;
|
||||||
|
import org.apache.tomcat.util.http.fileupload.util.Streams;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ public class ImageCacheHandler implements EventHandler {
|
|||||||
log.debug("正在下载...(Content-Length: {}KB)", response.getEntity().getContentLength() / 1024);
|
log.debug("正在下载...(Content-Length: {}KB)", response.getEntity().getContentLength() / 1024);
|
||||||
ByteArrayOutputStream bufferOutputStream = new ByteArrayOutputStream();
|
ByteArrayOutputStream bufferOutputStream = new ByteArrayOutputStream();
|
||||||
try(FileOutputStream fileOutputStream = new FileOutputStream(storeFile)) {
|
try(FileOutputStream fileOutputStream = new FileOutputStream(storeFile)) {
|
||||||
IOUtils.copy(response.getEntity().getContent(), bufferOutputStream);
|
Streams.copy(response.getEntity().getContent(), bufferOutputStream, false);
|
||||||
ByteArrayInputStream bufferInputStream = new ByteArrayInputStream(bufferOutputStream.toByteArray());
|
ByteArrayInputStream bufferInputStream = new ByteArrayInputStream(bufferOutputStream.toByteArray());
|
||||||
CacheStoreCentral.ImageChecksum imageChecksum = CacheStoreCentral.ImageChecksum
|
CacheStoreCentral.ImageChecksum imageChecksum = CacheStoreCentral.ImageChecksum
|
||||||
.buildImageChecksumFromStream(
|
.buildImageChecksumFromStream(
|
||||||
@ -79,7 +79,7 @@ public class ImageCacheHandler implements EventHandler {
|
|||||||
bufferInputStream
|
bufferInputStream
|
||||||
);
|
);
|
||||||
bufferInputStream.reset();
|
bufferInputStream.reset();
|
||||||
IOUtils.copy(bufferInputStream, fileOutputStream);
|
Streams.copy(bufferInputStream, fileOutputStream, false);
|
||||||
CacheStoreCentral.setImageChecksum(imageChecksum);
|
CacheStoreCentral.setImageChecksum(imageChecksum);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error("下载图片时发生异常", e);
|
log.error("下载图片时发生异常", e);
|
||||||
|
@ -2,6 +2,8 @@ package net.lamgc.cgj.bot.framework.cli;
|
|||||||
|
|
||||||
import net.lamgc.cgj.bot.boot.ApplicationBoot;
|
import net.lamgc.cgj.bot.boot.ApplicationBoot;
|
||||||
import net.lamgc.cgj.bot.event.BotEventHandler;
|
import net.lamgc.cgj.bot.event.BotEventHandler;
|
||||||
|
import net.lamgc.cgj.bot.framework.cli.message.ConsoleMessageEvent;
|
||||||
|
import net.lamgc.cgj.bot.framework.cli.message.ConsoleMessageSenderFactory;
|
||||||
import net.lamgc.cgj.bot.message.MessageSenderBuilder;
|
import net.lamgc.cgj.bot.message.MessageSenderBuilder;
|
||||||
import org.jline.reader.LineReader;
|
import org.jline.reader.LineReader;
|
||||||
import org.jline.reader.LineReaderBuilder;
|
import org.jline.reader.LineReaderBuilder;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package net.lamgc.cgj.bot.framework.cli;
|
package net.lamgc.cgj.bot.framework.cli.message;
|
||||||
|
|
||||||
import net.lamgc.cgj.bot.event.MessageEvent;
|
import net.lamgc.cgj.bot.event.MessageEvent;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package net.lamgc.cgj.bot.framework.cli;
|
package net.lamgc.cgj.bot.framework.cli.message;
|
||||||
|
|
||||||
import net.lamgc.cgj.bot.message.MessageSender;
|
import net.lamgc.cgj.bot.message.MessageSender;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package net.lamgc.cgj.bot.framework.cli;
|
package net.lamgc.cgj.bot.framework.cli.message;
|
||||||
|
|
||||||
import net.lamgc.cgj.bot.message.MessageSender;
|
import net.lamgc.cgj.bot.message.MessageSender;
|
||||||
import net.lamgc.cgj.bot.message.MessageSenderFactory;
|
import net.lamgc.cgj.bot.message.MessageSenderFactory;
|
@ -17,11 +17,11 @@ import net.mamoe.mirai.message.MessageEvent;
|
|||||||
import net.mamoe.mirai.message.TempMessageEvent;
|
import net.mamoe.mirai.message.TempMessageEvent;
|
||||||
import net.mamoe.mirai.utils.BotConfiguration;
|
import net.mamoe.mirai.utils.BotConfiguration;
|
||||||
import net.mamoe.mirai.utils.Utils;
|
import net.mamoe.mirai.utils.Utils;
|
||||||
import org.apache.commons.net.util.Base64;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.util.Base64;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
public class MiraiMain implements Closeable {
|
public class MiraiMain implements Closeable {
|
||||||
@ -49,10 +49,11 @@ public class MiraiMain implements Closeable {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils.setDefaultLogger(MiraiToSlf4jLogger::new);
|
Utils.setDefaultLogger(MiraiToSlf4jLoggerAdapter::new);
|
||||||
BotConfiguration configuration = new BotConfiguration();
|
BotConfiguration configuration = new BotConfiguration();
|
||||||
configuration.setProtocol(BotConfiguration.MiraiProtocol.ANDROID_PAD);
|
configuration.setProtocol(BotConfiguration.MiraiProtocol.ANDROID_PAD);
|
||||||
bot = BotFactoryJvm.newBot(Long.parseLong(botProperties.getProperty("bot.qq", "0")), Base64.decodeBase64(botProperties.getProperty("bot.password", "")), configuration);
|
bot = BotFactoryJvm.newBot(Long.parseLong(botProperties.getProperty("bot.qq", "0")),
|
||||||
|
Base64.getDecoder().decode(botProperties.getProperty("bot.password", "")), configuration);
|
||||||
Events.subscribeAlways(GroupMessageEvent.class, this::executeMessageEvent);
|
Events.subscribeAlways(GroupMessageEvent.class, this::executeMessageEvent);
|
||||||
Events.subscribeAlways(FriendMessageEvent.class, this::executeMessageEvent);
|
Events.subscribeAlways(FriendMessageEvent.class, this::executeMessageEvent);
|
||||||
Events.subscribeAlways(TempMessageEvent.class, this::executeMessageEvent);
|
Events.subscribeAlways(TempMessageEvent.class, this::executeMessageEvent);
|
||||||
|
@ -8,7 +8,12 @@ import org.slf4j.LoggerFactory;
|
|||||||
import org.slf4j.Marker;
|
import org.slf4j.Marker;
|
||||||
import org.slf4j.MarkerFactory;
|
import org.slf4j.MarkerFactory;
|
||||||
|
|
||||||
public class MiraiToSlf4jLogger extends MiraiLoggerPlatformBase {
|
/**
|
||||||
|
* MiraiLoggerToSlf4jLogger适配器
|
||||||
|
* <p>该Logger通过Slf4j的Marker进行标识, loggerName为{@code mirai.[identity]}</p>
|
||||||
|
* <p>由于适配器适配方式的原因, 日志输出的调用信息将不可用(调用指向了适配器内的方法);</p>
|
||||||
|
*/
|
||||||
|
public class MiraiToSlf4jLoggerAdapter extends MiraiLoggerPlatformBase {
|
||||||
|
|
||||||
private final static Marker marker = MarkerFactory.getMarker("mirai");
|
private final static Marker marker = MarkerFactory.getMarker("mirai");
|
||||||
|
|
||||||
@ -16,7 +21,7 @@ public class MiraiToSlf4jLogger extends MiraiLoggerPlatformBase {
|
|||||||
|
|
||||||
private final String identity;
|
private final String identity;
|
||||||
|
|
||||||
public MiraiToSlf4jLogger(String identity) {
|
public MiraiToSlf4jLoggerAdapter(String identity) {
|
||||||
this.identity = identity;
|
this.identity = identity;
|
||||||
this.logger = LoggerFactory.getLogger("mirai." + identity);
|
this.logger = LoggerFactory.getLogger("mirai." + identity);
|
||||||
}
|
}
|
@ -7,11 +7,11 @@ import com.squareup.gifencoder.GifEncoder;
|
|||||||
import com.squareup.gifencoder.Image;
|
import com.squareup.gifencoder.Image;
|
||||||
import com.squareup.gifencoder.ImageOptions;
|
import com.squareup.gifencoder.ImageOptions;
|
||||||
import io.netty.handler.codec.http.HttpHeaderNames;
|
import io.netty.handler.codec.http.HttpHeaderNames;
|
||||||
import org.apache.commons.io.IOUtils;
|
|
||||||
import org.apache.http.HttpResponse;
|
import org.apache.http.HttpResponse;
|
||||||
import org.apache.http.client.HttpClient;
|
import org.apache.http.client.HttpClient;
|
||||||
import org.apache.http.client.methods.HttpGet;
|
import org.apache.http.client.methods.HttpGet;
|
||||||
import org.apache.http.util.EntityUtils;
|
import org.apache.http.util.EntityUtils;
|
||||||
|
import org.apache.tomcat.util.http.fileupload.util.Streams;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@ -126,7 +126,7 @@ public final class PixivUgoiraBuilder {
|
|||||||
HashMap<String, InputStream> frameMap = new HashMap<>(frames.size());
|
HashMap<String, InputStream> frameMap = new HashMap<>(frames.size());
|
||||||
while((entry = zipInputStream.getNextEntry()) != null) {
|
while((entry = zipInputStream.getNextEntry()) != null) {
|
||||||
log.trace("ZipEntry {} 正在接收...", entry);
|
log.trace("ZipEntry {} 正在接收...", entry);
|
||||||
IOUtils.copy(zipInputStream, cacheOutputStream);
|
Streams.copy(zipInputStream, cacheOutputStream, false);
|
||||||
frameMap.put(entry.getName(), new ByteArrayInputStream(cacheOutputStream.toByteArray()));
|
frameMap.put(entry.getName(), new ByteArrayInputStream(cacheOutputStream.toByteArray()));
|
||||||
log.trace("ZipEntry {} 已接收完成.", entry);
|
log.trace("ZipEntry {} 已接收完成.", entry);
|
||||||
cacheOutputStream.reset();
|
cacheOutputStream.reset();
|
||||||
|
@ -50,7 +50,7 @@
|
|||||||
<AppenderRef ref="STANDARD_STDOUT"/>
|
<AppenderRef ref="STANDARD_STDOUT"/>
|
||||||
<AppenderRef ref="STANDARD_STDERR"/>
|
<AppenderRef ref="STANDARD_STDERR"/>
|
||||||
</Logger>
|
</Logger>
|
||||||
<Logger level="TRACE" name="mirai">
|
<Logger level="INFO" name="mirai">
|
||||||
<AppenderRef ref="STANDARD_STDOUT"/>
|
<AppenderRef ref="STANDARD_STDOUT"/>
|
||||||
<AppenderRef ref="STANDARD_STDERR"/>
|
<AppenderRef ref="STANDARD_STDERR"/>
|
||||||
</Logger>
|
</Logger>
|
||||||
|
@ -2,7 +2,6 @@ package net.lamgc.cgj.pixiv;
|
|||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import org.apache.commons.io.IOUtils;
|
|
||||||
import org.apache.http.HttpHost;
|
import org.apache.http.HttpHost;
|
||||||
import org.apache.http.client.CookieStore;
|
import org.apache.http.client.CookieStore;
|
||||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||||
@ -10,6 +9,7 @@ import org.apache.http.client.methods.HttpGet;
|
|||||||
import org.apache.http.impl.client.CloseableHttpClient;
|
import org.apache.http.impl.client.CloseableHttpClient;
|
||||||
import org.apache.http.impl.client.HttpClientBuilder;
|
import org.apache.http.impl.client.HttpClientBuilder;
|
||||||
import org.apache.http.util.EntityUtils;
|
import org.apache.http.util.EntityUtils;
|
||||||
|
import org.apache.tomcat.util.http.fileupload.util.Streams;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
@ -64,7 +64,7 @@ public class PixivDownloadTest {
|
|||||||
ZipEntry entry = new ZipEntry(link.substring(link.lastIndexOf("/") + 1));
|
ZipEntry entry = new ZipEntry(link.substring(link.lastIndexOf("/") + 1));
|
||||||
log.info("正在写入: " + entry.getName());
|
log.info("正在写入: " + entry.getName());
|
||||||
zos.putNextEntry(entry);
|
zos.putNextEntry(entry);
|
||||||
IOUtils.copy(inputStream, zos);
|
Streams.copy(inputStream, zos, false);
|
||||||
zos.flush();
|
zos.flush();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error("写入文件项时发生异常", e);
|
log.error("写入文件项时发生异常", e);
|
||||||
@ -96,7 +96,7 @@ public class PixivDownloadTest {
|
|||||||
ZipEntry entry = new ZipEntry(link.substring(link.lastIndexOf("/") + 1));
|
ZipEntry entry = new ZipEntry(link.substring(link.lastIndexOf("/") + 1));
|
||||||
log.info("正在写入: " + entry.getName());
|
log.info("正在写入: " + entry.getName());
|
||||||
zos.putNextEntry(entry);
|
zos.putNextEntry(entry);
|
||||||
IOUtils.copy(inputStream, zos);
|
Streams.copy(inputStream, zos, false);
|
||||||
zos.flush();
|
zos.flush();
|
||||||
log.info("已成功写入 {}", entry.getName());
|
log.info("已成功写入 {}", entry.getName());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -139,7 +139,7 @@ public class PixivDownloadTest {
|
|||||||
entry.setComment(rankInfo.toString());
|
entry.setComment(rankInfo.toString());
|
||||||
log.info("正在写入: " + entry.getName());
|
log.info("正在写入: " + entry.getName());
|
||||||
zos.putNextEntry(entry);
|
zos.putNextEntry(entry);
|
||||||
IOUtils.copy(inputStream, zos);
|
Streams.copy(inputStream, zos, false);
|
||||||
zos.flush();
|
zos.flush();
|
||||||
log.info("已成功写入 {}", entry.getName());
|
log.info("已成功写入 {}", entry.getName());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
Reference in New Issue
Block a user