mirror of
https://github.com/gabehf/Koito.git
synced 2026-03-16 10:55:55 -07:00
Pre-release version v0.0.14 (#96)
* add dev branch container to workflow * correctly set the default range of ActivityGrid * fix: set name/short_name to koito (#61) * fix dev container push workflow * fix: race condition with using getComputedStyle primary color for dynamic activity grid darkening (#76) * Fix race condition with using getComputedStyle primary color for dynamic activity grid darkening Instead just use the color from the current theme directly. Tested works on initial load and theme changes. Fixes https://github.com/gabehf/Koito/issues/75 * Rework theme provider to provide the actual Theme object throughtout the app, in addition to the name Split name out of the Theme struct to simplify custom theme saving/reading * fix: set first artist listed as primary by default (#81) * feat: add server-side configuration with default theme (#90) * docs: add example for usage of the main listenbrainz instance (#71) * docs: add example for usage of the main listenbrainz instance * Update scrobbler.md --------- Co-authored-by: Gabe Farrell <90876006+gabehf@users.noreply.github.com> * feat: add server-side cfg and default theme * fix: repair custom theme --------- Co-authored-by: m0d3rnX <jesper@posteo.de> * docs: add default theme cfg option to docs * feat: add ability to manually scrobble track (#91) * feat: add button to manually scrobble from ui * fix: ensure timestamp is in the past, log fix * test: add integration test * feat: add first listened to dates for media items (#92) * fix: ensure error checks for ErrNoRows * feat: add now playing endpoint and ui (#93) * wip * feat: add now playing * fix: set default theme when config is not set * feat: fetch images from subsonic server (#94) * fix: useQuery instead of useEffect for now playing * feat: custom artist separator regex (#95) * Fix race condition with using getComputedStyle primary color for dynamic activity grid darkening Instead just use the color from the current theme directly. Tested works on initial load and theme changes. Fixes https://github.com/gabehf/Koito/issues/75 * Rework theme provider to provide the actual Theme object throughtout the app, in addition to the name Split name out of the Theme struct to simplify custom theme saving/reading * feat: add server-side configuration with default theme (#90) * docs: add example for usage of the main listenbrainz instance (#71) * docs: add example for usage of the main listenbrainz instance * Update scrobbler.md --------- Co-authored-by: Gabe Farrell <90876006+gabehf@users.noreply.github.com> * feat: add server-side cfg and default theme * fix: repair custom theme --------- Co-authored-by: m0d3rnX <jesper@posteo.de> * fix: rebase errors --------- Co-authored-by: pet <128837728+againstpetra@users.noreply.github.com> Co-authored-by: mlandry <mike.landry@gmail.com> Co-authored-by: m0d3rnX <jesper@posteo.de>
This commit is contained in:
parent
bf0ec68cfe
commit
36f984a1a2
56 changed files with 1887 additions and 906 deletions
|
|
@ -8,12 +8,14 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/gabehf/koito/internal/db"
|
||||
"github.com/gabehf/koito/internal/logger"
|
||||
"github.com/gabehf/koito/internal/mbz"
|
||||
"github.com/gabehf/koito/internal/memkv"
|
||||
"github.com/gabehf/koito/internal/models"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
|
@ -56,8 +58,9 @@ type SubmitListenOpts struct {
|
|||
ReleaseGroupMbzID uuid.UUID
|
||||
Time time.Time
|
||||
|
||||
UserID int32
|
||||
Client string
|
||||
UserID int32
|
||||
Client string
|
||||
IsNowPlaying bool
|
||||
}
|
||||
|
||||
const (
|
||||
|
|
@ -165,6 +168,14 @@ func SubmitListen(ctx context.Context, store db.DB, opts SubmitListenOpts) error
|
|||
}
|
||||
}
|
||||
|
||||
if opts.IsNowPlaying {
|
||||
if track.Duration == 0 {
|
||||
memkv.Store.Set(strconv.Itoa(int(opts.UserID)), track.ID)
|
||||
} else {
|
||||
memkv.Store.Set(strconv.Itoa(int(opts.UserID)), track.ID, time.Duration(track.Duration)*time.Second)
|
||||
}
|
||||
}
|
||||
|
||||
if opts.SkipSaveListen {
|
||||
return nil
|
||||
}
|
||||
|
|
@ -190,21 +201,18 @@ func buildArtistStr(artists []*models.Artist) string {
|
|||
var (
|
||||
// Bracketed feat patterns
|
||||
bracketFeatPatterns = []*regexp.Regexp{
|
||||
regexp.MustCompile(`(?i)\(feat\. ([^)]*)\)`),
|
||||
regexp.MustCompile(`(?i)\[feat\. ([^\]]*)\]`),
|
||||
regexp.MustCompile(`(?i)\([fF]eat\. ([^)]*)\)`),
|
||||
regexp.MustCompile(`(?i)\[[fF]eat\. ([^\]]*)\]`),
|
||||
}
|
||||
// Inline feat (not in brackets)
|
||||
inlineFeatPattern = regexp.MustCompile(`(?i)feat\. ([^()\[\]]+)$`)
|
||||
inlineFeatPattern = regexp.MustCompile(`(?i)[fF]eat\. ([^()\[\]]+)$`)
|
||||
|
||||
// Delimiters only used inside feat. sections
|
||||
featSplitDelimiters = regexp.MustCompile(`(?i)\s*(?:,|&|and|·)\s*`)
|
||||
|
||||
// Delimiter for separating artists in main string (rare but real usage)
|
||||
mainArtistDotSplitter = regexp.MustCompile(`\s+·\s+`)
|
||||
)
|
||||
|
||||
// ParseArtists extracts all contributing artist names from the artist and title strings
|
||||
func ParseArtists(artist string, title string) []string {
|
||||
func ParseArtists(artist string, title string, addlSeparators []*regexp.Regexp) []string {
|
||||
seen := make(map[string]struct{})
|
||||
var out []string
|
||||
|
||||
|
|
@ -219,12 +227,9 @@ func ParseArtists(artist string, title string) []string {
|
|||
}
|
||||
}
|
||||
|
||||
foundFeat := false
|
||||
|
||||
// Extract bracketed features from artist
|
||||
for _, re := range bracketFeatPatterns {
|
||||
if matches := re.FindStringSubmatch(artist); matches != nil {
|
||||
foundFeat = true
|
||||
artist = strings.Replace(artist, matches[0], "", 1)
|
||||
for _, name := range featSplitDelimiters.Split(matches[1], -1) {
|
||||
add(name)
|
||||
|
|
@ -233,7 +238,6 @@ func ParseArtists(artist string, title string) []string {
|
|||
}
|
||||
// Extract inline feat. from artist
|
||||
if matches := inlineFeatPattern.FindStringSubmatch(artist); matches != nil {
|
||||
foundFeat = true
|
||||
artist = strings.Replace(artist, matches[0], "", 1)
|
||||
for _, name := range featSplitDelimiters.Split(matches[1], -1) {
|
||||
add(name)
|
||||
|
|
@ -241,14 +245,19 @@ func ParseArtists(artist string, title string) []string {
|
|||
}
|
||||
|
||||
// Add base artist(s)
|
||||
if foundFeat {
|
||||
add(strings.TrimSpace(artist))
|
||||
} else {
|
||||
// Only split on " · " in base artist string
|
||||
for _, name := range mainArtistDotSplitter.Split(artist, -1) {
|
||||
l1 := len(out)
|
||||
for _, re := range addlSeparators {
|
||||
for _, name := range re.Split(artist, -1) {
|
||||
if name == artist {
|
||||
continue
|
||||
}
|
||||
add(name)
|
||||
}
|
||||
}
|
||||
// Only add the full artist string if no splitters were matched
|
||||
if l1 == len(out) {
|
||||
add(artist)
|
||||
}
|
||||
|
||||
// Extract features from title
|
||||
for _, re := range bracketFeatPatterns {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue