How does https://pubsubhubbub.appspot.com/ actually works and what kind of response am I expected to receive?

601 Views Asked by At

Good day everyone,

For context purpose, I am trying to monitor a Youtube Channel where, whenever they post a new video, I will get a notification and process the entry.

What I have done:- a) setup the callback url to receive and reply the hub challenge.

b) https://pubsubhubbub.appspot.com/subscribe Subscribe to this site as suggested by Youtube where the topic URL is https://www.youtube.com/feeds/videos.xml?channel_id=UClrEYreVkBee7ZQYei_6Jqg (atom-feed) and the callback URL is to a Google Cloud functions url.

verification c) Reply and verified the hub challenge sent by (b).

The questions I have are:

  1. I havent receive any response from pubsubhubbub since the subscription but the Youtube channel already has updated videos since then. Have I missed some steps here or is this not the expectation to have?

  2. I expect to only receive a notification and not the XML feed body from pubsubhubbub and upon notification, I should then process and fetch the XML feed from the channel.

OR

I expect to receive the XML feed body / latest entry from pubsubhubbub.

The reason I am asking this is I see there is a latest entry latest entry and not the full feed in the pubsubhubbub site.

Thanks in advance if there are anybody who could help answer these questions.

1

There are 1 best solutions below

2
user2465378 On
import express from 'express';
import dotenv from "dotenv";
dotenv.config();

const YouTubeNotifier = require('youtube-notification');
const app = express();
const port = 6050;
const baseUrl = "https://evil-wasp-10.loca.lt"
let channelId = process.env.CHANNEL_ID;

export const notifier = new YouTubeNotifier({
    hubCallback: `${baseUrl}/youtube/notifications`,
});

app.use("/youtube/notifications", notifier.listener());

app.listen(port, () => {
    console.log(`App listening at http://localhost:${port}`)

})

notifier.subscribe(channelId);

notifier.on('subscribe', (data: any) => {
    console.log('Subscribed');
    console.log(data);
});

notifier.on('notified', (data: any) => {
    console.log('New Video');
    console.log(data);
});