mirror of
https://github.com/imputnet/cobalt.git
synced 2026-07-10 16:16:29 -05:00
add support for [service name] #343
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @wanquanY on GitHub (Jul 9, 2024).
service name & description
headers = {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
link samples for the service you'd like cobalt to support
'https://www.youtube.com/watch?v=suO6X5U4rmQ',
‘https://www.bilibili.com/video/BV1zx4y1x7SD/?spm_id_from=333.1007.tianma.1-1-1.click&vd_source=73c4aca839bb90148d5538d4abc316d3’
additional context
import requests
设置请求头
headers = {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
设置请求体
data = {
'url': 'https://www.youtube.com/watch?v=suO6X5U4rmQ', # 替换为你的视频链接
'isAudioOnly': True # 设置为只获取音频
}
发送POST请求
response = requests.post('https://api.cobalt.tools/api/json', headers=headers, json=data)
解析响应
if response.status_code == 200:
response_data = response.json()
if response_data.get('status') == 'success':
audio_url = response_data.get('audio')
print(f"音频链接: {audio_url}")
else:
print(f"请求失败: {response_data.get('text')}")
else:
print(f"HTTP请求失败: {response.status_code}, 错误信息: {response.text}")
run code result return "请求失败: None"
@dumbmoron commented on GitHub (Jul 9, 2024):
what
@wanquanY commented on GitHub (Jul 9, 2024):
The request api, unable to get audio link to video