feedleware/feedleware/youtube/__init__.py

22 lines
603 B
Python

from flask import abort, Blueprint
from .youtube import APIClient, NoSuchChannel
from .feed import construct_rss
def create_blueprint(config):
"""Create a YouTube endpoint blueprint."""
client = APIClient(config["key"])
youtube = Blueprint("youtube", __name__)
@youtube.route("/<string:channel_id>", methods=["GET", "HEAD"])
def get(channel_id: str):
try:
return (
construct_rss(client, channel_id),
{"Content-Type": "application/rss+xml"},
)
except NoSuchChannel:
abort(404)
return youtube