gpt4 book ai didi

c# - 如何在 YouTube 用户上传视频时调用函数?

转载 作者:行者123 更新时间:2023-11-30 15:21:17 24 4
gpt4 key购买 nike

我正在尝试制作一个简单的聊天机器人,它会在某个 channel 上传视频时发送一条消息,最好是包含视频的名称和视频的超链接。

YouTube 的 API 很奇怪,我完全不知道如何处理。

这是我目前所拥有的:

using System;
using System.Linq;
using Google.Apis.Services;
using Google.Apis.YouTube.v3;

YouTubeService service = new YouTubeService(new BaseClientService.Initializer() {
ApiKey = apiKey,
ApplicationName = "GoodApp"
});

var getChannel = service.Channels.List("snippet");
getChannel.Id = channelId;

var response = getChannel.Execute();

var channel = response[0]; //now what?

最佳答案

使用 the YouTube PubSubHubbub service当 channel 上传新视频、更改视频标题或更改视频描述时,您可以收到推送通知。从该页面引用有关设置的信息:

  1. Set up a callback server that can handle incoming Atom feed notifications.
  2. Use the Google hub to subscribe to receive push notifications:
    • Set the mode to subscribe. (Or set the mode to unsubscribe to cancel a subscription.)
    • Set the callback URL to the URL that you set up in step 1.
    • Set the topic URL to https://www.youtube.com/xml/feeds/videos.xml?channel_id=CHANNEL_ID, where CHANNEL_ID is the YouTube channel ID for which you want to retrieve push notifications.
  3. Process notifications sent to your callback server. [...]

不幸的是,回调服务器不仅仅是几行代码,而且这取决于您运行的服务器类型。如果您了解 PHP、AppEngine 或 Go,订阅者存储库位于 PubSubHubbub可能会有帮助,否则搜索引擎似乎对我有很好的结果。

关于c# - 如何在 YouTube 用户上传视频时调用函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37913009/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com