export

package
v0.1.44 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2026 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package export provides functionality for exporting music to external devices.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BatchCmd

func BatchCmd(params Params) tea.Cmd

BatchCmd starts the export and returns commands for progress updates.

func ContinueExportCmd

func ContinueExportCmd(params Params, nextIndex int) tea.Cmd

ContinueExportCmd returns a command to export the next file.

func GenerateExportPath

func GenerateExportPath(t TrackInfo, structure FolderStructure) string

GenerateExportPath creates the relative path for an exported track.

func NeedsConversion

func NeedsConversion(ext string) bool

NeedsConversion returns true if the file extension requires conversion.

Types

type CompleteMsg

type CompleteMsg struct {
	JobID      string
	Artist     string
	Album      string
	TargetName string
	Failed     int
	Total      int
	Errors     []TrackError
}

CompleteMsg signals the export finished.

type Exporter

type Exporter struct{}

Exporter handles copying and converting files for export.

func NewExporter

func NewExporter() *Exporter

NewExporter creates a new Exporter.

func (*Exporter) ConvertToMP3

func (e *Exporter) ConvertToMP3(src, dst string) error

ConvertToMP3 converts a FLAC file to MP3 using ffmpeg. Uses 320kbps CBR preset.

func (*Exporter) CopyFile

func (e *Exporter) CopyFile(src, dst string) error

CopyFile copies a file from src to dst. Creates parent directories if needed. Skips if destination already exists.

func (*Exporter) ExportFile

func (e *Exporter) ExportFile(src, dst string, convert bool) error

ExportFile exports a single track, converting if needed.

type FileExportedMsg

type FileExportedMsg struct {
	JobID   string
	Current int
	Track   Track
	Err     error
}

FileExportedMsg reports progress on a single file.

type FolderStructure

type FolderStructure string

FolderStructure defines how exported files are organized.

const (
	FolderStructureFlat         FolderStructure = "flat"         // Artist - Album/01 - Track.mp3
	FolderStructureHierarchical FolderStructure = "hierarchical" // Artist/Album/01 - Track.mp3
	FolderStructureSingle       FolderStructure = "single"       // Artist - Album - 01 - Track.mp3
)

type Job

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

Job tracks the progress of an export operation.

func NewJob

func NewJob(target Target, tracks []Track) *Job

NewJob creates a new export job.

func (*Job) Cancel

func (j *Job) Cancel()

Cancel marks the job as canceled.

func (*Job) Complete

func (j *Job) Complete()

Complete marks the job as done.

func (*Job) Errors

func (j *Job) Errors() []TrackError

Errors returns all export errors.

func (*Job) IsCanceled

func (j *Job) IsCanceled() bool

IsCanceled returns true if the job was canceled.

func (*Job) JobBar

func (j *Job) JobBar() *jobbar.Job

JobBar returns the jobbar.Job for display.

func (*Job) Progress

func (j *Job) Progress(current int)

Progress updates job progress.

func (*Job) RecordError

func (j *Job) RecordError(track Track, err error)

RecordError records a failed export.

func (*Job) Target

func (j *Job) Target() Target

Target returns the export target.

func (*Job) Tracks

func (j *Job) Tracks() []Track

Tracks returns the tracks to export.

type Params

type Params struct {
	Job         *Job
	Exporter    *Exporter
	ConvertFLAC bool
	BasePath    string
}

Params contains parameters for the export command.

type ProgressMsg

type ProgressMsg struct {
	JobID   string
	Current int
	Total   int
}

ProgressMsg reports export progress for UI updates.

type StartExportMsg

type StartExportMsg struct {
	Target      Target
	Tracks      []Track
	ConvertFLAC bool
	MountPath   string
}

StartExportMsg initiates an export operation.

type Target

type Target struct {
	ID              int64
	Name            string
	DeviceUUID      string
	DeviceLabel     string
	Subfolder       string
	FolderStructure FolderStructure
	CreatedAt       int64
}

Target represents a saved export destination.

type TargetRepository

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

TargetRepository handles persistence of export targets.

func NewTargetRepository

func NewTargetRepository(db *sql.DB) *TargetRepository

NewTargetRepository creates a new repository.

func (*TargetRepository) Create

func (r *TargetRepository) Create(t Target) (int64, error)

Create adds a new target and returns its ID.

func (*TargetRepository) Delete

func (r *TargetRepository) Delete(id int64) error

Delete removes a target.

func (*TargetRepository) FindByUUID

func (r *TargetRepository) FindByUUID(uuid string) ([]Target, error)

FindByUUID returns the targets matching a device UUID.

func (*TargetRepository) Get

func (r *TargetRepository) Get(id int64) (Target, error)

Get returns a target by ID.

func (*TargetRepository) List

func (r *TargetRepository) List() ([]Target, error)

List returns all saved targets.

func (*TargetRepository) Update

func (r *TargetRepository) Update(t Target) error

Update modifies an existing target.

type Track

type Track struct {
	ID        int64
	SrcPath   string
	Artist    string
	Album     string
	Title     string
	TrackNum  int
	DiscNum   int
	DiscTotal int
	Extension string
}

Track contains info needed to export a single track.

type TrackError

type TrackError struct {
	Track Track
	Err   error
}

TrackError records a failed export.

type TrackInfo

type TrackInfo struct {
	Artist      string
	Album       string
	Title       string
	TrackNumber int
	DiscNumber  int
	TotalDiscs  int
	Extension   string // e.g., ".flac", ".mp3"
}

TrackInfo contains metadata needed for export path generation.

type Volume

type Volume struct {
	Label     string
	UUID      string
	MountPath string
	Device    string
}

Volume represents a mounted removable device.

func DetectVolumes

func DetectVolumes() ([]Volume, error)

DetectVolumes scans for mounted USB devices.

func (Volume) String

func (v Volume) String() string

String returns a display string for the volume.

Jump to

Keyboard shortcuts

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