feat: Add better error messages to podcast routes
All checks were successful
Build Docker / BuildImage (push) Successful in 52s

This commit is contained in:
2025-10-11 17:59:06 +11:00
parent 9f7b93b8a1
commit 74362de02a

View File

@@ -1,4 +1,5 @@
from flask import Blueprint, make_response from flask import Blueprint, make_response, request
from tools import error_response
import requests import requests
podcast_bp = Blueprint('podcast', __name__) podcast_bp = Blueprint('podcast', __name__)
@@ -7,6 +8,9 @@ podcast_bp = Blueprint('podcast', __name__)
def podcast_index_get(): def podcast_index_get():
# Proxy to ID1 url # Proxy to ID1 url
req = requests.get("https://podcasts.c.woodburn.au/ID1") req = requests.get("https://podcasts.c.woodburn.au/ID1")
if req.status_code != 200:
return error_response(request, "Error from Podcast Server", req.status_code)
return make_response( return make_response(
req.content, 200, {"Content-Type": req.headers["Content-Type"]} req.content, 200, {"Content-Type": req.headers["Content-Type"]}
) )
@@ -16,6 +20,8 @@ def podcast_index_get():
def podcast_contents_get(): def podcast_contents_get():
# Proxy to ID1 url # Proxy to ID1 url
req = requests.get("https://podcasts.c.woodburn.au/ID1/") req = requests.get("https://podcasts.c.woodburn.au/ID1/")
if req.status_code != 200:
return error_response(request, "Error from Podcast Server", req.status_code)
return make_response( return make_response(
req.content, 200, {"Content-Type": req.headers["Content-Type"]} req.content, 200, {"Content-Type": req.headers["Content-Type"]}
) )
@@ -25,6 +31,8 @@ def podcast_contents_get():
def podcast_path_get(path): def podcast_path_get(path):
# Proxy to ID1 url # Proxy to ID1 url
req = requests.get("https://podcasts.c.woodburn.au/ID1/" + path) req = requests.get("https://podcasts.c.woodburn.au/ID1/" + path)
if req.status_code != 200:
return error_response(request, "Error from Podcast Server", req.status_code)
return make_response( return make_response(
req.content, 200, {"Content-Type": req.headers["Content-Type"]} req.content, 200, {"Content-Type": req.headers["Content-Type"]}
) )
@@ -34,6 +42,8 @@ def podcast_path_get(path):
def podcast_xml_get(): def podcast_xml_get():
# Proxy to ID1 url # Proxy to ID1 url
req = requests.get("https://podcasts.c.woodburn.au/ID1.xml") req = requests.get("https://podcasts.c.woodburn.au/ID1.xml")
if req.status_code != 200:
return error_response(request, "Error from Podcast Server", req.status_code)
return make_response( return make_response(
req.content, 200, {"Content-Type": req.headers["Content-Type"]} req.content, 200, {"Content-Type": req.headers["Content-Type"]}
) )
@@ -42,6 +52,8 @@ def podcast_xml_get():
@podcast_bp.route("/podsync.opml") @podcast_bp.route("/podsync.opml")
def podcast_podsync_get(): def podcast_podsync_get():
req = requests.get("https://podcasts.c.woodburn.au/podsync.opml") req = requests.get("https://podcasts.c.woodburn.au/podsync.opml")
if req.status_code != 200:
return error_response(request, "Error from Podcast Server", req.status_code)
return make_response( return make_response(
req.content, 200, {"Content-Type": req.headers["Content-Type"]} req.content, 200, {"Content-Type": req.headers["Content-Type"]}
) )