Documentation
¶
Overview ¶
Copyright © 2023-2025 Philipp Wolfer <[email protected]>
This file is part of Scotty.
Scotty is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
Scotty is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Scotty. If not, see <https://www.gnu.org/licenses/>.
Copyright © 2023-2025 Philipp Wolfer <[email protected]>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Index ¶
- func IterExportProgress[T any](items []T, t *TransferProgress, c chan TransferProgress) iter.Seq2[int, T]
- func IterImportProgress[T any](items []T, t *TransferProgress, c chan TransferProgress) iter.Seq2[int, T]
- type AdditionalInfo
- type Backend
- type BackendOption
- type Entity
- type ExportResult
- type ImportBackend
- type ImportResult
- type JSONLFile
- type Listen
- type ListensExport
- type ListensImport
- type ListensList
- type ListensResult
- type LogEntry
- type LogEntryType
- type Love
- type LovesExport
- type LovesImport
- type LovesList
- type LovesResult
- type OptionType
- type Progress
- type Track
- type TransferProgress
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IterExportProgress ¶ added in v0.6.0
func IterExportProgress[T any]( items []T, t *TransferProgress, c chan TransferProgress, ) iter.Seq2[int, T]
func IterImportProgress ¶ added in v0.6.0
func IterImportProgress[T any]( items []T, t *TransferProgress, c chan TransferProgress, ) iter.Seq2[int, T]
Types ¶
type AdditionalInfo ¶
type Backend ¶
type Backend interface {
// Return the name of the interface
Name() string
// Initialize the backend from a config.
InitConfig(config *config.ServiceConfig) error
// Return configuration options
Options() []BackendOption
// Free all resources of the backend
Close()
}
A listen service backend. All listen services must implement this interface.
type BackendOption ¶ added in v0.3.0
type ExportResult ¶ added in v0.3.0
type ImportBackend ¶
type ImportBackend interface {
Backend
// If the backend needs to setup resources before starting to import,
// this can be done here.
StartImport() error
// The implementation can perform all steps here to finalize the
// export/import and free used resources.
FinishImport(result *ImportResult) error
}
type ImportResult ¶
type ImportResult struct {
TotalCount int
ImportCount int
LastTimestamp time.Time
ImportLog []LogEntry
// Error is only set if an unrecoverable import error occurred
Error error
}
func (*ImportResult) Copy ¶ added in v0.7.0
func (i *ImportResult) Copy() ImportResult
func (*ImportResult) Log ¶ added in v0.4.0
func (i *ImportResult) Log(t LogEntryType, msg string)
func (*ImportResult) Update ¶
func (i *ImportResult) Update(from *ImportResult)
func (*ImportResult) UpdateTimestamp ¶
func (i *ImportResult) UpdateTimestamp(newTime time.Time)
Sets LastTimestamp to newTime, if newTime is newer than LastTimestamp
type JSONLFile ¶ added in v0.7.0
type JSONLFile[T any] struct { File archive.OpenableFile }
type ListensExport ¶
type ListensExport interface {
Backend
// Returns a list of all listens newer then oldestTimestamp.
// The returned list of listens is supposed to be ordered by the
// Listen.ListenedAt timestamp, with the oldest entry first.
ExportListens(ctx context.Context, oldestTimestamp time.Time, results chan ListensResult, progress chan TransferProgress)
}
Must be implemented by services supporting the export of listens.
type ListensImport ¶
type ListensImport interface {
ImportBackend
// Imports the given list of listens.
ImportListens(ctx context.Context, export ListensResult, importResult ImportResult, progress chan TransferProgress) (ImportResult, error)
}
Must be implemented by services supporting the import of listens.
type ListensList ¶
type ListensList []Listen
func (ListensList) Len ¶
func (l ListensList) Len() int
func (ListensList) Less ¶
func (l ListensList) Less(i, j int) bool
func (ListensList) NewerThan ¶
func (l ListensList) NewerThan(t time.Time) ListensList
Returns a new ListensList with only elements that are newer than t.
func (ListensList) Swap ¶
func (l ListensList) Swap(i, j int)
type ListensResult ¶
type ListensResult ExportResult[ListensList]
type LogEntry ¶ added in v0.4.0
type LogEntry struct {
Type LogEntryType
Message string
}
type LogEntryType ¶ added in v0.4.0
type LogEntryType string
const ( Output LogEntryType = "" Info LogEntryType = "Info" Warning LogEntryType = "Warning" Error LogEntryType = "Error" )
type LovesExport ¶
type LovesExport interface {
Backend
// Returns a list of all loves newer then oldestTimestamp.
// The returned list of listens is supposed to be ordered by the
// Love.Created timestamp, with the oldest entry first.
ExportLoves(ctx context.Context, oldestTimestamp time.Time, results chan LovesResult, progress chan TransferProgress)
}
Must be implemented by services supporting the export of loves.
type LovesImport ¶
type LovesImport interface {
ImportBackend
// Imports the given list of loves.
ImportLoves(ctx context.Context, export LovesResult, importResult ImportResult, progress chan TransferProgress) (ImportResult, error)
}
Must be implemented by services supporting the import of loves.
type LovesResult ¶
type LovesResult ExportResult[LovesList]
type OptionType ¶ added in v0.3.0
type OptionType string
const ( Bool OptionType = "bool" Secret OptionType = "secret" String OptionType = "string" Int OptionType = "int" )
type Progress ¶
func (Progress) FromImportResult ¶
func (p Progress) FromImportResult(result ImportResult) Progress
type Track ¶
type Track struct {
TrackName string
ReleaseName string
ArtistNames []string
TrackNumber int
DiscNumber int
Duration time.Duration
ISRC mbtypes.ISRC
RecordingMBID mbtypes.MBID
ReleaseMBID mbtypes.MBID
ReleaseGroupMBID mbtypes.MBID
ArtistMBIDs []mbtypes.MBID
WorkMBIDs []mbtypes.MBID
Tags []string
AdditionalInfo AdditionalInfo
}
func (Track) ArtistName ¶
func (*Track) FillAdditionalInfo ¶
func (t *Track) FillAdditionalInfo()
Updates AdditionalInfo to have standard fields as defined by ListenBrainz
type TransferProgress ¶ added in v0.6.0
func (TransferProgress) FromImportResult ¶ added in v0.6.0
func (p TransferProgress) FromImportResult(result ImportResult, completed bool) TransferProgress