|
|
@ -17,7 +17,6 @@ import java.awt.image.BufferedImage; |
|
|
|
import java.io.*; |
|
|
|
import java.io.*; |
|
|
|
import java.util.Enumeration; |
|
|
|
import java.util.Enumeration; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
import java.util.concurrent.TimeUnit; |
|
|
|
|
|
|
|
import java.util.zip.ZipEntry; |
|
|
|
import java.util.zip.ZipEntry; |
|
|
|
import java.util.zip.ZipFile; |
|
|
|
import java.util.zip.ZipFile; |
|
|
|
|
|
|
|
|
|
|
@ -46,7 +45,7 @@ public class PixivUtil implements LogManger{ |
|
|
|
BufferedOutputStream bos = null; |
|
|
|
BufferedOutputStream bos = null; |
|
|
|
ZipFile zipFile = null; |
|
|
|
ZipFile zipFile = null; |
|
|
|
String imageUrl=baseUrl+illust_id; |
|
|
|
String imageUrl=baseUrl+illust_id; |
|
|
|
String path=null; |
|
|
|
String path; |
|
|
|
try { |
|
|
|
try { |
|
|
|
log.info("图片链接:"+imageUrl); |
|
|
|
log.info("图片链接:"+imageUrl); |
|
|
|
Connection.Response response=Jsoup.connect(imageUrl).cookie("PHPSESSID",phpsessid).execute(); |
|
|
|
Connection.Response response=Jsoup.connect(imageUrl).cookie("PHPSESSID",phpsessid).execute(); |
|
|
@ -91,7 +90,8 @@ public class PixivUtil implements LogManger{ |
|
|
|
while ((count = is.read(buf)) > -1) { |
|
|
|
while ((count = is.read(buf)) > -1) { |
|
|
|
bos.write(buf, 0, count); |
|
|
|
bos.write(buf, 0, count); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
bos.close(); |
|
|
|
|
|
|
|
is.close(); |
|
|
|
ImageIO.write(ImageIO.read(imgFile),"png",new File(imgPath.replace("jpg","png"))); |
|
|
|
ImageIO.write(ImageIO.read(imgFile),"png",new File(imgPath.replace("jpg","png"))); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -114,15 +114,7 @@ public class PixivUtil implements LogManger{ |
|
|
|
e.printStackTrace(); |
|
|
|
e.printStackTrace(); |
|
|
|
}finally { |
|
|
|
}finally { |
|
|
|
try { |
|
|
|
try { |
|
|
|
if(bos != null){ |
|
|
|
|
|
|
|
bos.close(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(fos != null) { |
|
|
|
|
|
|
|
fos.close(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(is != null){ |
|
|
|
|
|
|
|
is.close(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(zipFile != null){ |
|
|
|
if(zipFile != null){ |
|
|
|
zipFile.close(); |
|
|
|
zipFile.close(); |
|
|
|
} |
|
|
|
} |
|
|
@ -153,6 +145,7 @@ public class PixivUtil implements LogManger{ |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static void jpgToGif(String gifName,String jpgPath,JsonNode node){ |
|
|
|
public static void jpgToGif(String gifName,String jpgPath,JsonNode node){ |
|
|
|
AnimatedGifEncoder animatedGifEncoder=new AnimatedGifEncoder(); |
|
|
|
AnimatedGifEncoder animatedGifEncoder=new AnimatedGifEncoder(); |
|
|
|
|
|
|
|
|
|
|
|
OutputStream outputStream= null; |
|
|
|
OutputStream outputStream= null; |
|
|
|
InputStream inputStream=null; |
|
|
|
InputStream inputStream=null; |
|
|
|
File file=new File(jpgPath); |
|
|
|
File file=new File(jpgPath); |
|
|
@ -180,8 +173,8 @@ public class PixivUtil implements LogManger{ |
|
|
|
//把帧添加进去合成
|
|
|
|
//把帧添加进去合成
|
|
|
|
animatedGifEncoder.addFrame(image); |
|
|
|
animatedGifEncoder.addFrame(image); |
|
|
|
animatedGifEncoder.setDelay(delay); |
|
|
|
animatedGifEncoder.setDelay(delay); |
|
|
|
|
|
|
|
|
|
|
|
log.info(gifName+":正在合成第"+((index+1)+"帧")); |
|
|
|
log.info(gifName+":正在合成第"+((index+1)+"帧")); |
|
|
|
|
|
|
|
inputStream.close(); |
|
|
|
} |
|
|
|
} |
|
|
|
//添加完所有帧开始合成
|
|
|
|
//添加完所有帧开始合成
|
|
|
|
animatedGifEncoder.finish(); |
|
|
|
animatedGifEncoder.finish(); |
|
|
@ -197,17 +190,10 @@ public class PixivUtil implements LogManger{ |
|
|
|
if(outputStream!=null){ |
|
|
|
if(outputStream!=null){ |
|
|
|
outputStream.close(); |
|
|
|
outputStream.close(); |
|
|
|
} |
|
|
|
} |
|
|
|
if(inputStream!=null){ |
|
|
|
FileUtils.deleteDirectory(file); |
|
|
|
inputStream.close(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (!FileUtils.deleteQuietly(file)){ |
|
|
|
|
|
|
|
TimeUnit.SECONDS.sleep(1); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} catch (IOException e) { |
|
|
|
} catch (IOException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
e.printStackTrace(); |
|
|
|
} catch (InterruptedException e) { |
|
|
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|