From 8cb99d16e23fafddfa2d2477a0de78d7bb3b1aca Mon Sep 17 00:00:00 2001 From: lijia Date: Mon, 19 Aug 2024 08:47:35 +0800 Subject: [PATCH 01/15] =?UTF-8?q?dep:=20=E7=B2=BE=E7=AE=80JRE=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=A8=A1=E5=9D=97`jdk.crypto.ec`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/scripts/gen_zip_sha1_for_release.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/scripts/gen_zip_sha1_for_release.sh b/.github/scripts/gen_zip_sha1_for_release.sh index 7a11c2b4..ae6afae6 100644 --- a/.github/scripts/gen_zip_sha1_for_release.sh +++ b/.github/scripts/gen_zip_sha1_for_release.sh @@ -29,8 +29,8 @@ zip -m "BilibiliDown.v$VERSION_NUMBER.release.zip" ./update.bat zip -rm "BilibiliDown.v$VERSION_NUMBER.release.zip" ./config/ zip -rm "BilibiliDown.v$VERSION_NUMBER.release.zip" ./LICENSE/ -wget https://github.com/nICEnnnnnnnLee/BilibiliDown/releases/download/V4.5/minimal-bilibilidown-jre11.0.23_9_win_x64.zip -unzip minimal-bilibilidown-jre11.0.23_9_win_x64.zip +wget https://github.com/nICEnnnnnnnLee/BilibiliDown/releases/download/V4.5/minimal-bilibilidown-jre11.0.23_9.crypto.ec_win_x64.zip +unzip minimal-bilibilidown-jre11.0.23_9.crypto.ec_win_x64.zip cp "BilibiliDown.v$VERSION_NUMBER.release.zip" "BilibiliDown.v$VERSION_NUMBER.win_x64_jre11.release.zip" zip -rm "BilibiliDown.v$VERSION_NUMBER.win_x64_jre11.release.zip" ./minimal-bilibilidown-jre/ From a0b3d62ab646ebcb69574158d746f2a783335c0d Mon Sep 17 00:00:00 2001 From: lijia Date: Tue, 27 Aug 2024 10:06:47 +0800 Subject: [PATCH 02/15] =?UTF-8?q?feat:=20=E5=9C=A8=E8=BD=AC=E7=A0=81?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E7=9A=84=E6=97=B6=E5=80=99=EF=BC=8C=E5=BC=B9?= =?UTF-8?q?=E5=87=BA=E6=A3=80=E6=9F=A5ffmpeg=E9=85=8D=E7=BD=AE=E7=9A=84?= =?UTF-8?q?=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../downloaders/impl/FLVDownloader.java | 18 +++++++++++------- .../downloaders/impl/M4SDownloader.java | 19 +++---------------- .../ui/thread/DownloadRunnableInternal.java | 4 ++++ 3 files changed, 18 insertions(+), 23 deletions(-) diff --git a/src/nicelee/bilibili/downloaders/impl/FLVDownloader.java b/src/nicelee/bilibili/downloaders/impl/FLVDownloader.java index fe45045a..71236899 100644 --- a/src/nicelee/bilibili/downloaders/impl/FLVDownloader.java +++ b/src/nicelee/bilibili/downloaders/impl/FLVDownloader.java @@ -7,10 +7,10 @@ import nicelee.bilibili.annotations.Bilibili; import nicelee.bilibili.downloaders.IDownloader; import nicelee.bilibili.enums.StatusEnum; +import nicelee.bilibili.exceptions.BilibiliError; import nicelee.bilibili.util.CmdUtil; import nicelee.bilibili.util.HttpHeaders; import nicelee.bilibili.util.HttpRequestUtil; -import nicelee.bilibili.util.Logger; import nicelee.ui.Global; @@ -131,12 +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); - if (result) { - convertingStatus = StatusEnum.SUCCESS; - } else { - convertingStatus = StatusEnum.FAIL; - } - return result; + return throwErrorIfNotConvertOk(result); } else { url = tryBetterUrl(url); String fileName = fName + suffix; @@ -149,6 +144,15 @@ protected boolean download(String url, String avId, int qn, int page, String suf } } + protected boolean throwErrorIfNotConvertOk(boolean ok) { + if (ok) { + convertingStatus = StatusEnum.SUCCESS; + return true; + } else { + convertingStatus = StatusEnum.FAIL; + throw new BilibiliError("转码失败,请检查ffmpeg配置"); + } + } /** * 返回当前状态 * diff --git a/src/nicelee/bilibili/downloaders/impl/M4SDownloader.java b/src/nicelee/bilibili/downloaders/impl/M4SDownloader.java index 19773fe9..5bfe7937 100644 --- a/src/nicelee/bilibili/downloaders/impl/M4SDownloader.java +++ b/src/nicelee/bilibili/downloaders/impl/M4SDownloader.java @@ -53,11 +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); - if (result) - convertingStatus = StatusEnum.SUCCESS; - else - convertingStatus = StatusEnum.FAIL; - return result; + return throwErrorIfNotConvertOk(result); } return false; } @@ -74,11 +70,7 @@ public boolean download(String url, String avId, int qn, int page) { totalTaskCnt = currentTask = 1; convertingStatus = StatusEnum.PROCESSING; boolean result = CmdUtil.convert(videoName, null, dstName); - if (result) - convertingStatus = StatusEnum.SUCCESS; - else - convertingStatus = StatusEnum.FAIL; - return result; + return throwErrorIfNotConvertOk(result); }else if (util.download(links[1], audioName, header.getBiliWwwM4sHeaders(avId))) { // 如下载成功,统计数据后重置 sumSuccessDownloaded += util.getTotalFileSize(); @@ -86,12 +78,7 @@ public boolean download(String url, String avId, int qn, int page) { // 下载完毕后,进行合并 convertingStatus = StatusEnum.PROCESSING; boolean result = CmdUtil.convert(videoName, audioName, dstName); - if (result) { - convertingStatus = StatusEnum.SUCCESS; - } else { - convertingStatus = StatusEnum.FAIL; - } - return result; + return throwErrorIfNotConvertOk(result); } return false; } diff --git a/src/nicelee/ui/thread/DownloadRunnableInternal.java b/src/nicelee/ui/thread/DownloadRunnableInternal.java index 510cbd78..7fd0246e 100644 --- a/src/nicelee/ui/thread/DownloadRunnableInternal.java +++ b/src/nicelee/ui/thread/DownloadRunnableInternal.java @@ -4,6 +4,7 @@ import nicelee.bilibili.INeedAV; import nicelee.bilibili.downloaders.Downloader; import nicelee.bilibili.enums.StatusEnum; +import nicelee.bilibili.exceptions.BilibiliError; import nicelee.bilibili.parsers.InputParser; import nicelee.bilibili.util.CmdUtil; import nicelee.bilibili.util.Logger; @@ -12,6 +13,7 @@ import nicelee.bilibili.util.custom.System; import nicelee.ui.Global; import nicelee.ui.item.DownloadInfoPanel; +import nicelee.ui.item.JOptionPaneManager; public class DownloadRunnableInternal implements Runnable { @@ -103,6 +105,8 @@ public void run() { } CmdUtil.convertOrAppendCmdToRenameBat(avid_qn, formattedTitle, page); } + } catch (BilibiliError e) { + JOptionPaneManager.alertErrMsgWithNewThread("发生了预料之外的错误", ResourcesUtil.detailsOfException(e)); } catch (Exception e) { e.printStackTrace(); } From f68cdcb7f45bd4e08983dcf1664eb5ef03cab581 Mon Sep 17 00:00:00 2001 From: lijia Date: Tue, 27 Aug 2024 15:23:08 +0800 Subject: [PATCH 03/15] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=B8=8B?= =?UTF-8?q?=E8=BD=BDBeta=E7=89=88=E6=9C=AC=E5=8F=AF=E8=83=BD=E6=8A=A5?= =?UTF-8?q?=E9=94=99=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/VersionBetaDownloader.java | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/nicelee/bilibili/downloaders/impl/VersionBetaDownloader.java b/src/nicelee/bilibili/downloaders/impl/VersionBetaDownloader.java index 13768da4..c76a4fe8 100644 --- a/src/nicelee/bilibili/downloaders/impl/VersionBetaDownloader.java +++ b/src/nicelee/bilibili/downloaders/impl/VersionBetaDownloader.java @@ -2,7 +2,10 @@ import java.io.File; import java.io.IOException; +import java.net.HttpURLConnection; +import java.net.URL; import java.util.HashMap; +import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -13,6 +16,7 @@ import nicelee.bilibili.annotations.Bilibili; import nicelee.bilibili.enums.StatusEnum; +import nicelee.bilibili.util.HttpHeaders; import nicelee.bilibili.util.Logger; import nicelee.bilibili.util.VersionManagerUtil; import nicelee.ui.Global; @@ -73,6 +77,7 @@ public boolean download(String _url, String avId, int qn, int page) { // sumSuccessDownloaded = artifact.optLong("size_in_bytes", 0); Logger.println(downName); Logger.println(url); + String realUrl = getLocation(url, headers); // 开始下载 if (file == null) { file = new File(updateDir, downName); @@ -81,7 +86,7 @@ public boolean download(String _url, String avId, int qn, int page) { util.setSavePath(updateDir.getCanonicalPath()); } catch (IOException e1) { } - boolean succ = util.download(url, downName, headers); + boolean succ = util.download(realUrl, downName, new HttpHeaders().getCommonHeaders()); if (succ) { sumSuccessDownloaded += util.getTotalFileSize(); util.reset(); @@ -100,4 +105,27 @@ public boolean download(String _url, String avId, int qn, int page) { return succ; } + private String getLocation(String url, Map headers) { + try { + URL url0 = new URL(url); + HttpURLConnection conn = (HttpURLConnection) url0.openConnection(); + conn.setInstanceFollowRedirects(false); + for (Map.Entry entry : headers.entrySet()) { + conn.setRequestProperty(entry.getKey(), entry.getValue()); + } + conn.connect(); + + int code = conn.getResponseCode(); + if (code == 301 || code == 302) { + String location = conn.getHeaderField("Location"); + Logger.println(location); + return getLocation(location, headers); + } else { + return url; + } + } catch (IOException e) { + e.printStackTrace(); + return url; + } + } } From 43b650c6ed81e6cda5ec7e611be97c54395ba262 Mon Sep 17 00:00:00 2001 From: lijia Date: Thu, 29 Aug 2024 20:09:24 +0800 Subject: [PATCH 04/15] =?UTF-8?q?ui:=20=E5=AF=B9`Graphics=20g`=E5=81=9A?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=97=B6=E4=BD=BF=E7=94=A8=E5=AE=83=E7=9A=84?= =?UTF-8?q?copy=E5=89=AF=E6=9C=AC=E3=80=82=20#213?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/nicelee/ui/TabDownload.java | 13 +++++++++++-- src/nicelee/ui/TabIndex.java | 13 +++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/nicelee/ui/TabDownload.java b/src/nicelee/ui/TabDownload.java index de188918..1588f89e 100644 --- a/src/nicelee/ui/TabDownload.java +++ b/src/nicelee/ui/TabDownload.java @@ -99,8 +99,12 @@ public void initUI() { } @Override - public void paintComponent(Graphics g) { -// // super.paintComponent(g); + public void paintComponent(Graphics og) { + if (ui == null || og == null) { + return; + } + // https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/swing002.html#JSTGD472 + Graphics g = og.create(); Image img = backgroundIcon.getImage(); int width = img.getWidth(this.getParent()); int height = img.getHeight(this.getParent()); @@ -120,6 +124,11 @@ public void paintComponent(Graphics g) { g.drawImage(backgroundIcon.getImage(), 0, 0, this.getSize().width, this.getSize().height, this.getParent()); } this.setOpaque(false); + try { + ui.update(g, this); + } finally { + g.dispose(); + } } @Override diff --git a/src/nicelee/ui/TabIndex.java b/src/nicelee/ui/TabIndex.java index 695144a1..46e8bee5 100644 --- a/src/nicelee/ui/TabIndex.java +++ b/src/nicelee/ui/TabIndex.java @@ -145,8 +145,12 @@ public void downVideoTabs(boolean downAll, int qn) { } } @Override - public void paintComponent(Graphics g) { -// // super.paintComponent(g); + public void paintComponent(Graphics og) { + if (ui == null || og == null) { + return; + } + // https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/swing002.html#JSTGD472 + Graphics g = og.create(); Image img = backgroundIcon.getImage(); int width = img.getWidth(this.getParent()); int height = img.getHeight(this.getParent()); @@ -166,6 +170,11 @@ public void paintComponent(Graphics g) { g.drawImage(backgroundIcon.getImage(), 0, 0, this.getSize().width, this.getSize().height, this.getParent()); } this.setOpaque(false); + try { + ui.update(g, this); + } finally { + g.dispose(); + } } /** From e2c83205f12574cc4cab22546d60213ab5132b7a Mon Sep 17 00:00:00 2001 From: lijia Date: Fri, 30 Aug 2024 20:17:47 +0800 Subject: [PATCH 05/15] =?UTF-8?q?ui:=20=E7=B2=BE=E7=AE=80=E5=AE=9A?= =?UTF-8?q?=E5=88=B6JButton=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/nicelee/ui/item/MJButton.java | 136 +----------------------------- 1 file changed, 2 insertions(+), 134 deletions(-) diff --git a/src/nicelee/ui/item/MJButton.java b/src/nicelee/ui/item/MJButton.java index 0d72a699..29f51998 100644 --- a/src/nicelee/ui/item/MJButton.java +++ b/src/nicelee/ui/item/MJButton.java @@ -1,27 +1,10 @@ package nicelee.ui.item; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.FontMetrics; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.RenderingHints; -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import javax.swing.AbstractButton; -import javax.swing.BorderFactory; import javax.swing.Icon; import javax.swing.JButton; -import javax.swing.JComponent; -import javax.swing.UIManager; -import javax.swing.border.Border; -import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicButtonUI; -import nicelee.bilibili.util.Logger; import nicelee.ui.Global; public class MJButton extends JButton { @@ -45,122 +28,7 @@ public MJButton(Icon icon) { void setUI(boolean isSet) { if (isSet) { - this.setUI(new MyButtonUI()); + this.setUI(new BasicButtonUI()); } } -} - -class MyButtonUI extends BasicButtonUI implements java.io.Serializable, MouseListener, KeyListener { - private static final long serialVersionUID = -7267196158169247L; - - private final static MyButtonUI m_buttonUI = new MyButtonUI(); - - protected Border m_borderRaised = UIManager.getBorder("Button.border"); - - protected Border m_borderLowered = BorderFactory.createLineBorder(Color.LIGHT_GRAY, 2, true); -// protected Border m_borderLowered = UIManager.getBorder("Button.borderPressed"); - - protected Color m_backgroundNormal = UIManager.getColor("Button.background"); - - protected Color m_backgroundPressed = UIManager.getColor("Button.pressedBackground"); - - protected Color m_foregroundNormal = UIManager.getColor("Button.foreground"); - - protected Color m_foregroundActive = UIManager.getColor("Button.activeForeground"); - - protected Color m_focusBorder = UIManager.getColor("Button.focusBorder"); - - public static ComponentUI createUI(JComponent c) { - return m_buttonUI; - } - - public void installUI(JComponent c) { - super.installUI(c); - - c.addMouseListener(this); - c.addKeyListener(this); - } - - public void uninstallUI(JComponent c) { - super.uninstallUI(c); - c.removeMouseListener(this); - c.removeKeyListener(this); - } - -// public void paint(Graphics g, JComponent c) { - public void paint(Graphics2D g, JComponent c) { - AbstractButton b = (AbstractButton) c; - Dimension d = b.getSize(); - - g.setFont(c.getFont()); - FontMetrics fm = g.getFontMetrics(); - g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_ON); - - g.setColor(b.getForeground()); - String caption = b.getText(); - int x = (d.width - fm.stringWidth(caption)) / 2; - int y = (d.height + fm.getAscent()) / 2; - g.drawString(caption, x, y); - - } - - public Dimension getPreferredSize(JComponent c) { - Dimension d = super.getPreferredSize(c); -// if (m_borderRaised != null) { -// Insets ins = m_borderRaised.getBorderInsets(c); -// d.setSize(d.width + ins.left + ins.right, d.height + ins.top -// + ins.bottom); -// } - Logger.println("d.width:" + d.width + ", d.height:" + d.height); - return d; - } - - public void mouseClicked(MouseEvent e) { - } - - public void mousePressed(MouseEvent e) { - JComponent c = (JComponent) e.getComponent(); - c.setBorder(m_borderLowered); - c.setBackground(m_backgroundPressed); - } - - public void mouseReleased(MouseEvent e) { - JComponent c = (JComponent) e.getComponent(); - c.setBorder(m_borderRaised); - c.setBackground(m_backgroundNormal); - } - - public void mouseEntered(MouseEvent e) { - JComponent c = (JComponent) e.getComponent(); - c.setForeground(m_foregroundActive); - c.repaint(); - } - - public void mouseExited(MouseEvent e) { - JComponent c = (JComponent) e.getComponent(); - c.setForeground(m_foregroundNormal); - c.repaint(); - } - - public void keyTyped(KeyEvent e) { - } - - public void keyPressed(KeyEvent e) { - int code = e.getKeyCode(); - if (code == KeyEvent.VK_ENTER || code == KeyEvent.VK_SPACE) { - JComponent c = (JComponent) e.getComponent(); - c.setBorder(m_borderLowered); - c.setBackground(m_backgroundPressed); - } - } - - public void keyReleased(KeyEvent e) { - int code = e.getKeyCode(); - if (code == KeyEvent.VK_ENTER || code == KeyEvent.VK_SPACE) { - JComponent c = (JComponent) e.getComponent(); - c.setBorder(m_borderRaised); - c.setBackground(m_backgroundNormal); - } - } - -} +} \ No newline at end of file From 40dc3b78097b2a332681003e882afa03792599f0 Mon Sep 17 00:00:00 2001 From: lijia Date: Fri, 30 Aug 2024 20:18:51 +0800 Subject: [PATCH 06/15] =?UTF-8?q?ui:=20JMenuBar=E5=88=B7=E6=96=B0=E6=97=B6?= =?UTF-8?q?,=E9=80=9A=E7=9F=A5Tab=E5=88=B7=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/nicelee/ui/item/MJTitleBar.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/nicelee/ui/item/MJTitleBar.java b/src/nicelee/ui/item/MJTitleBar.java index 928a7d83..6d0101c4 100644 --- a/src/nicelee/ui/item/MJTitleBar.java +++ b/src/nicelee/ui/item/MJTitleBar.java @@ -4,6 +4,7 @@ import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.Font; +import java.awt.Graphics; import java.awt.Image; import java.awt.Point; import java.awt.event.MouseEvent; @@ -53,6 +54,14 @@ public MJTitleBar(JFrame frame, boolean setTitle, boolean setMenuBar) { init(); } + @Override + public void paintComponent(Graphics g) { + super.paintComponent(g); +// frame.repaint(); +// Logger.println("-------- notify other part of main frame to update ui ---------"); + Global.tabs.repaint(); + } + private void init() { // frame 去掉标题栏 frame.setUndecorated(true); From 3f9f05751f2c0f5cf5d8d114886ff15ee14069b1 Mon Sep 17 00:00:00 2001 From: lijia Date: Fri, 30 Aug 2024 21:04:35 +0800 Subject: [PATCH 07/15] =?UTF-8?q?feat:=20=E5=8F=AF=E4=BB=A5=E9=80=9A?= =?UTF-8?q?=E8=BF=87JVM=E5=8F=82=E6=95=B0=E6=8C=87=E5=AE=9A=E5=8A=A0?= =?UTF-8?q?=E8=BD=BD=E7=B1=BB=E7=9A=84mainClass?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src-launcher/nicelee/memory/App.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src-launcher/nicelee/memory/App.java b/src-launcher/nicelee/memory/App.java index 7eddf512..c8bbdee9 100644 --- a/src-launcher/nicelee/memory/App.java +++ b/src-launcher/nicelee/memory/App.java @@ -40,8 +40,9 @@ public static void main(String[] args) throws FileNotFoundException, IOException System.out.println(pd.getCodeSource().getLocation().getPath()); MemoryClassLoader mcl = new MemoryClassLoader(pd); + String mainClass = System.getProperty("bilibili.prop.mainClass", "nicelee.ui.FrameMain"); try { - Class clazz = mcl.loadClass("nicelee.ui.FrameMain"); + Class clazz = mcl.loadClass(mainClass); Method method = clazz.getMethod("main", new Class[] { String[].class }); method.invoke(null, (Object) args); } catch (ClassNotFoundException | IllegalAccessException | IllegalArgumentException | InvocationTargetException From faa370a0cfbe03f2e53b8723e5090a34f17bc071 Mon Sep 17 00:00:00 2001 From: lijia Date: Fri, 30 Aug 2024 21:39:44 +0800 Subject: [PATCH 08/15] =?UTF-8?q?ui:=20=E5=A4=87=E7=94=A8=E5=85=A5?= =?UTF-8?q?=E5=8F=A3=E7=B1=BB=E5=90=8C=E6=AD=A5=E5=9F=BA=E7=A1=80=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/nicelee/ui/FrameMain_v3_4.java | 126 +++++++++++++++++++++++++---- 1 file changed, 111 insertions(+), 15 deletions(-) diff --git a/src/nicelee/ui/FrameMain_v3_4.java b/src/nicelee/ui/FrameMain_v3_4.java index e5070fa4..2aa4dfd6 100644 --- a/src/nicelee/ui/FrameMain_v3_4.java +++ b/src/nicelee/ui/FrameMain_v3_4.java @@ -11,12 +11,22 @@ import javax.swing.JTabbedPane; import javax.swing.UIManager; +import nicelee.bilibili.INeedAV; import nicelee.bilibili.INeedLogin; +import nicelee.bilibili.PackageScanLoader; +import nicelee.bilibili.model.VideoInfo; import nicelee.bilibili.util.CmdUtil; import nicelee.bilibili.util.ConfigUtil; +import nicelee.bilibili.util.HttpCookies; import nicelee.bilibili.util.Logger; import nicelee.bilibili.util.RepoUtil; +import nicelee.bilibili.util.ResourcesUtil; +import nicelee.bilibili.util.SysUtil; +import nicelee.ui.item.JOptionPane; import nicelee.ui.item.MJMenuBar; +import nicelee.ui.thread.BatchDownloadRbyRThread; +import nicelee.ui.thread.CookieRefreshThread; +import nicelee.ui.thread.DownloadRunnable; import nicelee.ui.thread.LoginThread; import nicelee.ui.thread.MonitoringThread; @@ -29,35 +39,123 @@ public class FrameMain_v3_4 extends JFrame { JTabbedPane jTabbedpane;// 存放选项卡的组件 public static void main(String[] args) { + System.out.println(); // System.getProperties().setProperty("file.encoding", "utf-8"); + boolean isFFmpegSurported = SysUtil.surportFFmpegOfficially(); + System.out.println("Java version:" + System.getProperty("java.specification.version")); + System.out.println(ResourcesUtil.baseDirectory()); + // 读取配置文件 ConfigUtil.initConfigs(); - //初始化主题 - initUITheme(); + // -v 打印版本,然后退出 + if(args.length == 1 && "-v".equalsIgnoreCase(args[0])) { + System.out.println(Global.version); + System.exit(0); + } + // 显示过渡动画 + Global.frWaiting = new FrameWaiting(); + Global.frWaiting.start(); + + if (Global.lockCheck) { + if (ConfigUtil.isRunning()) { + Global.frWaiting.stop(); + JOptionPane.showMessageDialog(null, "程序已经在运行!", "请注意!!", JOptionPane.WARNING_MESSAGE); + return; + } + ConfigUtil.createLock(); + Runtime.getRuntime().addShutdownHook(new Thread(() -> { + ConfigUtil.deleteLock(); + })); + } - //初始化UI + nicelee.bilibili.util.custom.System.init(Global.syncServerTime); + // 初始化主题 + initUITheme(); + + // 初始化UI FrameMain_v3_4 main = new FrameMain_v3_4(); main.InitUI(); - - //初始化监控线程,用于刷新下载面板 + + // 初始化监控线程,用于刷新下载面板 MonitoringThread th = new MonitoringThread(); th.start(); - //初始化 - 登录 + // 尝试刷新cookie INeedLogin inl = new INeedLogin(); - if (inl.readCookies() != null) { + String cookiesStr = inl.readCookies(); + if (cookiesStr != null) { Global.needToLogin = true; + if(Global.tryRefreshCookieOnStartup && !Global.runWASMinBrowser) { + HttpCookies.setGlobalCookies(HttpCookies.convertCookies(cookiesStr)); + CookieRefreshThread.showTips = false; + CookieRefreshThread thCR = CookieRefreshThread.newInstance(); + thCR.start(); + try { + thCR.join(); + } catch (InterruptedException e1) { + } + CookieRefreshThread.showTips = true; + } } + // 初始化 - 登录 LoginThread loginTh = new LoginThread(); loginTh.start(); + // 初始化 - ffmpeg环境判断 + CmdUtil.DEFAULT_WORKING_DIR = ResourcesUtil.baseDirFile(); + String ffmpeg = ResourcesUtil.resolve(Global.ffmpegPath); + String[] cmd = new String[] { ffmpeg, "-version" }; + if (!CmdUtil.run(cmd)) { + if (isFFmpegSurported) { + Object[] options = { "是", "否" }; + int m = JOptionPane.showOptionDialog(null, + "检测到当前没有ffmpeg环境, mp4及小部分flv文件将无法转码或合并.\r\n 是否下载ffmpeg(自编译, 3M左右)?", "请选择:", + JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE, null, options, options[0]); + Logger.println(m); + if (m == 0) { + VideoInfo avInfo = new INeedAV().getVideoDetail("ffmpeg", 0, false); + DownloadRunnable downThread = new DownloadRunnable(avInfo, avInfo.getClips().get(1234L), 0); + Global.queryThreadPool.execute(downThread); + } + } else { + JOptionPane.showMessageDialog(null, "当前没有ffmpeg环境,大部分mp4及小部分flv文件将无法转码或合并", "请注意!!", + JOptionPane.WARNING_MESSAGE); + } + } else { + CmdUtil.FFMPEG_PATH = ffmpeg; + } + // - if(Global.saveToRepo) { + if (Global.saveToRepo) { RepoUtil.init(false); } - //Logger.println(.); -// FrameQRCode qr = new FrameQRCode("https://www.bilibili.com/"); -// qr.initUI(); -// qr.dispose(); + + // 预扫描加载类 + PackageScanLoader.validParserClasses.isEmpty(); + if(Global.batchDownloadRbyRRunOnStartup) { + // 开始按计划周期性批量下载 + new Thread(new Runnable() { + @Override + public void run() { + // 等待相关线程运行完毕 + try { + loginTh.join(); + } catch (InterruptedException e) {} + new BatchDownloadRbyRThread(Global.batchDownloadConfigName).start(); + } + }).start(); + } + System.out.println("如果过度界面显示时间过长,可双击跳过"); + try { + while (Global.frWaiting.isVisible()) { + Thread.sleep(1000); + } + } catch (InterruptedException e) { + Global.frWaiting.stop(); + } + Global.frWaiting = null; + main.setVisible(true); + main.setExtendedState(JFrame.NORMAL); + main.toFront(); } /** @@ -123,9 +221,7 @@ public void windowClosing(WindowEvent e) { CmdUtil.deleteAllInactiveCmdTemp(); } }); - this.setVisible(true); - Logger.println(jTabbedpane.getWidth()); - Logger.println(jTabbedpane.getHeight()); + SysTray.buildSysTray(this, icon.getImage()); } } From c60b3a657ded42ef2e484cc0cad2c6169a0fce31 Mon Sep 17 00:00:00 2001 From: lijia Date: Fri, 30 Aug 2024 23:27:22 +0800 Subject: [PATCH 09/15] =?UTF-8?q?chore:=20=E6=89=93=E5=8D=B0main=20class?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src-launcher/nicelee/memory/App.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src-launcher/nicelee/memory/App.java b/src-launcher/nicelee/memory/App.java index c8bbdee9..595b4680 100644 --- a/src-launcher/nicelee/memory/App.java +++ b/src-launcher/nicelee/memory/App.java @@ -41,6 +41,7 @@ public static void main(String[] args) throws FileNotFoundException, IOException System.out.println(pd.getCodeSource().getLocation().getPath()); MemoryClassLoader mcl = new MemoryClassLoader(pd); String mainClass = System.getProperty("bilibili.prop.mainClass", "nicelee.ui.FrameMain"); + System.out.println("Current main class:" + mainClass); try { Class clazz = mcl.loadClass(mainClass); Method method = clazz.getMethod("main", new Class[] { String[].class }); From cd2b3e30ba18f4f01e8db049fb2b83534ac1f60b Mon Sep 17 00:00:00 2001 From: lijia Date: Sat, 31 Aug 2024 11:05:37 +0800 Subject: [PATCH 10/15] =?UTF-8?q?ui:=20=E5=88=87=E6=8D=A2=E6=8B=96?= =?UTF-8?q?=E6=8B=BD=E4=BD=8D=E7=A7=BB=E7=9A=84=E8=AE=A1=E7=AE=97=E6=96=B9?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/nicelee/ui/item/MJTitleBar.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/nicelee/ui/item/MJTitleBar.java b/src/nicelee/ui/item/MJTitleBar.java index 6d0101c4..2cea541b 100644 --- a/src/nicelee/ui/item/MJTitleBar.java +++ b/src/nicelee/ui/item/MJTitleBar.java @@ -20,6 +20,7 @@ import nicelee.ui.item.JOptionPane; import javax.swing.JPanel; import javax.swing.SwingConstants; +import javax.swing.SwingUtilities; import nicelee.bilibili.util.Logger; import nicelee.ui.FrameMain; @@ -199,14 +200,15 @@ public void mouseClicked(MouseEvent e) { @Override public void mousePressed(MouseEvent e) { if(e.getSource() == this) { - pressedPoint = e.getPoint(); - //Logger.println(pressedPoint); + pressedPoint = SwingUtilities.convertPoint(this, e.getPoint(), frame); } } @Override public void mouseReleased(MouseEvent e) { - pressedPoint = null; + if(e.getSource() == this) { + pressedPoint = null; + } } @Override @@ -221,11 +223,11 @@ public void mouseExited(MouseEvent e) { public void mouseDragged(MouseEvent e) { //实现拖拽 if(pressedPoint != null &&e.getSource() != btnClose && e.getSource() != btnMin) { - Point locationPoint = frame.getLocation(); - Point point = e.getPoint(); - int x = locationPoint.x + point.x - pressedPoint.x; - int y = locationPoint.y + point.y - pressedPoint.y; - frame.setLocation(x, y); + int newX = e.getXOnScreen() - pressedPoint.x; + int newY = e.getYOnScreen() - pressedPoint.y; + if( newX == frame.getX() && newY == frame.getY() ) + return; + frame.setLocation(newX, newY); } } From f2010d432b369908923ab28858d4d5dac7bcbc54 Mon Sep 17 00:00:00 2001 From: lijia Date: Sat, 31 Aug 2024 11:07:38 +0800 Subject: [PATCH 11/15] =?UTF-8?q?revert(ui):=20=E6=92=A4=E9=94=80=E6=97=A0?= =?UTF-8?q?=E7=94=A8=E7=9A=84=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/nicelee/ui/item/MJTitleBar.java | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/nicelee/ui/item/MJTitleBar.java b/src/nicelee/ui/item/MJTitleBar.java index 2cea541b..054eae19 100644 --- a/src/nicelee/ui/item/MJTitleBar.java +++ b/src/nicelee/ui/item/MJTitleBar.java @@ -4,7 +4,6 @@ import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.Font; -import java.awt.Graphics; import java.awt.Image; import java.awt.Point; import java.awt.event.MouseEvent; @@ -54,14 +53,6 @@ public MJTitleBar(JFrame frame, boolean setTitle, boolean setMenuBar) { this.setMenuBar = setMenuBar; init(); } - - @Override - public void paintComponent(Graphics g) { - super.paintComponent(g); -// frame.repaint(); -// Logger.println("-------- notify other part of main frame to update ui ---------"); - Global.tabs.repaint(); - } private void init() { // frame 去掉标题栏 From 83d69822749b46f1550069afc8ddf5fe5da92d82 Mon Sep 17 00:00:00 2001 From: lijia Date: Mon, 2 Sep 2024 10:03:34 +0800 Subject: [PATCH 12/15] =?UTF-8?q?feat:=20=E5=B0=86`ffmpeg`=E5=8A=A0?= =?UTF-8?q?=E5=85=A5win64=5Fjre=E7=9A=84=E6=89=93=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/scripts/gen_zip_sha1_for_release.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/scripts/gen_zip_sha1_for_release.sh b/.github/scripts/gen_zip_sha1_for_release.sh index ae6afae6..1a6948a5 100644 --- a/.github/scripts/gen_zip_sha1_for_release.sh +++ b/.github/scripts/gen_zip_sha1_for_release.sh @@ -34,6 +34,10 @@ unzip minimal-bilibilidown-jre11.0.23_9.crypto.ec_win_x64.zip cp "BilibiliDown.v$VERSION_NUMBER.release.zip" "BilibiliDown.v$VERSION_NUMBER.win_x64_jre11.release.zip" zip -rm "BilibiliDown.v$VERSION_NUMBER.win_x64_jre11.release.zip" ./minimal-bilibilidown-jre/ +wget https://github.com/nICEnnnnnnnLee/BilibiliDown/releases/download/V4.5/ffmpeg-20240123-win-amd64.exe +mv ffmpeg-20240123-win-amd64.exe ffmpeg.exe +zip -m "BilibiliDown.v$VERSION_NUMBER.win_x64_jre11.release.zip" ./ffmpeg.exe + (sha1sum "BilibiliDown.v$VERSION_NUMBER.win_x64_jre11.release.zip"| cut -d' ' -f1) > "BilibiliDown.v$VERSION_NUMBER.win_x64_jre11.release.zip.sha1" (sha1sum "BilibiliDown.v$VERSION_NUMBER.release.zip"| cut -d' ' -f1) > "BilibiliDown.v$VERSION_NUMBER.release.zip.sha1" From 6bfcbec3f0ef754924e9dff4bbed3c95806649a5 Mon Sep 17 00:00:00 2001 From: lijia Date: Mon, 2 Sep 2024 13:58:40 +0800 Subject: [PATCH 13/15] =?UTF-8?q?refactor:=20=E9=87=8D=E6=9E=84=E5=B9=B6?= =?UTF-8?q?=E4=BC=98=E5=8C=96ffmpeg=E6=A3=80=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/nicelee/ui/FrameMain.java | 25 ++----------------------- src/nicelee/ui/FrameMain_v3_4.java | 26 ++------------------------ 2 files changed, 4 insertions(+), 47 deletions(-) diff --git a/src/nicelee/ui/FrameMain.java b/src/nicelee/ui/FrameMain.java index e5b78946..06ac36bf 100644 --- a/src/nicelee/ui/FrameMain.java +++ b/src/nicelee/ui/FrameMain.java @@ -46,7 +46,7 @@ public class FrameMain extends JFrame { public static void main(String[] args) { System.out.println(); // System.getProperties().setProperty("file.encoding", "utf-8"); - boolean isFFmpegSurported = SysUtil.surportFFmpegOfficially(); + boolean isFFmpegSupported = SysUtil.surportFFmpegOfficially(); System.out.println("Java version:" + System.getProperty("java.specification.version")); System.out.println(ResourcesUtil.baseDirectory()); // 读取配置文件 @@ -110,28 +110,7 @@ public static void main(String[] args) { loginTh.start(); // 初始化 - ffmpeg环境判断 - CmdUtil.DEFAULT_WORKING_DIR = ResourcesUtil.baseDirFile(); - String ffmpeg = ResourcesUtil.resolve(Global.ffmpegPath); - String[] cmd = new String[] { ffmpeg, "-version" }; - if (!CmdUtil.run(cmd)) { - if (isFFmpegSurported) { - Object[] options = { "是", "否" }; - int m = JOptionPane.showOptionDialog(null, - "检测到当前没有ffmpeg环境, mp4及小部分flv文件将无法转码或合并.\r\n 是否下载ffmpeg(自编译, 3M左右)?", "请选择:", - JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE, null, options, options[0]); - Logger.println(m); - if (m == 0) { - VideoInfo avInfo = new INeedAV().getVideoDetail("ffmpeg", 0, false); - DownloadRunnable downThread = new DownloadRunnable(avInfo, avInfo.getClips().get(1234L), 0); - Global.queryThreadPool.execute(downThread); - } - } else { - JOptionPane.showMessageDialog(null, "当前没有ffmpeg环境,大部分mp4及小部分flv文件将无法转码或合并", "请注意!!", - JOptionPane.WARNING_MESSAGE); - } - } else { - CmdUtil.FFMPEG_PATH = ffmpeg; - } + InitCheck.checkFFmpeg(isFFmpegSupported); // if (Global.saveToRepo) { diff --git a/src/nicelee/ui/FrameMain_v3_4.java b/src/nicelee/ui/FrameMain_v3_4.java index 2aa4dfd6..9d308a5e 100644 --- a/src/nicelee/ui/FrameMain_v3_4.java +++ b/src/nicelee/ui/FrameMain_v3_4.java @@ -41,7 +41,7 @@ public class FrameMain_v3_4 extends JFrame { public static void main(String[] args) { System.out.println(); // System.getProperties().setProperty("file.encoding", "utf-8"); - boolean isFFmpegSurported = SysUtil.surportFFmpegOfficially(); + boolean isFFmpegSupported = SysUtil.surportFFmpegOfficially(); System.out.println("Java version:" + System.getProperty("java.specification.version")); System.out.println(ResourcesUtil.baseDirectory()); // 读取配置文件 @@ -101,29 +101,7 @@ public static void main(String[] args) { loginTh.start(); // 初始化 - ffmpeg环境判断 - CmdUtil.DEFAULT_WORKING_DIR = ResourcesUtil.baseDirFile(); - String ffmpeg = ResourcesUtil.resolve(Global.ffmpegPath); - String[] cmd = new String[] { ffmpeg, "-version" }; - if (!CmdUtil.run(cmd)) { - if (isFFmpegSurported) { - Object[] options = { "是", "否" }; - int m = JOptionPane.showOptionDialog(null, - "检测到当前没有ffmpeg环境, mp4及小部分flv文件将无法转码或合并.\r\n 是否下载ffmpeg(自编译, 3M左右)?", "请选择:", - JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE, null, options, options[0]); - Logger.println(m); - if (m == 0) { - VideoInfo avInfo = new INeedAV().getVideoDetail("ffmpeg", 0, false); - DownloadRunnable downThread = new DownloadRunnable(avInfo, avInfo.getClips().get(1234L), 0); - Global.queryThreadPool.execute(downThread); - } - } else { - JOptionPane.showMessageDialog(null, "当前没有ffmpeg环境,大部分mp4及小部分flv文件将无法转码或合并", "请注意!!", - JOptionPane.WARNING_MESSAGE); - } - } else { - CmdUtil.FFMPEG_PATH = ffmpeg; - } - + InitCheck.checkFFmpeg(isFFmpegSupported); // if (Global.saveToRepo) { RepoUtil.init(false); From 2ab80e703873fef9979b1b00e5cbba17f3a23c3e Mon Sep 17 00:00:00 2001 From: lijia Date: Mon, 2 Sep 2024 14:25:20 +0800 Subject: [PATCH 14/15] =?UTF-8?q?feat:=20=E6=A3=80=E6=9F=A5=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F=E5=AF=B9=E6=95=B0=E6=8D=AE=E7=9B=AE=E5=BD=95=E7=9A=84?= =?UTF-8?q?`=E5=86=99`=E7=9A=84=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/nicelee/ui/FrameMain.java | 7 +-- src/nicelee/ui/FrameMain_v3_4.java | 7 +-- src/nicelee/ui/InitCheck.java | 78 ++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+), 10 deletions(-) create mode 100644 src/nicelee/ui/InitCheck.java diff --git a/src/nicelee/ui/FrameMain.java b/src/nicelee/ui/FrameMain.java index 06ac36bf..ff44afdd 100644 --- a/src/nicelee/ui/FrameMain.java +++ b/src/nicelee/ui/FrameMain.java @@ -16,21 +16,17 @@ import javax.swing.JTabbedPane; import javax.swing.UIManager; -import nicelee.bilibili.INeedAV; import nicelee.bilibili.INeedLogin; import nicelee.bilibili.PackageScanLoader; -import nicelee.bilibili.model.VideoInfo; import nicelee.bilibili.util.CmdUtil; import nicelee.bilibili.util.ConfigUtil; import nicelee.bilibili.util.HttpCookies; -import nicelee.bilibili.util.Logger; import nicelee.bilibili.util.RepoUtil; import nicelee.bilibili.util.ResourcesUtil; import nicelee.bilibili.util.SysUtil; import nicelee.ui.item.MJTitleBar; import nicelee.ui.thread.BatchDownloadRbyRThread; import nicelee.ui.thread.CookieRefreshThread; -import nicelee.ui.thread.DownloadRunnable; import nicelee.ui.thread.LoginThread; import nicelee.ui.thread.MonitoringThread; @@ -56,6 +52,8 @@ public static void main(String[] args) { System.out.println(Global.version); System.exit(0); } + // 初始化 - 检查对数据文件夹是否有“写”的权限 + InitCheck.checkFileAccess(); // 显示过渡动画 Global.frWaiting = new FrameWaiting(); Global.frWaiting.start(); @@ -79,7 +77,6 @@ public static void main(String[] args) { // } // 初始化主题 initUITheme(); - // 初始化UI FrameMain main = new FrameMain(); main.InitUI(); diff --git a/src/nicelee/ui/FrameMain_v3_4.java b/src/nicelee/ui/FrameMain_v3_4.java index 9d308a5e..2d3c6222 100644 --- a/src/nicelee/ui/FrameMain_v3_4.java +++ b/src/nicelee/ui/FrameMain_v3_4.java @@ -11,14 +11,11 @@ import javax.swing.JTabbedPane; import javax.swing.UIManager; -import nicelee.bilibili.INeedAV; import nicelee.bilibili.INeedLogin; import nicelee.bilibili.PackageScanLoader; -import nicelee.bilibili.model.VideoInfo; import nicelee.bilibili.util.CmdUtil; import nicelee.bilibili.util.ConfigUtil; import nicelee.bilibili.util.HttpCookies; -import nicelee.bilibili.util.Logger; import nicelee.bilibili.util.RepoUtil; import nicelee.bilibili.util.ResourcesUtil; import nicelee.bilibili.util.SysUtil; @@ -26,7 +23,6 @@ import nicelee.ui.item.MJMenuBar; import nicelee.ui.thread.BatchDownloadRbyRThread; import nicelee.ui.thread.CookieRefreshThread; -import nicelee.ui.thread.DownloadRunnable; import nicelee.ui.thread.LoginThread; import nicelee.ui.thread.MonitoringThread; @@ -51,6 +47,8 @@ public static void main(String[] args) { System.out.println(Global.version); System.exit(0); } + // 初始化 - 检查对数据文件夹是否有“写”的权限 + InitCheck.checkFileAccess(); // 显示过渡动画 Global.frWaiting = new FrameWaiting(); Global.frWaiting.start(); @@ -70,7 +68,6 @@ public static void main(String[] args) { nicelee.bilibili.util.custom.System.init(Global.syncServerTime); // 初始化主题 initUITheme(); - // 初始化UI FrameMain_v3_4 main = new FrameMain_v3_4(); main.InitUI(); diff --git a/src/nicelee/ui/InitCheck.java b/src/nicelee/ui/InitCheck.java new file mode 100644 index 00000000..b8e55f9b --- /dev/null +++ b/src/nicelee/ui/InitCheck.java @@ -0,0 +1,78 @@ +package nicelee.ui; + +import java.io.File; +import java.nio.file.Files; + +import nicelee.bilibili.INeedAV; +import nicelee.bilibili.model.VideoInfo; +import nicelee.bilibili.util.CmdUtil; +import nicelee.bilibili.util.Logger; +import nicelee.bilibili.util.ResourcesUtil; +import nicelee.ui.item.JOptionPane; +import nicelee.ui.thread.DownloadRunnable; + +/** + * 初始化检查要放在配置文件读取之后 + * + */ +public class InitCheck { + + public static void main(String[] args) { + checkFileAccess(); + Global.ffmpegPath = "ffmpeg"; + checkFFmpeg(true); + } + + public static void checkFileAccess() { + File f = ResourcesUtil.baseDirFile(); + if (!Files.isWritable(f.toPath())) { + String tips = "检测到程序对于数据目录没有“写”权限,可能无法正常工作。\n" + + "建议设置JVM参数 -Dbilibili.prop.dataDirPath={dataDirPath} 指定有读写权限的数据目录位置。\n当前数据目录为: " + + f.getAbsolutePath(); + JOptionPane.showMessageDialog(null, tips); + } + } + + public static void checkFFmpeg(boolean isFFmpegSupported) { + CmdUtil.DEFAULT_WORKING_DIR = ResourcesUtil.baseDirFile(); + if (!checkFFmpegConf() && !checkFFmpegSys()) { + if (isFFmpegSupported) { + Object[] options = { "是", "否" }; + int m = JOptionPane.showOptionDialog(null, + "检测到当前没有ffmpeg环境, mp4及小部分flv文件将无法转码或合并.\r\n 是否下载ffmpeg(自编译, 3M左右)?", "请选择:", + JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE, null, options, options[0]); + Logger.println(m); + if (m == 0) { + VideoInfo avInfo = new INeedAV().getVideoDetail("ffmpeg", 0, false); + DownloadRunnable downThread = new DownloadRunnable(avInfo, avInfo.getClips().get(1234L), 0); + Global.queryThreadPool.execute(downThread); + return; + } + } + + JOptionPane.showMessageDialog(null, "当前没有ffmpeg环境,请自行下载ffmpeg,并正确配置 bilibili.ffmpegPath ", "请注意!!", + JOptionPane.WARNING_MESSAGE); + } + } + + private static boolean checkFFmpegSys() { + String ffmpeg = "ffmpeg"; + String[] cmd = new String[] { ffmpeg, "-version" }; + if (CmdUtil.run(cmd)) { + CmdUtil.FFMPEG_PATH = ffmpeg; + return true; + } + return false; + } + + private static boolean checkFFmpegConf() { + String ffmpeg = ResourcesUtil.resolve(Global.ffmpegPath); + String[] cmd = new String[] { ffmpeg, "-version" }; + if (CmdUtil.run(cmd)) { + CmdUtil.FFMPEG_PATH = ffmpeg; + return true; + } + return false; + } + +} From 5b64e62e5617aca1cb246347204fb9ab89373fa3 Mon Sep 17 00:00:00 2001 From: lijia Date: Tue, 3 Sep 2024 20:27:34 +0800 Subject: [PATCH 15/15] V6.34 Update --- .github/release.info | 53 ++++++++++++++++++++++++++++---------- UPDATE.md | 46 ++++++++++++++++++++++++++++++++- src/nicelee/ui/Global.java | 2 +- 3 files changed, 86 insertions(+), 15 deletions(-) diff --git a/.github/release.info b/.github/release.info index 89756e3a..af5e95f5 100644 --- a/.github/release.info +++ b/.github/release.info @@ -1,16 +1,43 @@ -* 新增: release 附件中`win64_jre`压缩文件加入`exe`程序 -* 新增: 添加专栏图片解析 -* 新增: 添加专栏文集图片解析 -* 新增: 添加图文动态解析 -* 新增: 添加图文动态个人收藏解析 -* 新增: 可以JVM传入参数`-Dbilibili.prop.dataDirPath={dataDirPath}`来指定数据文件夹位置(可以不是程序所在目录) -* 新增: 可以JVM传入参数`-Dbilibili.prop.log=true/false`来尽可能减少打印信息 -* 新增: 可以在登录时获取服务器时间并以之为基准 -* 新增(ui): 配置面板中,针对文件/文件夹类型的配置,可以通过文件选择器来选择路径 -* 新增(ci): 现在可以手动触发release ci,此时可以选择是否同步上传代码、附件到第三方 -* 新增(ci): 现在会将`commit hash`,`workflow id`信息写入作品信息页面,`buildTime`改为`GMT+8`时区 -* 已知问题: jpackage 打包的exe程序无法自重启 [JDK-8325924](https://bugs.openjdk.org/browse/JDK-8325924)/[JDK-8325203](https://bugs.openjdk.org/browse/JDK-8325203) -* 具体修改详见[V6.32...V6.33](https://github.com/nICEnnnnnnnLee/BilibiliDown/compare/V6.31...V6.32) +该版本主要用来解决某些使用上的问题,如果您已经可以正常使用,可以忽略该更新。 +* 精简jre支持的https加密套件有限,不支持ecc。这会导致默认的ffmpeg源bitbucket下载失败。随着网站加密套件的更新,未来或许还会有更多的`TLS handshake failure`。 +这个问题在旧版本可以通过更换ffmpeg源,或者自行获取ffmpeg并在程序设置好path的方式来解决。 +新版本为精简JRE添加了模块`jdk.crypto.ec`,用于解决部分HTTPS链接握手出错的问题。 +需要注意的是,这个模块在JDK 22被标为deprecated,相关实现会被挪到`java.base`模块。详见[JDK-8312267](https://bugs.openjdk.org/browse/JDK-8312267) +另外,新版本为Windows x64用户打包的`zip`、`msi`添加了精简编译的`ffmpeg.exe`。 + +* 在转码/合并失败时,现在会提示检查ffmpeg配置。 +现在Web端基本上获取不到高清晰度的mp4、flv。随着时间推移,ffmpeg成了必选项,以前的逻辑、设计和提示语都有点过时。 +尝试让用户明白三件事情: + + ffmpeg是必需的。 + + 程序可以提供仅基础功能的精简版编译下载。 + + 如果计算机里有现成的ffmpeg,可以通过配置进行指定。 + +* 修复程序自更新时下载Beta版本报错的问题。 + 下载Github Action的artifact链接301到新链接后,继承使用原来的header会报错,这个行为有点抽象。 + +* 现在程序会检查数据目录的`写`权限。#214 + 不推荐将程序放在系统盘。如果你这么做了,你需要进行额外的操作(三选一): + + 以管理员身份运行程序(不推荐) + + 参考#214 将程序目录设置为可写可修改 + + 设置另外的有权限的数据目录,通过传入JVM参数`-Dbilibili.prop.dataDirPath`进行指定。不会可以在参考文档中搜索关键词。 + +* 部分环境可能出现显示错误的情况。#213 +问题存在,但找不到原因。可以通过更换入口类规避。 +现在可以通过传入JVM参数`-Dbilibili.prop.mainClass`参数给`launch.jar`,来指定`INeedBiliAV.jar`的运行入口。 + + 修改`BilibiliDown.cfg` + ``` + [Application] + app.classpath=launch.jar + app.mainclass=nicelee.memory.App + + [JavaOptions] + java-options=-Dfile.encoding=utf-8 + java-options=-Dbilibili.prop.mainClass=nicelee.ui.FrameMain_v3_4 + ``` + + 或者脚本 + `java -Dbilibili.prop.mainClass=nicelee.ui.FrameMain_v3_4 -jar launch.jar`
如果你是Win64用户,且没有java环境,请下载附件`*.win_x64_jre11.release.zip`或 `*.win_x64.msi` \ No newline at end of file diff --git a/UPDATE.md b/UPDATE.md index 2044f4c0..ef77f760 100644 --- a/UPDATE.md +++ b/UPDATE.md @@ -1,6 +1,50 @@ ## UPDATE +* V6.34 + 该版本主要用来解决某些使用上的问题,如果您已经可以正常使用,可以忽略该更新。 + * 精简jre支持的https加密套件有限,不支持ecc。这会导致默认的ffmpeg源bitbucket下载失败。随着网站加密套件的更新,未来或许还会有更多的`TLS handshake failure`。 + 这个问题在旧版本可以通过更换ffmpeg源,或者自行获取ffmpeg并在程序设置好path的方式来解决。 + 新版本为精简JRE添加了模块`jdk.crypto.ec`,用于解决部分HTTPS链接握手出错的问题。 + 需要注意的是,这个模块在JDK 22被标为deprecated,相关实现会被挪到`java.base`模块。详见[JDK-8312267](https://bugs.openjdk.org/browse/JDK-8312267) + 另外,新版本为Windows x64用户打包的`zip`、`msi`添加了精简编译的`ffmpeg.exe`。 + + * 在转码/合并失败时,现在会提示检查ffmpeg配置。 + 现在Web端基本上获取不到高清晰度的mp4、flv。随着时间推移,ffmpeg成了必选项,以前的逻辑、设计和提示语都有点过时。 + 尝试让用户明白三件事情: + + ffmpeg是必需的。 + + 程序可以提供仅基础功能的精简版编译下载。 + + 如果计算机里有现成的ffmpeg,可以通过配置进行指定。 + + * 修复程序自更新时下载Beta版本报错的问题。 + 下载Github Action的artifact需要登录,虽然不甘心,但可以理解。 + 下载链接301到新链接后,继承使用原来的header会报错,这个行为有点抽象。 + 大部分工具都是follow redirect可以直接下载的,但这里的逻辑是那小部分。 + + * 现在程序会检查数据目录的`写`权限。#214 + 不推荐将程序放在系统盘。如果你这么做了,你需要进行额外的操作(三选一): + + 以管理员身份运行程序(不推荐) + + 参考#214 将程序目录设置为可写可修改 + + 设置另外的有权限的数据目录,通过传入JVM参数`-Dbilibili.prop.dataDirPath`进行指定。不会可以在参考文档中搜索关键词。 + + * 部分环境可能出现显示错误的情况。#213 + 问题存在,但找不到原因。可以通过更换入口类规避。 + 现在可以通过传入JVM参数`-Dbilibili.prop.mainClass`参数给`launch.jar`,来指定`INeedBiliAV.jar`的运行入口。 + + 修改`BilibiliDown.cfg` + ``` + [Application] + app.classpath=launch.jar + app.mainclass=nicelee.memory.App + + [JavaOptions] + java-options=-Dfile.encoding=utf-8 + java-options=-Dbilibili.prop.mainClass=nicelee.ui.FrameMain_v3_4 + ``` + + 或者脚本 + `java -Dbilibili.prop.mainClass=nicelee.ui.FrameMain_v3_4 -jar launch.jar` + * V6.33 `2024-08-18` - * 新增: release中`win64_jre`压缩文件加入`exe`程序 + * 新增: release 附件中`win64_jre`压缩文件加入`exe`程序 * 新增: 添加专栏图片解析 * 新增: 添加专栏文集图片解析 * 新增: 添加图文动态解析 diff --git a/src/nicelee/ui/Global.java b/src/nicelee/ui/Global.java index 7f15afbf..c02c19f7 100644 --- a/src/nicelee/ui/Global.java +++ b/src/nicelee/ui/Global.java @@ -25,7 +25,7 @@ public class Global { // 界面显示相关 - @Config(key = "bilibili.version", defaultValue = "v6.33", warning = false) + @Config(key = "bilibili.version", defaultValue = "v6.34", warning = false) public static String version; // 一般情况下,我们不会设置这个标签,这个用于测试 @Config(key = "bilibili.time.syncServer", note = "同步服务器的时间", defaultValue = "false", valids = { "true", "false" }) public static boolean syncServerTime;