Is there any way to extract the "Most Replayed" (aka Video Activity Graph) Data from a YouTube video via API?
What I'm referring to:
Is there any way to extract the "Most Replayed" (aka Video Activity Graph) Data from a YouTube video via API?
What I'm referring to:
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=mostReplayed&id=VIDEO_ID, you will get the most replayed graph values you are looking for in item["mostReplayed"]
.
With the video id XiCrniLQGYc
you would get:
{
"kind": "youtube#videoListResponse",
"etag": "NotImplemented",
"items": [
{
"kind": "youtube#video",
"etag": "NotImplemented",
"id": "XiCrniLQGYc",
"mostReplayed": {
"markers": [
{
"startMillis": 0,
"intensityScoreNormalized": 1
},
{
"startMillis": 2580,
"intensityScoreNormalized": 0.7083409245967562
},
{
"startMillis": 5160,
"intensityScoreNormalized": 0.6381007317793738
},
...
{
"startMillis": 255420,
"intensityScoreNormalized": 0.012864077773078256
}
],
"timedMarkerDecorations": [
{
"visibleTimeRangeStartMillis": 0,
"visibleTimeRangeEndMillis": 10320
}
]
}
}
]
}
heatMarkerIntensityScoreNormalized
name suggests, I recommend you to learn more about Normalisation. –
Cadence googleapiclient
but when I request the API, it returns the item[mostReplayed]
as None. Am I doing something wrong with your API as it has worked very well with IDs that I have just manually retrieved from other YouTube videos. –
Fontana ['l-bGkjtMC0Q', 'OLvRv-poMtA', '4R7vRFGJr3k', 'OBsLKLef-F0', 'ar3gEAT2h28', '6ecTO22ulRM', 'J4-lP_D7iEk', 'ZEuV9d3gsio', 'T4CY4wVqhPU', 'v8tR7mPsBcU']
–
Fontana l-bGkjtMC0Q
does not have public most replayed data (see OP highlighted curve example), hence my API cannot retrieve any. –
Cadence Adding the following snippet to parse/read through @Benjamin's API response. This function will give you the top 5 snippets (peaks) from the video.
def get_peak_rewatched_timestamps(test_data):
markers = test_data['items'][0]['mostReplayed']['markers']
sorted_markers = sorted(markers, key=lambda x: x['intensityScoreNormalized'], reverse=True)
top_markers = sorted_markers[:5]
top_timestamps_seconds = [marker['startMillis'] / 1000 for marker in top_markers]
return top_timestamps_seconds
© 2022 - 2024 — McMap. All rights reserved.