mirror of
https://github.com/navidrome/navidrome.git
synced 2025-05-08 22:31:07 +03:00
fix beets address and add is_duplicate field. (#2)
* fix beet address * add is_duplicate to sql db. Set if the 'dup' tag of the media file is set.
This commit is contained in:
parent
bfd9449494
commit
8aaba56f0d
25
db/migrations/20241209172239_duplicate.go
Normal file
25
db/migrations/20241209172239_duplicate.go
Normal file
@ -0,0 +1,25 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"github.com/pressly/goose/v3"
|
||||
)
|
||||
|
||||
func init() {
|
||||
goose.AddMigrationContext(upDuplicate, downDuplicate)
|
||||
}
|
||||
|
||||
func upDuplicate(ctx context.Context, tx *sql.Tx) error {
|
||||
_, err := tx.Exec(`
|
||||
alter table media_file
|
||||
add is_duplicate bool not null default false;
|
||||
|
||||
`)
|
||||
return err
|
||||
}
|
||||
|
||||
func downDuplicate(ctx context.Context, tx *sql.Tx) error {
|
||||
// This code is executed when the migration is rolled back.
|
||||
return nil
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
version: '3.4'
|
||||
services:
|
||||
navidrome:
|
||||
image: navidrome:latest
|
||||
image: laker93/neodrome:latest
|
||||
restart: unless-stopped
|
||||
container_name: "${NAME}"
|
||||
user: "501:20"
|
||||
|
@ -12,6 +12,7 @@ var fieldMap = map[string]*mappedField{
|
||||
"artist": {field: "media_file.artist"},
|
||||
"albumartist": {field: "media_file.album_artist"},
|
||||
"hascoverart": {field: "media_file.has_cover_art"},
|
||||
"isduplicate": {field: "media_file.is_duplicate"},
|
||||
"tracknumber": {field: "media_file.track_number"},
|
||||
"discnumber": {field: "media_file.disc_number"},
|
||||
"year": {field: "media_file.year"},
|
||||
|
@ -31,6 +31,7 @@ type MediaFile struct {
|
||||
AlbumArtist string `structs:"album_artist" json:"albumArtist"`
|
||||
AlbumID string `structs:"album_id" json:"albumId"`
|
||||
HasCoverArt bool `structs:"has_cover_art" json:"hasCoverArt"`
|
||||
IsDuplicate bool `structs:"is_duplicate" json:"isDuplicate"`
|
||||
TrackNumber int `structs:"track_number" json:"trackNumber"`
|
||||
DiscNumber int `structs:"disc_number" json:"discNumber"`
|
||||
DiscSubtitle string `structs:"disc_subtitle" json:"discSubtitle,omitempty"`
|
||||
|
@ -29,6 +29,8 @@ func NewMediaFileRepository(ctx context.Context, db dbx.Builder) *mediaFileRepos
|
||||
"title": fullTextFilter,
|
||||
"starred": booleanFilter,
|
||||
"genre_id": eqFilter,
|
||||
"is_duplicate": booleanFilter,
|
||||
"isduplicate": booleanFilter,
|
||||
})
|
||||
r.setSortMappings(map[string]string{
|
||||
"title": "order_title",
|
||||
|
@ -52,6 +52,7 @@ func (s MediaFileMapper) ToMediaFile(md metadata.Tags) model.MediaFile {
|
||||
mf.Suffix = md.Suffix()
|
||||
mf.Size = md.Size()
|
||||
mf.HasCoverArt = md.HasPicture()
|
||||
mf.IsDuplicate = md.IsDuplicate()
|
||||
mf.SortTitle = md.SortTitle()
|
||||
mf.SortAlbumName = md.SortAlbum()
|
||||
mf.SortArtistName = md.SortArtist()
|
||||
|
@ -148,6 +148,7 @@ func (t Tags) DiscSubtitle() string {
|
||||
func (t Tags) CatalogNum() string { return t.getFirstTagValue("catalognumber") }
|
||||
func (t Tags) Bpm() int { return (int)(math.Round(t.getFloat("tbpm", "bpm", "fbpm"))) }
|
||||
func (t Tags) HasPicture() bool { return t.getFirstTagValue("has_picture") != "" }
|
||||
func (t Tags) IsDuplicate() bool { return t.getFirstTagValue("dup") == "1" }
|
||||
|
||||
// MusicBrainz Identifiers
|
||||
|
||||
|
@ -210,7 +210,7 @@ func getBeetTrack(ds model.DataStore) http.HandlerFunc {
|
||||
log.Info("mediafile", "mf", mf)
|
||||
// todo set this base from env variable
|
||||
//baseUrl := "http://127.0.0.1:8337"
|
||||
baseUrl := fmt.Sprintf("http://beets%s:8337", user)
|
||||
baseUrl := fmt.Sprintf("http://beets:8337")
|
||||
queryEndPoint := "/item/query/"
|
||||
queryStr := fmt.Sprintf("artist:%s/title:%s/user:%s", mf.Artist, mf.Title, user)
|
||||
url := baseUrl + queryEndPoint + queryStr
|
||||
|
@ -43,6 +43,7 @@ export const SongInfo = (props) => {
|
||||
<FunctionField render={(r) => r.genres?.map((g) => g.name).join(', ')} />
|
||||
),
|
||||
compilation: <BooleanField source="compilation" />,
|
||||
isDuplicate: <BooleanField source="isDuplicate" />,
|
||||
bitRate: <BitrateField source="bitRate" />,
|
||||
channels: <NumberField source="channels" />,
|
||||
size: <SizeField source="size" />,
|
||||
|
@ -13,6 +13,7 @@
|
||||
"album": "Album",
|
||||
"path": "File path",
|
||||
"genre": "Genre",
|
||||
"isDuplicate": "Duplicate",
|
||||
"compilation": "Compilation",
|
||||
"year": "Year",
|
||||
"size": "File size",
|
||||
|
Loading…
x
Reference in New Issue
Block a user