|
@@ -14,10 +14,7 @@ import org.apache.http.message.BasicHeader;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.io.*;
|
|
|
-import java.net.Authenticator;
|
|
|
-import java.net.HttpURLConnection;
|
|
|
-import java.net.PasswordAuthentication;
|
|
|
-import java.net.URL;
|
|
|
+import java.net.*;
|
|
|
import java.nio.file.Files;
|
|
|
import java.util.Objects;
|
|
|
import java.util.UUID;
|
|
@@ -83,13 +80,8 @@ public class VideoDownloader {
|
|
|
if (file.exists()) {
|
|
|
file.delete();
|
|
|
}
|
|
|
- // 设置代理
|
|
|
- System.setProperty("http.proxyHost", PROXY_HOST);
|
|
|
- System.setProperty("http.proxyPort", String.valueOf(PROXY_PORT));
|
|
|
- System.setProperty("http.proxyUser", USERNAME);
|
|
|
- System.setProperty("http.proxyPassword", PASSWORD);
|
|
|
-
|
|
|
- HttpURLConnection connection = (HttpURLConnection) new URL(videoUrl).openConnection();
|
|
|
+ Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(PROXY_HOST, PROXY_PORT));
|
|
|
+ HttpURLConnection connection = (HttpURLConnection) new URL(videoUrl).openConnection(proxy);
|
|
|
connection.setRequestMethod("GET");
|
|
|
connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0");
|
|
|
connection.setRequestProperty("Accept", "*/*");
|