streamers

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: May 8, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package streamers extracts 30-day streaming statistics and generates sorted markdown.

BUG(🐛): there are bugs in here.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OpenCSV

func OpenCSV(file string) (afero.File, error)

OpenCSV opens the CSV file and returns an Afero file object and/or error.

Types

type Streamer

type Streamer struct {
	Name           string  // The name of the streamer
	YTURL          string  // The url of the streamer's YouTube channel
	SullyGnomeID   string  // The SullyGnome ID of the streamer
	ThirtyDayStats float32 // Hours streamed in the last 30 days
	Lang           string  // The streamer's language. If they are online this is used in the generated markdown.
}

Streamer is a struct that contains the name of a streamer and the YouTube channel url. SullyGnomeID and ThirtyDayStats are fetched from SullyGnome.com. (sorry for lightly gathering a small amount of info every 24 hours).

func (*Streamer) GetStats

func (s *Streamer) GetStats()

GetStats populates the Streamer struct's ThirtyDayStats field with 30-day streaming statistics.

func (*Streamer) GetUID

func (s *Streamer) GetUID()

GetUID populates the Streamer struct's SullyGnomeID field.

func (*Streamer) OnlineNow

func (s *Streamer) OnlineNow(indexText string) bool

OnlineNow returns a bool whether the streamer is online(🟢) or not in "index.md".

func (Streamer) ReturnMarkdownLine

func (s Streamer) ReturnMarkdownLine(online bool) (string, error)

ReturnMarkdownLine returns a GitHub markdown-flavored line for 'index.md' or 'inactive.md'. If the stream has > 0 hours over 30 days, it will return a line that contains columns for the 🟢 and Twitch/YouTube links. Otherwise if will return a line that just contains the streamer + links for inactive.md.

type StreamerList

type StreamerList struct {
	Streamers []Streamer // List of Streamers
}

StreamList is uhh... a list of Streamers.

func ParseStreamers

func ParseStreamers(f afero.File) (StreamerList, error)

ParseStreamers takes an Afero file object and returns a StreamerList populated with Streamer objects.

func (StreamerList) Len

func (sl StreamerList) Len() int

Len returns the length of the StreamerList, used to implement sort.Interface.

func (StreamerList) Less

func (sl StreamerList) Less(i, j int) bool

Less returns a bool for i > j, used to implment sort.Interface.

func (*StreamerList) Sort

func (sl *StreamerList) Sort()

Implement sort, after implementing the Len, Less, and Swap functions to satisfy the sort.Interface.

func (StreamerList) Swap

func (sl StreamerList) Swap(i, j int)

Swap swaps the elements at i and j in the StreamerList, used to implement sort.Interface.

type SullyGnomeStats

type SullyGnomeStats struct {
	Data struct {
		Datasets []struct {
			Data []float32 `json:"data"`
		} `json:"datasets"`
	} `json:"data"`
}

SullyGnomeStats is a struct to deserialize the 30-day streaming statistics json response.

Notes

Bugs

  • there are bugs in here.

Jump to

Keyboard shortcuts

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