获取火山无水印视频方法

本文介绍了如何去除火山短视频的水印,通过获取视频分享链接,解析链接中的item_id,然后利用特定接口替换链接,从而获取无水印视频。提供了相关代码示例,包括处理重定向链接和封装的GET请求方法。

抖音短视频去水印咱们聊过了,今天来看看它兄弟火山短视频怎么去水印,也就是抖音火山版。

👉老规矩先通过分享获取视频分享短链接。

https://share.huoshan.com/hotsoon/s/Q5J3WUgvMk8/

👉然后将链接复制到浏览器打开,啪,出来了,很快哈,而且特别清晰明了,让人很快就能找到自己想要的数据,而且从参数名就可以看出来cover代表的是封面,url代表的是视频链接。
在这里插入图片描述

👉现在我们要做的就是把视频链接复制到浏览器打开看看,如果直接是无水印的就更好,不过我觉得不可能。😜😜
在这里插入图片描述

👉很好,果然是带水印的,现在要做的就是把带水印的链接变成无水印的。

巴啦啦小魔仙变( ̄︶ ̄)↗

👉带水印链接:

https://api.huoshan.com/hotsoon/item/video/_reflow/?video_id=v0d00fg10000c3ptnijc77udb72m3230&line=0&app_id=0&vquality=normal&watermark=2&long_video=0&sf=5&ts=1628838766&item_id=6986180881278962975

👉无水印链接:

https://api.huoshan.com/hotsoon/item/video/_playback/?video_id=v0d00fg10000c3ptnijc77udb72m3230

👉将链接复制到浏览器打开就是没有水印的视频。

在这里插入图片描述

👉神奇吧,神奇就对了。本期只做思路分析和源码分享所以对复杂的技术就不分析了。

👉处理重定向链接代码:

    public static String hSMatchNo(String redirectUrl) {
        List<String> 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);
    }

👉封装的get请求代码:

    /**
     * 请求并获取返回值
     *
     * @param urlStr
     * @return
     * @throws Exception
     */
    public static String httpGet(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();
    }

👉全部代码:

package com.smile.utils;


import com.alibaba.fastjson.JSON;
import com.smile.wechat.domain.VideoInfo;
import com.smile.wechat.dto.HSResultDto;
import com.smile.common.exception.CustomException;
import com.smile.common.utils.StringUtils;

/**
 * 火山小视频去水印
 */
public class HuoShan {

    public static VideoInfo getVideo(String url) {
        String redirectUrl = HttpUtils.getLocation(url);
        if (!redirectUrl.contains("http")) {
            throw new CustomException("请复制正确的链接!");
        }
        try {
            if (!StringUtils.isEmpty(redirectUrl)) {
                VideoInfo videoInfo = new VideoInfo();
                /**
                 * 1、拿到itemId
                 */
                String itemId = HttpUtils.hSMatchNo(redirectUrl);

                StringBuilder sb = new StringBuilder();
                sb.append(HttpUtils.HUO_SHAN_BASE_URL).append(itemId);

                /**
                 * 2、itemId 拼接视频详情接口
                 */
                String videoResult = HttpUtils.httpGet(sb.toString());

                HSResultDto hsResult = JSON.parseObject(videoResult, HSResultDto.class);

                videoInfo.setVideoPic(hsResult.getData().getItem_info().getCover());

                /**
                 * 3、替换URL地址
                 */
                String replace = hsResult.getData().getItem_info().getUrl().replace("_reflow", "_playback");

                videoInfo.setVideoUrl(replace.substring(0, replace.indexOf("&")));

                videoInfo.setVideoDescribe("火山小视频");
                videoInfo.setAuthor("火山小视频");
                return videoInfo;
            } else {
                throw new CustomException("解析失败!");
            }
        } catch (Exception e) {
            throw new CustomException("请复制正确的链接!");
        }
    }
}

👉结果展示:
在这里插入图片描述
大家关注下我公众号呗,里面分享这种源码更多,csdn一个劲被举报,简单的没事,只要获取难度大点的就被举报,也不知道为啥。
在这里插入图片描述

👉作者的话:
​ 谢谢能耐心看完的童鞋,如果这篇文章能对你有帮忙更好。代码仅供学习与参考,切勿用于商业用途。

给定引用中未提及获取 endpoint 火山方法。不过在引用中涉及火山引擎相关 API 使用时提到了 model endpoint ID,例如在火山引擎 DeepSeek R1 API 使用中,model = "deepseek - r1 - 250120" 这里的 "deepseek - r1 - 250120" 可看作一种模型端点标识;在火山引擎火山方舟平台微调 SFT 调用推理时,model = "ep - xxx" 这里的 "ep - xxx" 也是模型端点标识。但没有获取这些 endpoint 的具体方式。 通常获取火山引擎相关的 endpoint 可能需要在火山引擎的控制台,针对具体服务创建相应的资源或实例,创建完成后可能会在相关服务的管理界面获取到对应的 endpoint 信息。也可以参考火山引擎的官方文档、开发者社区等渠道获取详细的获取方法。 ```python # 以下是引用中使用 endpoint 的示例代码 # DeepSeek R1 API 使用示例 import os from openai import OpenAI client = OpenAI( api_key = "*******************", base_url = "https://ark.cn-beijing.volces.com/api/v3", ) # Non - streaming print("----- standard request -----") completion = client.chat.completions.create( model = "deepseek-r1-250120", # 这里的 deepseek-r1-250120 可看作 endpoint messages = [ {"role": "system", "content": "你是人工智能助手"}, {"role": "user", "content": "常见的十字花科植物有哪些?"}, ], ) print(completion.choices[0].message.content) # 火山方舟平台微调 SFT 调用推理示例 import os from openai import OpenAI os.environ["OPENAI_API_KEY"] = "YOUR_API_KEY" os.environ["OPENAI_API_BASE"] = "YOUR_API_BASE" client = OpenAI( api_key = os.environ.get("OPENAI_API_KEY"), base_url = os.environ.get("OPENAI_API_BASE"), ) system_prompt = ( "You are a medical expert with advanced knowledge in clinical reasoning, diagnostics, and " "treatment planning. Please answer the following medical question. Before answering, " "think carefully about the question and create a step - by - step chain of thoughts to ensure a logical and accurate response." ) question = "有一个病人咳嗽两三个月了,并且流鼻涕,这两天才查出来全鸡蛋过敏,现在应该怎么办" completion = client.chat.completions.create( model = "ep-xxx", # 这里的 ep-xxx 可看作 endpoint messages = [ {"role": "system", "content": system_prompt}, {"role": "user", "content": question}, ], ) print(completion.choices[0].message.content) ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值