gdq

package module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 16, 2020 License: MIT Imports: 12 Imported by: 0

README

🏃 GDQ 🎮

A Go library and CLI for Games Done Quick

Build Status Coverage Status Go report card GoDoc

Games Done Quick (GDQ) is a regular speedrunning event that collects money for charity. The event is incredibly fun, especially if you enjoy seeing your favourite games torn to shreds by amazing runners and supported with great commentary and prizes to win.

This repo contains a Go library and CLI for working with the GDQ schedule. Since GDQ doesn't have an API for the schedule we rely on parsing the HTML of the schedule page instead, so beware this library might break if the design of the schedule changes.

There is also a companion Matrix bot over at GDQBot.

Documentation

Index

Constants

View Source
const (
	// ErrMissingSchedule means we couldn't find a schedule at all
	ErrMissingSchedule err = "missing schedule"
	// ErrInvalidSchedule means the schedule we found isn't conforming to our expectations
	ErrInvalidSchedule err = "invalid schedule"
	// ErrUnexpectedData means we encountered a row in a different format
	ErrUnexpectedData err = "row did not contain the data we expected"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Duration

type Duration struct {
	time.Duration
}

Duration represents a interval of time

func (Duration) MarshalJSON

func (d Duration) MarshalJSON() (b []byte, err error)

MarshalJSON marshals a Duration to JSON

func (Duration) String

func (d Duration) String() string

type Edition

type Edition uint

Edition is the schedule ID of a GDQ edition

const (
	Latest   Edition = 0
	AGDQ2016 Edition = iota + 16
	SGDQ2016
	AGDQ2017
	SGDQ2017
	HRDQ2017
	AGDQ2018
	SGDQ2018
	GDQX2018
	AGDQ2019
	SGDQ2019
	GDQX2019
	AGDQ2020
	FrostFatales2020
	SGDQ2020
	CRDQ2020

	FleetFatales2020
	AGDQ2021
)

All the GDQ editions for which a schedule is available

func GetEdition

func GetEdition(input string) (edition Edition, found bool)

GetEdition tries to find an edition matching the input

func (Edition) String

func (e Edition) String() string

type Event

type Event struct {
	Start    time.Time `json:"start"`
	Setup    Duration  `json:"setup"`
	Estimate Duration  `json:"estimate"`
	Runners  []string  `json:"runners"`
	Hosts    []string  `json:"hosts"`
	Title    string    `json:"title"`
	Category string    `json:"category"`
	Platform string    `json:"platform"`
}

Event represents a single event at a GDQ

type Schedule

type Schedule struct {
	Events []*Event
	// contains filtered or unexported fields
}

Schedule represents the events occurring at a GDQ

func GetSchedule

func GetSchedule(id Edition, client *http.Client) (*Schedule, error)

GetSchedule returns the Schedule for a GDQ edition

A client has to be passed in. Please make sure to configure your client correctly, so not http.DefaultClient. Be nice to server admins and make sure your client sets a User-Agent header.

func NewSchedule

func NewSchedule() *Schedule

NewSchedule returns an empty Schedule

func NewScheduleFrom

func NewScheduleFrom(events []*Event) *Schedule

NewScheduleFrom returns a scheduled filled with the events

func (*Schedule) ForHost

func (s *Schedule) ForHost(name string) *Schedule

ForHost returns a new schedule with events only matching this host

The host's name is matched using a string submatch. This means that if you call somtething like schedule.ForHust("b") you can get a schedule with events for multiple hosts.

The match is case insensitive.

func (*Schedule) ForRunner

func (s *Schedule) ForRunner(name string) *Schedule

ForRunner returns a new schedule with events only matching this runner

The runner's name is matched using a string submatch. This means that if you call somtething like schedule.ForRunner("b") you can get a schedule with events for multiple runners.

The match is case insensitive.

func (*Schedule) ForTitle

func (s *Schedule) ForTitle(title string) *Schedule

ForTitle returns a new schedule with events only matching this event title

The title is matched using a string submatch. This means that if you call somtething like schedule.ForTitle("b") you can get a schedule with multiple events.

The match is case insensitive.

func (*Schedule) NextEvent

func (s *Schedule) NextEvent() *Event

NextEvent returns the next/upcoming event in the schedule

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL