Files
MusicServer/internal/backend/characters.go
Sebastian 806e88adeb
All checks were successful
Build / build (push) Successful in 2m35s
#1 - Created request to check newest version of the app
#2 - Added request to download the newest version of the app
#3 - Added request to check progress during sync
#4 - Now blocking all request while sync is in progress
#5 - Implemented ants for thread pooling
#6 - Changed the sync request to now only start the sync
2025-08-23 11:36:03 +02:00

34 lines
684 B
Go

package backend
import (
"log"
"os"
"strings"
)
func GetCharacters() []string {
charactersPath := os.Getenv("CHARACTERS_PATH")
files, err := os.ReadDir(charactersPath)
if err != nil {
log.Fatal(err)
}
var characters []string
for _, file := range files {
if isImage(file) {
characters = append(characters, file.Name())
}
}
return characters
}
func GetCharacter(character string) string {
musicPath := os.Getenv("MUSIC_PATH")
charactersPath := musicPath + "characters/"
return charactersPath + character
}
func isImage(entry os.DirEntry) bool {
return !entry.IsDir() && (strings.HasSuffix(entry.Name(), ".jpg") || strings.HasSuffix(entry.Name(), ".png"))
}