gpt4 book ai didi

python - 上传视频,然后使用YouTube数据API按ID检索视频

转载 作者:行者123 更新时间:2023-12-03 06:08:24 27 4
gpt4 key购买 nike

好的,使用插入功能上传视频后,我会从API返回视频ID,但是我不确定是否上传视频。

youtube_request = youtube.videos().insert(
part="snippet, status",
body={
"snippet": {
"title": title_input,
"categoryId": "22"
},
"status": {
"privacyStatus": "unlisted"
}
},
media_body=MediaFileUpload(os_video_path)
)
response = youtube_request.execute()
youtube_id = response['id']


按ID搜索youtube时似乎找不到它们。我使用了他们页面上的示例代码,有人可以告诉我我做错了什么吗?
    request = youtube.videos().list(
part="snippet,contentDetails,statistics",
id="JmFnvOZDXRc"
)
response = request.execute()

响应:
HTTP/1.1 200 
cache-control: private, max-age=0, must-revalidate, no-transform
content-encoding: gzip
content-length: 182
content-type: application/json; charset=UTF-8
date: Wed, 18 Mar 2020 17:03:56 GMT
etag: "SJZWTG6xR0eGuCOh2bX6w3s4F94/3tR7Y4Y9pxhARXrfsYwiDwvvwNg"
expires: Wed, 18 Mar 2020 17:03:56 GMT
server: GSE
vary: Origin, X-Origin

{
"kind": "youtube#videoListResponse",
"etag": "\"SJZWTG6xR0eGuCOh2bX6w3s4F94/3tR7Y4Y9pxhARXrfsYwiDwvvwNg\"",
"pageInfo": {
"totalResults": 0,
"resultsPerPage": 0
},
"items": []
}

最佳答案

该视频未公开,因此未显示。嵌入后,视频ID将起作用。

 <iframe width="560" height="315" src="https://www.youtube.com/embed/{{ video.video_id }}?rel=0" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

关于python - 上传视频,然后使用YouTube数据API按ID检索视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60744440/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com