chipmusic

package
v0.0.0-...-baf3de5 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultBaseURL is redundantly the base URL of the chipmusic.org
	DefaultBaseURL = "https://chipmusic.org"

	DefaultWorkers = 40

	// AudioFileTypeMP3 is the expected extension for an MP3 audio file
	AudioFileTypeMP3 AudioFileType = "mp3"

	// TrackFilterNone does not filter for any particular track; instead, it returns the most recently posted tracks
	TrackFilterLatest = "latest"

	// TrackFilterRandom filters for random tracks
	TrackFilterRandom = "random"

	// TrackFilterFeatured filters for featured tracks
	TrackFilterFeatured = "featured"

	// TrackFilterFeatured filters for tracks with high ratings
	TrackFilterHighRatings = "popular"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AudioFileType

type AudioFileType string

AudioFileType is an enumeration of possible audio file types

type Client

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

Client is a struct capable of interacting with chipmusic.org

func NewClient

func NewClient(options ...Option) (*Client, error)

NewClient creates a new Client object that is configured with a list of Options

func (*Client) GetTrack

func (c *Client) GetTrack(ctx context.Context, trackPageURL string) (*Track, error)

GetTrack takes a URL to a track page for chipmusic.org and returns a Track. The returned struct contains metadata about the track and a reader which can be used to download the track itself for playback. Use FileType in the Track to determine how to use the the content returned from the reader

func (*Client) Search

func (c *Client) Search(ctx context.Context, search, filter string, page int) ([]string, error)

Search performs a search against chipmusic.org, returning a list of URLs to tracks which match. If a search returns more tracks than can be returned in a single call, you can use the page parameter to paginate through the additional tracks. To iterate through all tracks for a particular search, start with page = 1 and increment it for subsequent calls. The order of the tracks returned is undefined. If no tracks are found or there are no other tracks, an empty slice is returned

type Option

type Option func(*Client) error

Option is an alias for a function that modifies a Client. An Option is used to override the default values of Client

func WithBaseURL

func WithBaseURL(baseURL string) Option

WithBaseURL allows overriding the base URL for chipmusic.org

func WithHTTPClient

func WithHTTPClient(client *http.Client) Option

WithHTTPClient allows overriding the default HTTP client used to make requests

func WithWorkers

func WithWorkers(workers int) Option

WithWorkers allows overriding the default number fo workers used to download a file

type ReadSeekCloser

type ReadSeekCloser interface {
	io.ReadSeeker
	io.Closer
}

ReadSeekCloser is an interface combining the capabilities of ReaderSeeker and Closer. The beep library

type ReadSeekNopCloser

type ReadSeekNopCloser struct {
	Reader io.ReadSeeker
}

ReadSeekNopCloser is an implementation of ReadSeekCloser which is able to read and seek but closing the reader doesn't actually do anything

func (*ReadSeekNopCloser) Close

func (r *ReadSeekNopCloser) Close() error

func (*ReadSeekNopCloser) Read

func (r *ReadSeekNopCloser) Read(p []byte) (n int, err error)

func (*ReadSeekNopCloser) Seek

func (r *ReadSeekNopCloser) Seek(offset int64, whence int) (int64, error)

type Track

type Track struct {

	// Title is the name of the track
	Title string

	// Artist is the name of the author who composed the track
	Artist string

	// Reader reads the body of the track. It is also able to seek to any point within the track
	Reader ReadSeekCloser

	// FileType represents the type of audio file for this track. This should be used to determine how to interpret and
	// play the content returned from Reader
	FileType AudioFileType
}

Track is song from chipmusic.org. It contains metadata related to the song along with a reader of the track itself

func (*Track) Close

func (t *Track) Close() error

Jump to

Keyboard shortcuts

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