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:
https://youtube.com/clip/Ugkx
+ 32 characters
For example, for a 15 second clip starting at the beginning of:
https://www.youtube.com/watch?v=NiXD4xVJM5Y
The link is:
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.
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:
[...] "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.