Skip to content

Commit

Permalink
Merge pull request #221 from nICEnnnnnnnLee/dev
Browse files Browse the repository at this point in the history
V6.35 Update
  • Loading branch information
nICEnnnnnnnLee authored Sep 25, 2024
2 parents 9b772a2 + ff5dbe2 commit 94a177e
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 11 deletions.
9 changes: 6 additions & 3 deletions src/nicelee/bilibili/downloaders/impl/FLVDownloader.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ protected boolean download(String url, String avId, int qn, int page, String suf
// 下载完毕后,进行合并
convertingStatus = StatusEnum.PROCESSING;
boolean result = CmdUtil.convert(fName + suffix, links.length);
return throwErrorIfNotConvertOk(result);
return throwErrorIfNotConvertOk(result, fName);
} else {
url = tryBetterUrl(url);
String fileName = fName + suffix;
Expand All @@ -144,13 +144,16 @@ protected boolean download(String url, String avId, int qn, int page, String suf
}
}

protected boolean throwErrorIfNotConvertOk(boolean ok) {
protected boolean throwErrorIfNotConvertOk(boolean ok, String msg) {
if (ok) {
convertingStatus = StatusEnum.SUCCESS;
return true;
} else {
convertingStatus = StatusEnum.FAIL;
throw new BilibiliError("转码失败,请检查ffmpeg配置");
if(Global.alertIfFFmpegFail)
throw new BilibiliError("如需关闭该警告,请在配置页搜索并修改配置 bilibili.alert.ffmpegFail\n\t转码失败,请检查ffmpeg配置: " + msg);
else
return false;
}
}
/**
Expand Down
6 changes: 3 additions & 3 deletions src/nicelee/bilibili/downloaders/impl/M4SDownloader.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public boolean download(String url, String avId, int qn, int page) {
if (util.download(links[1], audioName, header.getBiliWwwM4sHeaders(avId))) {
convertingStatus = StatusEnum.PROCESSING;
boolean result = CmdUtil.convert(null, audioName, dstName);
return throwErrorIfNotConvertOk(result);
return throwErrorIfNotConvertOk(result, audioName);
}
return false;
}
Expand All @@ -70,15 +70,15 @@ public boolean download(String url, String avId, int qn, int page) {
totalTaskCnt = currentTask = 1;
convertingStatus = StatusEnum.PROCESSING;
boolean result = CmdUtil.convert(videoName, null, dstName);
return throwErrorIfNotConvertOk(result);
return throwErrorIfNotConvertOk(result, videoName);
}else if (util.download(links[1], audioName, header.getBiliWwwM4sHeaders(avId))) {
// 如下载成功,统计数据后重置
sumSuccessDownloaded += util.getTotalFileSize();
util.reset();
// 下载完毕后,进行合并
convertingStatus = StatusEnum.PROCESSING;
boolean result = CmdUtil.convert(videoName, audioName, dstName);
return throwErrorIfNotConvertOk(result);
return throwErrorIfNotConvertOk(result, dstName);
}
return false;
}
Expand Down
2 changes: 2 additions & 0 deletions src/nicelee/ui/Global.java
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ public class Global {
public static String[] ffmpegCmd4Merge;
@Config(key = "bilibili.flv.ffmpeg", note = "FLV合并时是否调用ffmpeg", defaultValue = "false", valids = { "true", "false" })
public static boolean flvUseFFmpeg = false;
@Config(key = "bilibili.alert.ffmpegFail", note = "ffmpeg合并失败是否抛出异常", defaultValue = "true", valids = { "true", "false" })
public static boolean alertIfFFmpegFail = true;
@Config(key = "bilibili.cmd.debug", note = "调用外部命令时是否显示输出", defaultValue = "false", valids = { "true", "false" })
public static boolean debugCmd;
// 批量下载设置相关
Expand Down
14 changes: 9 additions & 5 deletions src/nicelee/ui/TabSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,8 @@ public void focusLost(FocusEvent e) {
jpContent.add(value);

int blankWidth = totalWidth - txtValueWidth;
JLabel blank = this.createTextLabel(null, blankWidth, LINE_HEIGHT);
blank.setVisible(visible);
if (withBtnChooser) {
boolean isFile = !config.pathType().startsWith("dir");
JButton btnFileChooser = new JButton("...");
Expand All @@ -274,12 +276,14 @@ public void focusLost(FocusEvent e) {
}
});
btnFileChooser.setVisible(visible);
jpContent.add(btnFileChooser);
blankWidth = blankWidth - H_GAP;
JPanel p = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
p.add(btnFileChooser);
p.add(blank);
p.setVisible(visible);
jpContent.add(p);
} else {
jpContent.add(blank);
}
JLabel blank = this.createTextLabel(null, blankWidth, LINE_HEIGHT);
blank.setVisible(visible);
jpContent.add(blank);
}
if (visible)
lineOunt++;
Expand Down
3 changes: 3 additions & 0 deletions src/resources/app.config
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,9 @@ bilibili.alert.maxAlertPrompt = 5
# 当遇到不期望的480P视频时是否抛出异常
## https://github.com/nICEnnnnnnnLee/BilibiliDown/issues/141
bilibili.alert.qualityUnexpected = true

# ffmpeg合并失败是否抛出异常
bilibili.alert.ffmpegFail = true
#######################################################################################################
# 同时支持HTTP + HTTPS 代理
#proxyHost = 127.0.0.1
Expand Down

0 comments on commit 94a177e

Please sign in to comment.