yt-chan-cgi: fix status code and sfeed_jsonfeed to sfeed_json - randomcrap - random crap programs of varying quality
 (HTM) git clone git://git.codemadness.org/randomcrap
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 6b4ba24149b5d51c6c07d5019d13087032491dc8
 (DIR) parent bd66c5e8f9cf5011390ad6b2a262de53c04d44b4
 (HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org>
       Date:   Sat,  6 May 2023 20:39:21 +0200
       
       yt-chan-cgi: fix status code and sfeed_jsonfeed to sfeed_json
       
       Diffstat:
         M yt-chan-cgi                         |      22 +++++++++++-----------
       
       1 file changed, 11 insertions(+), 11 deletions(-)
       ---
 (DIR) diff --git a/yt-chan-cgi b/yt-chan-cgi
       @@ -38,14 +38,14 @@ channelid="${channelid##\?}"
        channelid="${channelid##c=}"
        
        if test "$channelid" = ""; then
       -        printf 'Status: 400\r\n'
       +        printf 'Status: 400 Bad Request\r\n'
                printf 'Content-Type: text/plain; charset=utf-8\r\n\r\n'
                exit 1
        fi
        
        channelid="$(printf '%s' "$channelid" | sed -E 's@[^a-zA-Z0-9_-]*@@g')"
        if test "$channelid" = ""; then
       -        printf 'Status: 400\r\n'
       +        printf 'Status: 400 Bad Request\r\n'
                printf 'Content-Type: text/plain; charset=utf-8\r\n\r\n'
                printf "Channel ID must be set and proper: %s" "$channelid"
                exit 1
       @@ -60,7 +60,7 @@ trap 'rm -f "$f1" "$f2" "$f3"' EXIT
        
        url="https://www.youtube.com/feeds/videos.xml?channel_id=${channelid}"
        if ! hurl "$url" > "$f2"; then
       -        printf 'Status: 400\r\n'
       +        printf 'Status: 400 Bad Request\r\n'
                printf 'Content-Type: text/plain; charset=utf-8\r\n\r\n'
                printf 'Could not get feed: %s' "$url"
                exit 1
       @@ -68,7 +68,7 @@ fi
        
        # get channel data.
        if ! channel2tsv "$channelid" > "$f1"; then
       -        printf 'Status: 400\r\n'
       +        printf 'Status: 400 Bad Request\r\n'
                printf 'Content-Type: text/plain; charset=utf-8\r\n\r\n'
                printf 'Could not get channel videos: %s' "$channelid"
                exit 1
       @@ -103,32 +103,32 @@ FILENAME == f2 {
        
        case "${format}" in
        "json")
       -        printf 'Status: 200\r\n'
       +        printf 'Status: 200 OK\r\n'
                printf 'Content-Type: application/json; charset=utf-8\r\n\r\n'
       -        sfeed_jsonfeed < "$f3"
       +        sfeed_json < "$f3"
                ;;
        "html")
       -        printf 'Status: 200\r\n'
       +        printf 'Status: 200 OK\r\n'
                printf 'Content-Type: text/html; charset=utf-8\r\n\r\n'
                sfeed_html < "$f3"
                ;;
        "twtxt")
       -        printf 'Status: 200\r\n'
       +        printf 'Status: 200 OK\r\n'
                printf 'Content-Type: text/plain; charset=utf-8\r\n\r\n'
                sfeed_twtxt < "$f3"
                ;;
        "txt")
       -        printf 'Status: 200\r\n'
       +        printf 'Status: 200 OK\r\n'
                printf 'Content-Type: text/plain; charset=utf-8\r\n\r\n'
                sfeed_plain < "$f3"
                ;;
        "xml")
       -        printf 'Status: 200\r\n'
       +        printf 'Status: 200 OK\r\n'
                printf 'Content-Type: text/xml; charset=utf-8\r\n\r\n'
                sfeed_atom < "$f3"
                ;;
        *)
       -        printf 'Status: 200\r\n'
       +        printf 'Status: 200 OK\r\n'
                printf 'Content-Type: text/plain; charset=utf-8\r\n\r\n'
                cat "$f3"
                ;;