mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-07-30 15:58:51 +02:00
Pure mechanical move within package gobackend — no signature or behavior
change, so the gomobile binding surface is identical. exports.go (4,141
lines) now holds only availability/dir/duplicate/filename exports; the
rest moved to exports_{musicbrainz,download,reenrich,metadata,lyrics,
deezer,extensions,store,library}.go along existing responsibility
boundaries.
80 lines
1.7 KiB
Go
80 lines
1.7 KiB
Go
package gobackend
|
|
|
|
import (
|
|
"encoding/json"
|
|
"strings"
|
|
)
|
|
|
|
func CheckAvailability(spotifyID, isrc string) (string, error) {
|
|
client := NewSongLinkClient()
|
|
availability, err := client.CheckTrackAvailability(spotifyID, isrc)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
|
|
jsonBytes, err := json.Marshal(availability)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
|
|
return string(jsonBytes), nil
|
|
}
|
|
|
|
// SetSongLinkNetworkOptions is kept for backward compatibility.
|
|
func SetSongLinkNetworkOptions(allowHTTP, insecureTLS bool) {
|
|
SetNetworkCompatibilityOptions(allowHTTP, insecureTLS)
|
|
}
|
|
|
|
func SetDownloadDirectory(path string) error {
|
|
return setDownloadDir(path)
|
|
}
|
|
|
|
func AllowDownloadDir(path string) {
|
|
if strings.TrimSpace(path) == "" {
|
|
return
|
|
}
|
|
AddAllowedDownloadDir(path)
|
|
}
|
|
|
|
func CheckDuplicate(outputDir, isrc string) (string, error) {
|
|
existingFile, exists := CheckISRCExists(outputDir, isrc)
|
|
|
|
result := map[string]interface{}{
|
|
"exists": exists,
|
|
"filepath": existingFile,
|
|
}
|
|
|
|
jsonBytes, err := json.Marshal(result)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
|
|
return string(jsonBytes), nil
|
|
}
|
|
|
|
func CheckDuplicatesBatch(outputDir, tracksJSON string) (string, error) {
|
|
return CheckFilesExistParallel(outputDir, tracksJSON)
|
|
}
|
|
|
|
func PreBuildDuplicateIndex(outputDir string) error {
|
|
return PreBuildISRCIndex(outputDir)
|
|
}
|
|
|
|
func InvalidateDuplicateIndex(outputDir string) {
|
|
InvalidateISRCCache(outputDir)
|
|
}
|
|
|
|
func BuildFilename(template string, metadataJSON string) (string, error) {
|
|
var metadata map[string]interface{}
|
|
if err := json.Unmarshal([]byte(metadataJSON), &metadata); err != nil {
|
|
return "", err
|
|
}
|
|
|
|
filename := buildFilenameFromTemplate(template, metadata)
|
|
return filename, nil
|
|
}
|
|
|
|
func SanitizeFilename(filename string) string {
|
|
return sanitizeFilename(filename)
|
|
}
|