twedia

package
v0.0.0-...-1a45625 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2023 License: GPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetChannelID

func GetChannelID(token, clientID string) (string, error)

GetChannelID retrieves the channel ID for the OAuth token provided, and returns it as a string

func GetOAuthToken

func GetOAuthToken(clientID string) string

GetOAuthToken gets a User OAuth Token from the Twitch API and returns it as a string. This function needs further work: it is not fully automated, requiring user involvement (which also has an ugly UX)

func GetSongs

func GetSongs(a *Music, songsCollectionURL string) error

GetSongs populates the provided Music object with the song database found at the URL `songsCollectionURL`.

func InitSpeaker

func InitSpeaker() error

func ListenChannelPoints

func ListenChannelPoints(chanID, clientID, oauthToken string, callback func(TwitchRedemption))

ListenChannelPoints starts a WebSocket listening to the Twitch PubSub API for Channel Point redemptions, which calls callback with the provided file handle and the reward title as a string

func SelectSong

func SelectSong(artists *Music) (*Artist, *Album, *Song)

SelectSong asks the user for a song from the artists Music object, and returns pointers to the selected Artist, Album, and Song object within

func SynthesiseText

func SynthesiseText(t string) string

SynthesiseText uses the Google Cloud Text-to-Speech API to generate an MP3 audio file speaking the provided string t, and returns the file name of the created MP3 file. NB. this function requires that a valid Google API credential file is present and referred to by the 'GOOGLE_APPLICATION_CREDENTIALS' environment variable.

Types

type Album

type Album struct {
	Name  string `json:"name"`
	Songs []Song `json:"songs"`
}

Album is a structure storing the album name and a dynamic array of Song objects to represent the songs present on an album.

type Artist

type Artist struct {
	Artist     string  `json:"artist"`
	Albums     []Album `json:"albums"`
	TotalSongs int
}

Artist is a structure storing the artist name and a dynamic array of Album objects to represent the artist's albums.

type Music

type Music struct {
	Artists    []Artist `json:"artists"`
	TotalSongs int
}

Music is a structure storing a dynamic array within which to store the Artist objects, to be populated by parsing the JSON data file.

type Player

type Player struct {
	Playing bool
	// contains filtered or unexported fields
}

func NewPlayer

func NewPlayer() Player

func (*Player) AdjustVolume

func (p *Player) AdjustVolume(deltaVolume float64)

func (*Player) PlayFile

func (p *Player) PlayFile(fn string) error

func (*Player) Skip

func (p *Player) Skip() error

func (*Player) Stop

func (p *Player) Stop() error

func (*Player) TogglePause

func (p *Player) TogglePause()

type Song

type Song struct {
	Title string `json:"title"`
	URL   string `json:"url"`
}

Song is a structure storing the song title and YouTube URL of a song, both as a string.

type TwitchRedemption

type TwitchRedemption struct {
	ID         string       `json:"id"`
	User       twitchUser   `json:"user"`
	ChannelID  string       `json:"channel_id"`
	RedeemedAt time.Time    `json:"redeemed_at"`
	Reward     twitchReward `json:"reward"`
	UserInput  string       `json:"user_input"`
	Status     string       `json:"status"`
}

TwitchRedemption represents a Channel Point reward redemption on Twitch.

Jump to

Keyboard shortcuts

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