Skip to content

Commit

Permalink
新增功能 nICEnnnnnnnLee#38 saveFolder配置支持部分约定的变量
Browse files Browse the repository at this point in the history
  • Loading branch information
nICEnnnnnnnLee committed Apr 22, 2020
1 parent 7e26e65 commit 8e8778d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
5 changes: 0 additions & 5 deletions src/main/java/nicelee/bilibili/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,6 @@ public static void init(String[] args) {
}
}
// 后续补充措施
if (saveFolderAfterCheck != null) {
File f = new File(saveFolderAfterCheck);
if (!f.exists())
f.mkdirs();
}
String value = getValue(args[0], "proxy"); // http(s)代理 e.g. 127.0.0.1:8888
if (value != null && !value.isEmpty()) {
String argus[] = value.split(":");
Expand Down
20 changes: 16 additions & 4 deletions src/main/java/nicelee/bilibili/threads/ThRecord.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,29 @@ public void run() {
}
}

static String pathFormat(String pattern, RoomInfo roomInfo, SimpleDateFormat sdf) {
return pattern.replace("{name}", roomInfo.getUserName()).replace("{shortId}", roomInfo.getShortId())
.replace("{roomId}", roomInfo.getRoomId()).replace("{liver}", Config.liver)
.replace("{startTime}", sdf.format(new Date()));
}

static void record(RoomDealer roomDealer, RoomInfo roomInfo, String url, List<String> fileList) {
SimpleDateFormat sdf = new SimpleDateFormat(Config.timeFormat);
// "{name}-{shortId} 的{liver}直播{startTime}-{seq}";
String realName = Config.fileName.replace("{name}", roomInfo.getUserName())
.replace("{shortId}", roomInfo.getShortId()).replace("{roomId}", roomInfo.getRoomId())
.replace("{liver}", Config.liver).replace("{startTime}", sdf.format(new Date()))
.replace("{seq}", "" + fileList.size()).replaceAll("[\\\\|\\/|:\\*\\?|<|>|\\||\\\"$]", ".");
String realName = pathFormat(Config.fileName, roomInfo, sdf).replace("{seq}", "" + fileList.size())
.replaceAll("[\\\\|\\/|:\\*\\?|<|>|\\||\\\"$]", ".");
// 如果saveFolder不为空
if (Config.saveFolder != null) {
pathFormat(Config.saveFolder, roomInfo, sdf);
roomDealer.util.setSavePath(Config.saveFolder);
}
// 如果saveFolderAfterCheck不为空
if (Config.autoCheck && Config.saveFolderAfterCheck != null) {
pathFormat(Config.saveFolderAfterCheck, roomInfo, sdf);
File f = new File(Config.saveFolderAfterCheck);
if (!f.exists())
f.mkdirs();
}
roomDealer.startRecord(url, realName, roomInfo.getShortId());// 此处一直堵塞, 直至停止
File file = roomDealer.util.getFileDownload();

Expand Down

0 comments on commit 8e8778d

Please sign in to comment.