英文:
Access a YouTube Clip's start and end point
问题
目标:
我正在尝试找到YouTube剪辑的起始点和结束点。
YouTube剪辑的URL似乎没有遵循逻辑,除非它们具有以下格式:
https://youtube.com/clip/Ugkx
+ 32个字符
例如,对于从以下视频的开头开始的15秒剪辑:
https://www.youtube.com/watch?v=NiXD4xVJM5Y
链接是:
https://youtube.com/clip/UgkxU2HSeGL_NvmDJ-nQJrlLwllwMDBdGZFs
在URL中没有任何提示表明它从0秒开始,持续15秒,或来自视频ID NiXD4xVJM5Y
。
从HTML中,我能够找到视频ID:
<html>
...
<body>
...
<ytd-app>
...
<div#content.style-scope.ytd-app>
...
<ytd-page-manager#page-manager.style-scope.ytd-app>
...
<ytd-watch-flexy class="style-scope ytd-page-manager hide-skeleton" video-id="NiXD4xVJM5Y"...>
但我找不到起始点、结束点和/或持续时间。
理想情况下,我想使用Python包读取HTML,获取起始点和结束点,或者获取起始点并通过添加持续时间来确定结束点。
也许我需要使用YouTube数据API?我对YouTube的API不熟悉。
英文:
Goal:
I am trying to find the start and end point of a YouTube Clip.
The URL's for YouTube Clips appear to follow no logic other than they have:<br>
https://youtube.com/clip/Ugkx
+ 32 characters
For example, for a 15 second clip starting at the beginning of: <br>
https://www.youtube.com/watch?v=NiXD4xVJM5Y
The link is: <br>
https://youtube.com/clip/UgkxU2HSeGL_NvmDJ-nQJrlLwllwMDBdGZFs
There is nothing in the URL that would suggest it starts at 0 seconds, last 15 seconds or comes from video ID NiXD4xVJM5Y
.
From the HTML I was able to find the video id:
<html>
...
<body>
...
<ytd-app>
...
<div#content.style-scope.ytd-app>
...
<ytd-page-manager#page-manager.style-scope.ytd-app>
...
<ytd-watch-flexy class="style-scope ytd-page-manager hide-skeleton" video-id="NiXD4xVJM5Y"...>
But I cannot find the start point, end point, and/or duration.
Ideally, I would use a Python package to read the HTML, get the start and end point or get the start point and determine the end point by adding the duration.
Maybe I need to use YouTube Data API? I am inexperienced in YouTube's APIs.
答案1
得分: 1
YouTube Data API v3不提供基本功能。
我建议你尝试使用我的开源YouTube运营API。通过访问https://yt.lemnoslife.com/videos?part=clip&clipId=CLIP_ID,你可以在item["clip"]
中获取给定剪辑的开始时间和结束时间(以毫秒为单位)。
使用剪辑ID UgkxU2HSeGL_NvmDJ-nQJrlLwllwMDBdGZFs
你将得到:
{
"kind": "youtube#videoListResponse",
"etag": "NotImplemented",
"items": [
{
"kind": "youtube#video",
"etag": "NotImplemented",
"id": "UgkxU2HSeGL_NvmDJ-nQJrlLwllwMDBdGZFs",
"clip": {
"startTimeMs": 0,
"endTimeMs": 15000
}
}
]
}
英文:
One more time YouTube Data API v3 doesn't provide a basic feature.
I recommend you to try out my open-source YouTube operational API. Indeed by fetching https://yt.lemnoslife.com/videos?part=clip&clipId=CLIP_ID, you will get the start and end time in milliseconds of a given clip in item["clip"]
.
With the clip id UgkxU2HSeGL_NvmDJ-nQJrlLwllwMDBdGZFs
you would get:
{
"kind": "youtube#videoListResponse",
"etag": "NotImplemented",
"items": [
{
"kind": "youtube#video",
"etag": "NotImplemented",
"id": "UgkxU2HSeGL_NvmDJ-nQJrlLwllwMDBdGZFs",
"clip": {
"startTimeMs": 0,
"endTimeMs": 15000
}
}
]
}
答案2
得分: 0
以下是已经翻译好的部分:
这些信息无法通过API获得。
但是,您可以检查页面的源代码,即
https://youtube.com/clip/UgkxU2HSeGL_NvmDJ-nQJrlLwllwMDBdGZFs
并提取数据:
[...] "startMs":"237223","endMs":"257223" [...]
这对应于剪辑的开始和结束时间。
以及:
[...] "clipConfig":{"postId":"UgkxU2HSeGL_NvmDJ-nQJrlLwllwMDBdGZFs","startTimeMs":"0","endTimeMs":"15000"} [...]
这对应于所述剪辑的持续时间。
英文:
This information is not available through the API.
However, you could check the source code of the page - i.e.
https://youtube.com/clip/UgkxU2HSeGL_NvmDJ-nQJrlLwllwMDBdGZFs
and extract the data:
<!-- language-all: json -->
[...] "startMs":"237223","endMs":"257223" [...]
Which corresponds to the start and end time of the clip.
and:
[...] "clipConfig":{"postId":"UgkxU2HSeGL_NvmDJ-nQJrlLwllwMDBdGZFs","startTimeMs":"0","endTimeMs":"15000"} [...]
which corresponds to the duration of the said clip.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论