client

package
v0.0.0-...-15592ba Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2023 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package client continues functionality shared across client binaries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadConfig

func LoadConfig(p string, dst *Config) error

LoadConfig loads a JSON-marshaled Config from the file at p and updates dst.

Types

type Config

type Config struct {
	// ServerURL contains the App Engine server URL.
	ServerURL string `json:"serverUrl"`
	// Username contains an HTTP basic auth username.
	Username string `json:"username"`
	// Password contains an HTTP basic auth password.
	Password string `json:"password"`

	// CoverDir is the base directory containing cover art.
	CoverDir string `json:"coverDir"`
	// MusicDir is the base directory containing song files.
	MusicDir string `json:"musicDir"`
	// MetadataDir is the base directory containing JSON files that override song metadata.
	// $HOME/.nup/metadata will be used by default.
	MetadataDir string `json:"metadataDir"`
	// LastUpdateInfoFile is the path to a JSON file storing info about the last update.
	// The file will be created if it does not already exist.
	// $HOME/.nup/last_update_info.json will be used by default.
	LastUpdateInfoFile string `json:"lastUpdateInfoFile"`
	// ComputeGain indicates whether the mp3gain program should be used to compute per-song
	// and per-album gain information so that volume can be normalized during playback.
	ComputeGain bool `json:"computeGain"`
	// ArtistRewrites maps from original ID3 tag artist names to replacement names that should
	// be used for updates. This can be used to fix incorrectly-tagged files without needing to
	// reupload them.
	ArtistRewrites map[string]string `json:"artistRewrites"`
	// AlbumIDRewrites maps from original ID3 tag album IDs (i.e. MusicBrainz UUIDs) to
	// replacement IDs that should be used for updates. If the album name ends with the suffix
	// " (disc [number])", the suffix will be removed and the song's disc number will be set
	// accordingly. This can be used to fix split releases without needing to retag and reupload
	// them.
	AlbumIDRewrites map[string]string `json:"albumIdRewrites"`
}

Config holds configuration details for the nup client executable.

func (*Config) GetURL

func (cfg *Config) GetURL(path string) *url.URL

GetURL appends path to ServerURL. Query params should not be included.

func (*Config) ProjectID

func (cfg *Config) ProjectID() (string, error)

ProjectID returns the GCP project ID as derived from cfg.ServerURL.

type Task

type Task func() (map[string]interface{}, error)

Task produces one or more key-value pairs.

type TaskCache

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

TaskCache runs tasks that each produce one or more key-value pairs.

func NewTaskCache

func NewTaskCache(maxTasks int) *TaskCache

NewTaskCache returns a TaskCache that will run up to maxTasks simultaneous tasks.

func (*TaskCache) Get

func (c *TaskCache) Get(itemKey, taskKey string, task Task) (interface{}, error)

Get returns the item with the supplied key from the cache. If the item is not already in the cache, task will be executed (if another task with the same task key is not already running) and the resulting items will be saved to the cache.

func (*TaskCache) GetIfExists

func (c *TaskCache) GetIfExists(itemKey string) (interface{}, bool)

GetIfExists returns the item with the supplied key only if it's already been computed.

func (*TaskCache) Size

func (c *TaskCache) Size() int

Size returns the number of cached values.

Directories

Path Synopsis
Package files contains client code for reading song files.
Package files contains client code for reading song files.

Jump to

Keyboard shortcuts

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