feedleware/feedleware/youtube/__init__.py

22 lines
585 B
Python
Raw 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"])
twitch = Blueprint("youtube", __name__)
@twitch.route("/<string:login>", methods=["GET", "HEAD"])
def vod(login: str):
try:
return (
construct_rss(client, login),
{"Content-Type": "application/rss+xml"},
)
except NoSuchChannel:
abort(404)
return twitch