“最重播”通过API的YouTube视频数据

发布于 2025-02-07 04:19:35 字数 256 浏览 2 评论 0 原文

有什么方法可以通过API从YouTube视频中提取“最重播”(又称视频活动图)?

我指的是:

”

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

娇妻 2025-02-14 04:19:35

YouTube Data API V3再一次没有提供基本功能。

我建议您尝试我的 youtube操作API 。的确,通过获取 https://yt.lemt.lemn.lemnife.com/videos.com/videos?part=mostreplayplayplayplay& amp; amp; amp; amp; amp; amp; amp; amp; amp; id = video_id ,您将在 item [“ mostreplayed”] 中获得最重播的图形值。

带有视频ID xicrnilqgyc 您会得到:

{
    "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
                    }
                ]
            }
        }
    ]
}

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
                    }
                ]
            }
        }
    ]
}
缪败 2025-02-14 04:19:35

将以下片段添加到分析/读取@benjamin的API响应
此功能将为您提供视频中前5个片段(峰)。

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

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文