2023java攻克了抖音视频去水印视频下载
1、过滤链接
/**
* 过滤链接,获取http连接地址
* @param url
* @return
*/
public static String decodeHttpUrl(String url) {
int start = url.indexOf("http");
int end = url.lastIndexOf("/");
String decodeurl = url.substring(start, end);
return decodeurl;
}
2、获取视频链接
Connection con = Jsoup.connect(url);
con.header("User-Agent", "Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1");
Connection.Response resp = con.method(Connection.Method.GET).execute();
String strUrl = resp.url().toString();
String videoId = strUrl.substring(strUrl.indexOf("video/"), strUrl.lastIndexOf("/")).replace("video/", "");
String b = "https://m.douyin.com/share/video/"+videoId;
String finalVideoAddress = getVideoStreamUrl2(b);
3、下载视频链接
/**
* 下载
* @param videoAddress
* @param desc
*/
private static String downloadVideo(String videoAddress,String desc) {
try {
videoAddress = "https:"+videoAddress;
System.out.println(videoAddress);
String file2 = "C:\\data\\douyin";
String ids= UUID.randomUUID().toString().replace("-", "");
String file1=file2+"\\"+ids+"";
File file = new File(file1+".mp4");
file.createNewFile();
BaseAdapter adapter = new SpliderAdapter();
Map<String, String> maps = new HashMap<>();
System.out.println("\n-----视频保存路径-----\n" + file1+".mp4");
return adapter.getVideo(file1, videoAddress, maps, "mp4");
} catch (IOException e) {
}
return "";
}