config

package
v0.0.0-...-843db3f Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const DirName = "your-loss"

DirName is the name of the configuration directory.

View Source
const FileName = "config.json"

FileName is the name of the configuration file.

Variables

View Source
var DefaultOutputProfiles = []*OutputProfile{
	{
		Name:         "{{profile.default.hq-mp3.name}}",
		OutputFormat: SupportedOutputFormats[0],
		Bitrate:      320000,
	},
	{
		Name:         "{{profile.default.flac.name}}",
		OutputFormat: SupportedOutputFormats[1],
		Bitrate:      0,
	},
	{
		Name:         "{{profile.default.wav.name}}",
		OutputFormat: SupportedOutputFormats[2],
		Bitrate:      0,
	},
	{
		Name:         "{{profile.default.hq-aac.name}}",
		OutputFormat: SupportedOutputFormats[4],
		Bitrate:      224000,
	},
	{
		Name:         "{{profile.default.alac.name}}",
		OutputFormat: SupportedOutputFormats[5],
		Bitrate:      0,
	},
}

DefaultOutputProfiles is a list of default output profiles. Names and descriptions are not literal; instead, they are filled in with translations.

View Source
var SupportedOutputFormats = map[int]OutputFormat{
	0: {
		IsLossless:       false,
		Name:             "MP3",
		Extension:        "mp3",
		FfmpegEncoder:    "libmp3lame",
		SupportsMetadata: true,
		SupportsArtwork:  true,
		SuggestedBitrate: 320000,
	},
	1: {
		IsLossless:       true,
		Name:             "FLAC",
		Extension:        "flac",
		FfmpegEncoder:    "flac",
		SupportsMetadata: true,
		SupportsArtwork:  true,
		SuggestedBitrate: 0,
	},
	2: {
		IsLossless:       true,
		Name:             "WAV",
		Extension:        "wav",
		FfmpegEncoder:    "pcm_s16le",
		SupportsMetadata: true,
		SupportsArtwork:  false,
		SuggestedBitrate: 0,
	},
	3: {
		IsLossless:       false,
		Name:             "Opus",
		Extension:        "opus",
		FfmpegEncoder:    "libopus",
		SupportsMetadata: true,
		SupportsArtwork:  false,
		SuggestedBitrate: 120000,
	},
	4: {
		IsLossless:       false,
		Name:             "AAC",
		Extension:        "m4a",
		FfmpegEncoder:    "aac",
		SupportsMetadata: true,
		SupportsArtwork:  true,
		SuggestedBitrate: 224000,
	},
	5: {
		IsLossless:       true,
		Name:             "ALAC",
		Extension:        "m4a",
		FfmpegEncoder:    "alac",
		SupportsMetadata: true,
		SupportsArtwork:  true,
		SuggestedBitrate: 0,
	},
	6: {
		IsLossless:       true,
		Name:             "AIFF",
		Extension:        "aif",
		FfmpegEncoder:    "pcm_s16be",
		SupportsMetadata: true,
		SupportsArtwork:  false,
		SuggestedBitrate: 0,
	},
}

SupportedOutputFormats is a mapping IDs to supported output formats. A map is used instead of a slice to allow for reordering or removal without changing IDs.

Functions

func GetDirPath

func GetDirPath() (string, error)

GetDirPath returns the path to the application's configuration directory. If the user's config directory can't be determined, an error will be returned.

func GetFilePath

func GetFilePath() (string, error)

GetFilePath returns the path to the application's configuration file.

Types

type Config

type Config struct {
	// The language code to use.
	LangCode string

	// All output profiles.
	Profiles []*OutputProfile

	// All sync configurations.
	Syncs []*SyncConfig
}

Config is the application configuration.

func CreateDefault

func CreateDefault(locale lang.Locale) *Config

CreateDefault creates a default configuration.

func (*Config) GetProfile

func (c *Config) GetProfile(name string) *OutputProfile

GetProfile returns the output profile with the specified name. If no profile with the specified name exists, nil will be returned.

func (*Config) GetProfileIndex

func (c *Config) GetProfileIndex(name string) int

GetProfileIndex returns the index of the profile with the specified name. If no profile with the specified name exists, -1 will be returned.

func (*Config) GetSync

func (c *Config) GetSync(name string) *SyncConfig

GetSync returns the sync with the specified name. If no sync with the specified name exists, nil will be returned.

func (*Config) GetSyncIndex

func (c *Config) GetSyncIndex(name string) int

GetSyncIndex returns the index of the sync with the specified name. If no sync with the specified name exists, -1 will be returned.

type OutputFormat

type OutputFormat struct {
	// Whether the format is lossless.
	IsLossless bool

	// The format name.
	Name string

	// The format's file extension.
	Extension string

	// The name of the FFmpeg encoder used to convert to the format.
	FfmpegEncoder string

	// Whether the container used by the format supports metadata.
	SupportsMetadata bool

	// Whether the container used by the format supports artwork.
	SupportsArtwork bool

	// The suggested bitrate for the format.
	// Does not apply to lossless formats.
	// Should be a multiple of 1000.
	SuggestedBitrate uint
}

OutputFormat is an output format.

func GetOutputFormat

func GetOutputFormat(name string) *OutputFormat

GetOutputFormat returns the output format with the specified name. If no format with the specified name exists, nil will be returned.

func (OutputFormat) GetId

func (f OutputFormat) GetId() (int, bool)

GetId returns the ID of the format. If the format is not in the supported formats map, the ID will be 0 and false will be returned.

type OutputProfile

type OutputProfile struct {
	// The profile name.
	// Names are expected to be unique and treated as primary keys.
	Name string

	// The output format.
	OutputFormat OutputFormat

	// The bitrate to use for the output format.
	// Only applies to lossy formats.
	// Should be a multiple of 1000.
	Bitrate uint
}

OutputProfile is an output encoding profile.

type SyncConfig

type SyncConfig struct {
	// The sync's name.
	Name string

	// The source directory to sync from.
	SourceDir string

	// The destination directory to sync to.
	DestDir string

	// The output profile to use.
	Profile *OutputProfile

	// Whether to escape filenames.
	// Default: true
	EscapeFilenames bool

	// Whether to reencode files with the same format.
	// Default: false
	ReencodeSameFormat bool
}

SyncConfig is the configuration for a sync.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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