22 lines
600 B
Python
22 lines
600 B
Python
from flask import abort, Blueprint
|
|
from .twitch import APIClient, NoSuchUser
|
|
from .feed import construct_rss
|
|
|
|
|
|
def create_blueprint(config):
|
|
"""Create a Twitch endpoint blueprint."""
|
|
client = APIClient(config["client_id"], config["secret"])
|
|
twitch = Blueprint("twitch", __name__)
|
|
|
|
@twitch.route("/<string:login>", methods=["GET", "HEAD"])
|
|
def vod(login: str):
|
|
try:
|
|
return (
|
|
construct_rss(client, login),
|
|
{"Content-Type": "application/rss+xml"},
|
|
)
|
|
except NoSuchUser:
|
|
abort(404)
|
|
|
|
return twitch
|