mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-03 20:47:35 +03:00
Refactor string utilities into its own package str
This commit is contained in:
parent
46fc38bf61
commit
abe5690018
16 changed files with 158 additions and 125 deletions
|
@ -8,7 +8,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/navidrome/navidrome/log"
|
||||
"github.com/navidrome/navidrome/utils"
|
||||
"github.com/navidrome/navidrome/utils/str"
|
||||
)
|
||||
|
||||
type Line struct {
|
||||
|
@ -36,7 +36,7 @@ var (
|
|||
)
|
||||
|
||||
func ToLyrics(language, text string) (*Lyrics, error) {
|
||||
text = utils.SanitizeText(text)
|
||||
text = str.SanitizeText(text)
|
||||
|
||||
lines := strings.Split(text, "\n")
|
||||
|
||||
|
@ -67,7 +67,7 @@ func ToLyrics(language, text string) (*Lyrics, error) {
|
|||
if idTag != nil {
|
||||
switch idTag[1] {
|
||||
case "ar":
|
||||
artist = utils.SanitizeText(strings.TrimSpace(idTag[2]))
|
||||
artist = str.SanitizeText(strings.TrimSpace(idTag[2]))
|
||||
case "offset":
|
||||
{
|
||||
off, err := strconv.ParseInt(strings.TrimSpace(idTag[2]), 10, 64)
|
||||
|
@ -78,7 +78,7 @@ func ToLyrics(language, text string) (*Lyrics, error) {
|
|||
}
|
||||
}
|
||||
case "ti":
|
||||
title = utils.SanitizeText(strings.TrimSpace(idTag[2]))
|
||||
title = str.SanitizeText(strings.TrimSpace(idTag[2]))
|
||||
}
|
||||
|
||||
continue
|
||||
|
|
|
@ -12,8 +12,8 @@ import (
|
|||
|
||||
"github.com/navidrome/navidrome/conf"
|
||||
"github.com/navidrome/navidrome/consts"
|
||||
"github.com/navidrome/navidrome/utils"
|
||||
"github.com/navidrome/navidrome/utils/slice"
|
||||
"github.com/navidrome/navidrome/utils/str"
|
||||
)
|
||||
|
||||
type MediaFile struct {
|
||||
|
@ -187,7 +187,7 @@ func (mfs MediaFiles) ToAlbum() Album {
|
|||
a.Genre = slice.MostFrequent(a.Genres).Name
|
||||
slices.SortFunc(a.Genres, func(a, b Genre) int { return cmp.Compare(a.ID, b.ID) })
|
||||
a.Genres = slices.Compact(a.Genres)
|
||||
a.FullText = " " + utils.SanitizeStrings(fullText...)
|
||||
a.FullText = " " + str.SanitizeStrings(fullText...)
|
||||
a = fixAlbumArtist(a, albumArtistIds)
|
||||
songArtistIds = append(songArtistIds, a.AlbumArtistID, a.ArtistID)
|
||||
slices.Sort(songArtistIds)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue