özgün deniz
Kilopat
- Katılım
- 3 Aralık 2017
- Mesajlar
- 2.425
- Makaleler
- 1
- Çözümler
- 34
Buradaki (Subscribe to Push Notifications | YouTube Data API | Google for Developers) yönergeleri takip edip. Kayıt oluyorum. Python ile Flask uygulaması yapıp Ngrok ile Web'e çıkardım.
https://pubsubhubbub.appspot.com/subscribe sayfasından da callback url'i "ngrokurl/feed" ayarladım.
Topic'i de https://www.youtube.com/xml/feeds/videos.xml?channel_id=CHANNEL_ID 'ye uygun olarak ayarladım.
Youtube'un /feed'e attığı GET isteği ile hub.challenge'ı geri return'lüyorum subscribe olurken 200 dönüyor başarılı. Ama sonrasında hiçbir notification gelmiyor.
Yine aynı sayfadan (https://pubsubhubbub.appspot.com/subscribe) aboneliğin durumunu sorguluyorum. State:unverified gözüküyor. Abonelik isteğinden 1 saniye sonra da mismatch error diye bir error görüntüleniyor.
İşin içinden bir türlü çıkamadım.
Python:
import asyncio
import xmltodict
from xml.parsers.expat import ExpatError
import aiohttp
from discord import Webhook
from flask import Flask, request
from tivtech.WebhookConfig import CONFIG as config
app = Flask(__name__)
@app.route("/feed", methods=["GET", "POST"])
def feed():
async def send_message(content):
async with aiohttp.ClientSession() as session:
webhook = Webhook.from_url(config.webhook_url, session=session)
await webhook.send(content=content, username="Foo")
challange = request.args.get("hub.challenge")
if challange:
return challange
try:
xml_dict = xmltodict.parse(request.data)
channel_id = xml_dict["feed"]["entry"]["yt:channelId"]
print(channel_id)
if channel_id != config.youtube_channel_id:
return "", 403
video_url = xml_dict["feed"]["entry"]["link"]["@href"]
loop = asyncio.get_event_loop()
response = loop.run_until_complete(send_message(content=video_url))
except (ExpatError, LookupError):
print("Error")
return "", 403
return "", 204
if __name__ == "__main__":
app.run()
https://pubsubhubbub.appspot.com/subscribe sayfasından da callback url'i "ngrokurl/feed" ayarladım.
Topic'i de https://www.youtube.com/xml/feeds/videos.xml?channel_id=CHANNEL_ID 'ye uygun olarak ayarladım.
Youtube'un /feed'e attığı GET isteği ile hub.challenge'ı geri return'lüyorum subscribe olurken 200 dönüyor başarılı. Ama sonrasında hiçbir notification gelmiyor.
Yine aynı sayfadan (https://pubsubhubbub.appspot.com/subscribe) aboneliğin durumunu sorguluyorum. State:unverified gözüküyor. Abonelik isteğinden 1 saniye sonra da mismatch error diye bir error görüntüleniyor.
İşin içinden bir türlü çıkamadım.