goacnh

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2022 License: GPL-3.0 Imports: 6 Imported by: 0

README

AC:NH API Client

Use the AC:NH API from Go!


Supported Functions

  • K.K.Slider Songs: Search for and download K.K.Slider songs
  • Background Music: Search for and download BGM via hour, weather or both

package main

import (
  acnh "github.com/willfantom/go-acnh"
)

const (
  downloadDir string = "~/Downloads"
)

func main() {
  client := acnh.New()

  allBGM, _ := client.BGMList()

  for _, track := range allBGM {
    client.BGMDownload(track, downloadDir)
  }
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BGMTrack

type BGMTrack struct {
	ID       int     `json:"id"`
	FileName string  `json:"file-name"`
	Hour     int     `json:"hour"`
	Weather  Weather `json:"weather"`
}

BGMTrack represents a track that is played in the background of AC:NH under specified time and weather conditions.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client facilitates interaction with the AC:NH API

func New

func New() *Client

New creates a new instance of the AC:NH API client

func (*Client) BGMDownload

func (c *Client) BGMDownload(track *BGMTrack, downloadDirectory string) (string, error)

BGMDownload downloads the given track as an MP3 file to a given directory. The file name of the download is that specified as the file name by the API. The given download dir must exist before calling this. Returned is the file path of the download song, provided there was no error.

func (*Client) BGMDownloadTemp

func (c *Client) BGMDownloadTemp(track *BGMTrack) (string, error)

BGMDownloadTemp downloads the given track as an MP3 file to a temp directory. Th file name of the download is that specified as the file name by the API. Returned is the file path of the download song, provided there was no error.

func (*Client) BGMList

func (c *Client) BGMList() ([]*BGMTrack, error)

BGMList returns all the background music tracks that the API provides. An error is returned if the request failed or a non 200 error code was returned.

func (*Client) BGMListByHour

func (c *Client) BGMListByHour(hour int) ([]*BGMTrack, error)

BGMListByHour gets all the background music tracks that can be played in a given hour, regardless of the weather. An error is returned if the request failed or a non 200 error code was returned or no match was found.

func (*Client) BGMListByWeather

func (c *Client) BGMListByWeather(weather Weather) ([]*BGMTrack, error)

BGMListByWeather gets all the background music tracks that can be played in a given weather condition, regardless of the time. An error is returned if the request failed or a non 200 error code was returned or no match was found.

func (*Client) BGMTrackByID

func (c *Client) BGMTrackByID(id int) (*BGMTrack, error)

BGMTrackByID gets a single background music track based on the ID provided. An error is returned if the request failed or a non 200 error code was returned.

func (*Client) BGMTrackByQuery

func (c *Client) BGMTrackByQuery(hour int, weather Weather) (*BGMTrack, error)

BGMTrackByQuery gets the background music track that can be played in a given weather condition, at a specified hour. An error is returned if the request failed or a non 200 error code was returned or no match was found.

func (*Client) SongByID

func (c *Client) SongByID(id int) (*Song, error)

SongByID gets a single song based on the ID provided. An error is returned if the request failed or a non 200 error code was returned.

func (*Client) SongByName

func (c *Client) SongByName(name string) (*Song, error)

SongByName get a song based on its name. It is important to note that language of the name is set to EUen. An error is returned if the request failed or a non 200 error code was returned or no match was found.

func (*Client) SongDownload

func (c *Client) SongDownload(song *Song, downloadDirectory string) (string, error)

SongDownload downloads the given track as an MP3 file to a given directory. The file name of the download is that specified as the file name by the API. The given download dir must exist before calling this. Returned is the file path of the download song, provided there was no error.

func (*Client) SongDownloadTemp

func (c *Client) SongDownloadTemp(song *Song) (string, error)

SongDownload downloads the given track as an MP3 file to a temp directory. Th file name of the download is that specified as the file name by the API. Returned is the file path of the download song, provided there was no error.

func (*Client) SongList

func (c *Client) SongList() ([]*Song, error)

SongList returns all the songs that the API provides. An error is returned if the request failed or a non 200 error code was returned.

type Song

type Song struct {
	ID       int               `json:"id"`
	FileName string            `json:"file-name"`
	Name     map[string]string `json:"name"`
}

Song represents a K.K.Slider song as represented via the API

type Weather

type Weather string

Weather is a weather condition that can be experienced in AC:NH

const (
	SunnyWeather Weather = "Sunny"
	RainyWeather Weather = "Rainy"
	SnowyWeather Weather = "Snowy"
)

Jump to

Keyboard shortcuts

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