feedleware/feedleware/youtube/__init__.py

22 lines
603 B
Python
Raw Permalink Normal View History

2021-09-12 22:00:24 +00:00
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__)
2021-09-12 22:00:24 +00:00
@youtube.route("/<string:channel_id>", methods=["GET", "HEAD"])
def get(channel_id: str):
2021-09-12 22:00:24 +00:00
try:
return (
construct_rss(client, channel_id),
2021-09-12 22:00:24 +00:00
{"Content-Type": "application/rss+xml"},
)
except NoSuchChannel:
abort(404)
return youtube