Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Most Replayed" Data of YouTube Video via API

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:

Image of Youtube Video with "Most Replayed" Data displayed

like image 714
prodohsamuel Avatar asked Jan 26 '26 06:01

prodohsamuel


2 Answers

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
                    }
                ]
            }
        }
    ]
}
like image 128
Benjamin Loison Avatar answered Jan 27 '26 21:01

Benjamin Loison


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
like image 27
Chiranshu Adik Avatar answered Jan 27 '26 20:01

Chiranshu Adik



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!