You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Python下载Odysee未公开视频遇“edge credentials missing”问题求助

Odysee未公开视频下载问题

我用以下Python代码获取Odysee平台**未公开(unlisted)**视频的contentUrl:

import requests, ast

def getVideoMetadata(url,timeout=7):
    return ast.literal_eval(requests.get(url,timeout=timeout).text.split('<script type="application/ld+json">')[1].split("</script>")[0])

stream = getVideoMetadata(link) #link contains the shareable link of the video
print(stream['contentUrl'])

但把获取到的contentUrl粘贴到浏览器时,页面显示错误:

edge credentials missing

错误截图:
edge credentials missing错误截图

请问已有视频分享链接的情况下,有没有可行方案下载该未公开视频?


可行解决方案

方法1:复用会话携带凭证访问视频流

Odysee未公开视频的流地址需要验证访问凭证,这些凭证会在你打开原视频页面时存入Cookie。可以修改代码,用同一个会话先访问原页面,再请求视频流,自动携带所需Cookie:

import requests, ast

def getVideoMetadata(url, timeout=7):
    session = requests.Session()
    # 先访问原视频页面,获取会话Cookie
    response = session.get(url, timeout=timeout)
    # 提取视频元数据
    data = ast.literal_eval(response.text.split('<script type="application/ld+json">')[1].split("</script>")[0])
    return session, data['contentUrl']

# 使用示例
session, content_url = getVideoMetadata(link)
# 用同一个会话请求视频流并保存
with open('unlisted_video.mp4', 'wb') as f:
    for chunk in session.get(content_url, stream=True).iter_content(chunk_size=1024*1024):
        if chunk:
            f.write(chunk)

方法2:调用官方API获取有效流地址

从视频分享链接中提取claimId,调用Odysee官方API获取带签名的有效流地址:

import requests

def get_unlisted_video_stream(share_link):
    # 从分享链接中提取claimId(示例链接格式:https://odysee.com/@username:abc/title:def?r=XYZ)
    claim_id = share_link.split('/')[-1].split('?')[0].split(':')[-1]
    # 提取referral token(如果链接带r参数)
    referral_token = share_link.split('r=')[-1] if 'r=' in share_link else ''
    
    api_url = f"https://api.odysee.com/file/view?auth_token={referral_token}&claim_id={claim_id}"
    response = requests.get(api_url).json()
    
    if response.get('success'):
        return response['streaming_url']
    return None

# 使用示例
stream_url = get_unlisted_video_stream(link)
if stream_url:
    with open('video.mp4', 'wb') as f:
        for chunk in requests.get(stream_url, stream=True).iter_content(chunk_size=1024*1024):
            f.write(chunk)

方法3:浏览器开发者工具直接提取有效地址

  1. 用浏览器打开未公开视频的分享链接,确保视频能正常播放
  2. 按下F12打开开发者工具,切换到「网络」标签
  3. 过滤「媒体」类型,找到视频流的请求记录
  4. 复制该请求的完整URL,直接用该地址下载即可(已包含必要凭证参数)

内容的提问来源于stack exchange,提问作者George

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.17 13:15:58