Skip to content

Commit

Permalink
Caught an HTTP non-200 error and updated LCDZ page URL
Browse files Browse the repository at this point in the history
  • Loading branch information
creativenucleus committed Jan 15, 2024
1 parent 0f9c0d7 commit 91b9721
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions playlist_lcdz.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,35 @@ package main

import (
"fmt"
"log"
"net/http"
"regexp"

"golang.org/x/net/html"
)

func NewPlaylistLCDZ() (*Playlist, error) {
urlSource := "https://livecode.demozoo.org/type/Byte%2520Jam.html"
urlSource := "https://livecode.demozoo.org/type/Byte_Jam.html"
resp, err := http.Get(urlSource)
if err != nil {
log.Fatal(err)
return nil, err
}
defer resp.Body.Close()

if resp.StatusCode != http.StatusOK {
log.Fatal(err)
return nil, fmt.Errorf("LCDZ page responded with [%s] rather than 200", resp.Status)
}

doc, err := html.Parse(resp.Body)
if err != nil {
return nil, err
}

p := NewPlaylist()
links := findAllLuaLinks(doc)
if len(links) == 0 {
return nil, fmt.Errorf("LCDZ page responded, but no lua files found")
}

for _, link := range links {
p.items = append(p.items, PlaylistItem{location: link})
}
Expand Down

0 comments on commit 91b9721

Please sign in to comment.