In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "Java how to achieve Douyin to watermark", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "Java how to achieve Douyin to watermark it!"
I. Preface
Douyin to watermark method is very simple, has not been studied before, thought that to make a watermark also need to use the algorithm to remove, until the hands-on time found that it is so simple, without programming basis can be done.
II. Principles and steps
In fact, Douyin has a hidden unwatermarked address, as long as we find that address.
1. We are looking for a video link on Douyin where we want to remove the watermark.
Note: this must start with https, not a password
Open a browser to access:
After the visit, he will be redirected to this address, followed by a string of numbers. This is the id of the video. He found the video playback based on this unique id.
Press F12 to view the web request and find the address of the request you just copied. There is a location link in the response header to access the location link.
Https://www.iesdouyin.com/share/video/7064781119429807363/
There are many requests in F12, and one of the many requests is:
If you don't find too many requests, you can just skip it. Just look at https://aweme.snssdk.com. Replace id.
Https://www.iesdouyin.com/web/api/v2/aweme/iteminfo/?item_ids=7064781119429807363
Access the request again with a browser, and then return a large list of json data. You can find this link by flipping through it all the time.
Https://aweme.snssdk.com/aweme/v1/playwm/?video_id=v0200fg10000c85i9ejc77ue0kb2vo80&ratio=720p&line=0
Directly use that link to visit, he is actually a watermarked link, careful observation found that there is a paragraph / playwm, there are two letters wm is actually the abbreviation of watermark English words, after removing wm, you can get an unwatermarked link
Https://aweme.snssdk.com/aweme/v1/play/?video_id=v0200fg10000c85i9ejc77ue0kb2vo80&ratio=720p&line=0
Here, no watermark has been completed.
Third, code implementation
Here I use Java to implement, which has nothing to do with the language, as long as it can make a request.
/ * download Douyin waterless video * * @ throws IOException * / @ GetMapping (value = "/ downloadDy") public void downloadDy (String dyUrl, HttpServletResponse response) throws IOException {ResultDto resultDto = new ResultDto (); try {dyUrl= URLDecoder.decode (dyUrl) .replace ("dyUrl=", ""); resultDto = dyParseUrl (dyUrl);} catch (Exception e) {e.printStackTrace () } if (resultDto.getVideoUrl (). Contains ("http://")) {resultDto.setVideoUrl (resultDto.getVideoUrl (). Replace (" http://", "https://"));} String videoUrl = resultDto.getVideoUrl (); response.sendRedirect (videoUrl);} public ResultDto dyParseUrl (String redirectUrl) throws Exception {redirectUrl = CommonUtils.getLocation (redirectUrl); ResultDto dyDto = new ResultDto () If (! StringUtils.isEmpty (redirectUrl)) {/ * 1. Use ItemId to get video details, including unwatermarked video url * / String itemId = CommonUtils.matchNo (redirectUrl); StringBuilder sb = new StringBuilder (); sb.append (CommonUtils.DOU_YIN_BASE_URL) .append (itemId) String videoResult = CommonUtils.httpGet (sb.toString ()); DYResult dyResult = JSON.parseObject (videoResult, DYResult.class) / * 2. Unwatermarked video url * / String videoUrl = dyResult.getItem_list (). Get (0) .getVideo () .getPlay_addr () .getUrl_list () .get (0) .replace ("playwm", "play"); String videoRedirectUrl = CommonUtils.getLocation (videoUrl) DyDto.setVideoUrl (videoRedirectUrl); / * 3, audio url * / String musicUrl = dyResult.getItem_list (). Get (0). GetMusic (). GetPlay_url (). GetUri (); dyDto.setMusicUrl (musicUrl) / * 4, cover * / String videoPic = dyResult.getItem_list (). Get (0). GetVideo (). GetDynamic_cover (). GetUrl_list (). Get (0); dyDto.setVideoPic (videoPic) / * 5, Video copy * / String desc = dyResult.getItem_list (). Get (0). GetDesc (); dyDto.setDesc (desc);} return dyDto;}
ResultDto.java
Public class ResultDto {private String videoUrl; / / Video private String musicUrl; / / background Music private String videoPic; / / Silent Video private String desc; public String getDesc () {return desc;} public void setDesc (String desc) {this.desc = desc;} public String getVideoUrl () {return videoUrl } public void setVideoUrl (String videoUrl) {this.videoUrl = videoUrl;} public String getMusicUrl () {return musicUrl;} public void setMusicUrl (String musicUrl) {this.musicUrl = musicUrl;} public String getVideoPic () {return videoPic;} public void setVideoPic (String videoPic) {this.videoPic = videoPic;}}
CommonUtils .java
Public class CommonUtils {public static String DOU_YIN_BASE_URL = "https://www.iesdouyin.com/web/api/v2/aweme/iteminfo/?item_ids="; public static String HUO_SHAN_BASE_URL =" https://share.huoshan.com/api/item/info?item_id="; public static String DOU_YIN_DOMAIN = "douyin"; public static String HUO_SHAN_DOMAIN = "huoshan" Public static String getLocation (String url) {try {URL serverUrl = new URL (url); HttpURLConnection conn = (HttpURLConnection) serverUrl.openConnection (); conn.setRequestMethod ("GET"); conn.setInstanceFollowRedirects (false); conn.setRequestProperty ("User-agent", "ua"); / / Analog phone connected to conn.connect () String location = conn.getHeaderField ("Location"); return location;} catch (Exception e) {e.printStackTrace ();} return "";} public static String matchNo (String redirectUrl) {List results = new ArrayList (); Pattern p = Pattern.compile ("video/ ([\\ w /\.] *) /")) Matcher m = p.matcher (redirectUrl); while (! m.hitEnd () & & m.find ()) {results.add (m.group (1));} return results.get (0);} public static String hSMatchNo (String redirectUrl) {List results = new ArrayList (); Pattern p = Pattern.compile ("item_id= ([\\ w /\] *) &") Matcher m = p.matcher (redirectUrl); while (! m.hitEnd () & & m.find ()) {results.add (m.group (1));} return results.get (0);} public static String httpGet2 (String urlStr) throws Exception {URL url = new URL (urlStr); HttpURLConnection conn = (HttpURLConnection) url.openConnection (); conn.setRequestMethod ("GET") Conn.setRequestProperty ("Content-Type", "text/json;charset=utf-8"); BufferedReader in = new BufferedReader (new InputStreamReader (conn.getInputStream (), "UTF-8")); StringBuffer buf = new StringBuffer (); String inputLine = in.readLine (); while (inputLine! = null) {buf.append (inputLine) .append ("\ r\ n"); inputLine = in.readLine () } in.close (); return buf.toString ();} / * use Get to obtain data * * @ param url URL includes parameters, http://HOST/XX?XX=XX&XXX=XXX * @ return * / public static String httpGet (String url) {String result = ""; BufferedReader in = null Try {URL realUrl = new URL (url); / / Open the connection to URL URLConnection connection = realUrl.openConnection (); / / set the generic request properties connection.setRequestProperty ("accept", "* / *"); connection.setRequestProperty ("connection", "Keep-Alive") Connection.setRequestProperty ("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1 SV 1)"); / / establish the actual connection connection.connect () / / define the BufferedReader input stream to read the URL response in = new BufferedReader (new InputStreamReader (connection.getInputStream (), "UTF-8"); String line; while ((line = in.readLine ())! = null) {result + = line }} catch (Exception e) {System.out.println ("an exception occurred sending a GET request!" + e); e.printStackTrace ();} / / use the finally block to close the input stream finally {try {if (in! = null) {in.close ();}} catch (Exception e2) {e2.printStackTrace () } return result;} public static String parseUrl (String url) {String host = "; Pattern p = Pattern.compile (" http [: / |\\ w |\\.] + "); Matcher matcher = p.matcher (url); if (matcher.find ()) {host = matcher.group ();} return host.trim () } / * find the domain name (ending with https) * * @ param url * @ return * / public static String getDomainName (String url) {String host = ""; Pattern p = Pattern.compile ("https://.*\\.com"); Matcher matcher = p.matcher (url)) If (matcher.find ()) {host = matcher.group ();} return host.trim ();}} at this point, I believe you have a deeper understanding of "how to achieve Douyin watermarking by Java". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.