哔哩哔哩视频下载,哔哩哔哩动画下载,blibli视频下载电脑
程序员文章站
2022-07-12 23:51:03
...
哔哩哔哩视频下载,哔哩哔哩动画下载,blibli视频下载电脑
哔哩哔哩视频重命名
================================
©Copyright 蕃薯耀 2021-02-26
http://fanshuyao.iteye.com/
没图片,请移步:
https://www.cnblogs.com/fanshuyao/p/14451413.html
哔哩哔哩视频下载需要使用电脑软件:哔哩哔哩动画
一、哔哩哔哩动画,当前版本是:v2.13.10,微软官网下载地址:
https://www.microsoft.com/zh-cn/p/%e5%93%94%e5%93%a9%e5%93%94%e5%93%a9%e5%8a%a8%e7%94%bb/9nblggh5q5fv?activetab=pivot:overviewtab
二、通过软件下载的视频不规范,需要重命名哔哩哔哩视频的名称
每个视频都生成一个目录,太杂乱
文件夹下的视频名称很不明确
三、通过软件整理视频的名称
整理后的效果:
软件下载地址:
链接: https://pan.baidu.com/s/1PB6C5AczNEF9kPw7FnetuQ 提取码: vdvw
基于Jdk8运行使用:
软件运行截图:
四、核心代码
import java.io.File; import java.util.Date; import java.util.LinkedList; import java.util.Map; import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.stereotype.Service; import com.lqy.blibli.video.VideoComparator; import com.lqy.blibli.video.service.VideoService; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.io.FileUtil; import cn.hutool.json.JSONUtil; @Service public class VideoServiceImpl implements VideoService{ private Log log = LogFactory.getLog(getClass()); @Override public void saveVideos(String sourcePath, String destinationPath) { log.info("sourcePath=" + sourcePath); log.info("destinationPath=" + destinationPath); if(StringUtils.isBlank(sourcePath)) { throw new RuntimeException("源路径不能为空"); } File sourceDir = new File(sourcePath); if(!sourceDir.exists()) { throw new RuntimeException("源路径不存在"); } if(!sourceDir.isDirectory()) { throw new RuntimeException("源路径不是文件夹"); } File[] files = sourceDir.listFiles(); if(files == null || files.length < 1) { log.warn("源路径无文件"); throw new RuntimeException("源路径无文件"); } String destinationPathDirName = ""; LinkedList<File> dirFiles = new LinkedList<File>(); //获取文件和主目录名 for (File file : files) { if(file.isFile()) {//文件 String fileName = file.getName(); if(fileName.endsWith(".dvi")) { String dviFileString = FileUtil.readUtf8String(file); if(!StringUtils.isBlank(dviFileString)) { @SuppressWarnings("unchecked") Map<String, Object> dviMap = JSONUtil.toBean(dviFileString, Map.class); destinationPathDirName = (String) dviMap.get("Title"); } }else { continue; } }else { dirFiles.add(file); } } if(StringUtils.isBlank(destinationPathDirName)) { destinationPathDirName = new Date().getTime() + ""; } if(StringUtils.isBlank(destinationPath)) { destinationPath = sourceDir.getParent() + File.separator + destinationPathDirName; } //创建目标文件夹 if(!StringUtils.isBlank(destinationPath)) { File destinationPathDir = new File(destinationPath); if(!destinationPathDir.exists()) { destinationPathDir.mkdirs(); } } //对dirFiles排序 CollectionUtil.sort(dirFiles, new VideoComparator()); //复制文件 for (File dirFile : dirFiles) {//循环目录 log.warn("dirFile=" + dirFile.getAbsolutePath()); String dirFileName = dirFile.getName(); log.warn("dirFileName=" + dirFileName); File videoFile = null; String videoName = ""; File[] videoFiles = dirFile.listFiles(); for (File file : videoFiles) { String fileName = file.getName(); log.warn("fileName=" + fileName); if(fileName.endsWith(".mp4")) { videoFile = file; continue; } if(StringUtils.isBlank(videoName)) { if(fileName.endsWith(".info")) { String infoFileString = FileUtil.readUtf8String(file); if(!StringUtils.isBlank(infoFileString)) { @SuppressWarnings("unchecked") Map<String, Object> dviMap = JSONUtil.toBean(infoFileString, Map.class); String PartName = (String) dviMap.get("PartName"); log.warn("PartName=" + PartName); String prefix = this.getNamePrefix(dirFileName); log.warn("prefix=" + prefix); if(StringUtils.isNotBlank(PartName)) { videoName = prefix + PartName; }else { videoName = prefix + fileName; } } } } } if(videoFile != null) { String destinationFile = destinationPath + File.separator + videoName + ".mp4"; log.info("destinationFile=" + destinationFile); FileUtil.copy(videoFile, new File(destinationFile), true); log.info("++++++++++++++++++++++++++++++++++++++++++++++"); } } log.info("================结束================"); } private synchronized String getNamePrefix(String number) { Integer num = Integer.parseInt(number); String numString = ""; if(num < 10) { numString = "00"; } if(num >= 10 && num < 100) { numString = "0"; } String name = numString + num + "-"; //log.info("number=" +number); //log.info("name=" +name); return name; } }
(如果文章对您有所帮助,欢迎捐赠,^_^)
================================
©Copyright 蕃薯耀 2021-02-26
http://fanshuyao.iteye.com/