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
}
]
}
}
]
}
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With