-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Please provide an up-to-date example of PubSubhubbub #177
Comments
Nothing changed after year. That's sad. |
@sluongng, @MrBoombastic Hi guys I had the same problem for the past several weeks and I guess I was able to fix it locally, so wanted to share my approach. To begin with I also share the same frustration towards the lack of documentation. I tried two approaches - NodeJS (via koa2) didn't worked (wasn't able to read the body correctly) and So the steps are: 1. Create a new flask app
app.py: from flask import Flask
from flask import request
app = Flask(__name__)
# irrelevant to the question method, just for testing purposes
@app.route("/", methods=['GET', 'POST'])
def ping():
return 'pong'
@app.route("/feed", methods=['GET', 'POST'])
def feed():
challenge = request.args.get('hub.challenge')
if (challenge):
return challenge
print(request.data) # binary literal with xml payload
return '', 204
2. Create a ngrok tunnel (https://ngrok.com/docs)For me it looked something like that 3. Make a subscription in https://pubsubhubbub.appspot.com/subscribe
4. Test subscription5. Analyze report
6. Debugging
7. Further improvements
|
Good job, but PSHB should be simple. Now scraping XML for channel is faster and easier than this. Anyway, thank you! |
@MrBoombastic what do you mean by
|
Each channel has xml file with 10 latest videos. |
Gotcha! You mean this RSS feed |
@yoandinkov I tried to do this in Express.js but there is nothing return from the req or res object. |
@shan1iu can you share your project/give more information what have you done and what haven't worked exactly. Also do you get the right results from step 4 (testing the subscription)? |
What limits does PubSubhubbub have? How many channels can I listen to using it? |
i creating api in python to deploy in heroku and use the pubsubhubub |
@mmkhitaryan I'd like to know that also - I asked a question at StackOverflow but no answer yet: |
Hey there! I am currently having problems determining whether a pubsubhubbub notification that i recieved is a new upload or just a title/description change. Can anybody help me with that? |
@malaire - what's your count that you're trying it with? |
@AXVin - actually it's hard to say, I guess, I do use following approach: if a video's release date was less than an hour in the time the event appears I treat it as "new video" and store it in my database. |
@yoandinkov I have been testing with just 2 subscriptions for now, but YouTube push notifications are not working at all - I have received ZERO notifications while both channels have uploaded videos. I'm now waiting for YouTube to fix this bug before I start testing with more subscriptions. (Subscriber Diagnostics confirms that PubSubHubbub has received nothing from YouTube, so it's YouTube bug, not PubSubHubbub bug.) |
@malaire Do you have the GET method handled for the callback? You must return the hub.challenge query param inside that otherwise it will not be verified correctly and you will never recieve any updates ever. (Because, i do get the notifications) |
@AXVin My code is working correctly. Subscriber Diagnostics says "State: verified", and no errors of any kind, but "Content received: n/a" and "Content delivered: n/a". And manually checking the Topic URL confirms that uploads are happening so there should be push notifications. |
@malaire I can confirm that this service works correctly for me. My suggestion is either upload your own video in your own channel (so you know exactly what and when is being uploaded) or use some big channel (as CNN for example). Another suggestion is to refer to my previous post (from 02.12.2019) especially point 5. What about other properties (except State) do you have timestamps for all others as well (like subscription, etc.)? |
@yoandinkov I did test with my own channel where I uploaded video - no notification. And timestamps were correct also. I'm not interested in big channels but in small channels. I made issue here (without timestamps as I didn't remember them anymore, but I can add those once I finish currently ongoing 10-day test without any notifications): https://issuetracker.google.com/issues/169067950 |
I also tried doing this for live broadcasts. I can confirm the live broadcast shows up in the XML videos feed but the pubsubhubbub just doesn't seem to work. I did a similar flow for Twitch webhooks and it worked fine so I'm not sure where the disconnect is. There's seemingly no way to debug things programmatically so it just "doesn't work" from my end. |
I created flask API using your snippet it displays get request on terminal and black page on pubsubhubbub
and when i try to diagnose it displays these details Any idea why this is soo? |
Here's how I got it to work with NodeJS: const express = require('express');
const bodyParser = require('body-parser');
const app = express();
require('body-parser-xml')(bodyParser);
app.get('/test', ({ query: { 'hub.challenge': challenge } }, res) => {
console.log(challenge);
res.status(200).end(challenge)
});
app.post(`/test`, bodyParser.xml(), ({ body: {feed} }, res) => {
console.log(feed);
res.status(204).end();
});
app.listen(1234); PSHB sends a
|
Hi guys, thanks for the solution! Sorry, this question might be stupid, so please bear with me — I'm really new to YouTube APIs. |
@Menelion In theory - yes, you can, if you have your own mailing service etc. In practice - PSHB is really piece of garbage to test and handle. As I said about year ago in this thread, it's easier to use XML endpoint than trying to set up PubSub. Maybe you will have more luck? |
@MrBoombastic Thanks for your reply! However, I don't see any way of getting the single feed for all of my subscriptions in XML, either. See this, for example. Any ideas? |
@Menelion As somebody said in the answer in your linked question, you can manually export all your subscribed channels here: https://www.youtube.com/subscription_manager, convert downloaded XML to something easy to work with like JSON and ask Youtube's XML endpoint about each of channels listed in your JSON file. Yeah, if you have, for example, 200 channels subscribed, you have to make 200 requests to YouTube. But don't worry - it's not very limited, so you shouldn't expect Captchas or other blocks. |
@AXVin It seems this feature of poorly documented, so I created an issue on their official issue tracker. Edit: Google has already given this issue to an assignee. |
I made it work with Firebase Cloud Functions. Here is the github repo you can refer to: The cloud function verifies and also handles incoming feed. When it recieves data, it gets the updated video id, make a request to youtube api to get updated data and then stores it in firestore. |
@hanzlahabib can you fix your problem? |
I have save problem. |
I have the same question. Can anyone give some explainations or advices? |
@wsysuper Topic url is https://www.youtube.com/xml/feeds/videos.xml |
@tree1891 did you solve the problem |
@loademon yes, it does work well. |
how, can u explain |
The problem was solved when I ran it with Ngrok account. (Mismatch error) I logged in with my account key, not without an account. |
Has anyone had any luck with other pubsubhubbub endpoints? |
Hi everyone. I saw this issue and figured I would help out. YouTube doesn't really support PubSubHubbub or WebSub. It supports a protocol that is sort of based on these protocols. It also has some major issues. For example the push doesn't contain all of the information from the feed as would be required by the protocol, but instead basically just the video IDs and some fake information. Then you need to fetch the information yourself. This can be done by the YouTube API (if you have access) or by manually fetching the feed. But if you fetch the feed be careful as the feed seems to be cached even when it shouldn't be, so you will frequently get a notification via WebSub long before the item is actually available in the feed. So you basically need to fall back to polling anyways. I wrote more detail about this a while ago. I just gave it a re-read and it is still accurate. (I run a feed-reader service which subscribes to YouTube feeds via their WebSub-like API.) Between this doc and the WebSub specification there should be enough information to subscribe via "YouTube flavoured PubSubHubbub". https://kevincox.ca/2021/12/16/youtube-websub/ I'm happy to answer any questions not answered in either the spec or article. |
I start to touch this issue a few days ago. |
following |
According to https://developers.google.com/youtube/v3/guides/push_notifications you guys do support it.
But most of the code I can find around github or tutorial online are widely outdated.
Plus the configuration is a mix-bag between setting up environment for callback support to working with the web interface on https://pubsubhubbub.appspot.com/subscribe
Many library also claim that their implementation are not compatitble with latest specification.
Please help provide a working tutorial/example code. Preferable in GO/Python or NodeJS.
Also if there is a reliable way of testing this code, instead of having to wait around for a channel to upload a video, it would be very nice.
Thanks!
The text was updated successfully, but these errors were encountered: