mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-16 04:00:38 +03:00
Import and display disc subtitles
This commit is contained in:
parent
7f75994906
commit
0d9361734f
27
db/migration/20200512104202_add_disc_subtitle.go
Normal file
27
db/migration/20200512104202_add_disc_subtitle.go
Normal file
@ -0,0 +1,27 @@
|
||||
package migration
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
|
||||
"github.com/pressly/goose"
|
||||
)
|
||||
|
||||
func init() {
|
||||
goose.AddMigration(Up20200512104202, Down20200512104202)
|
||||
}
|
||||
|
||||
func Up20200512104202(tx *sql.Tx) error {
|
||||
_, err := tx.Exec(`
|
||||
alter table media_file
|
||||
add disc_subtitle varchar(255);
|
||||
`)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
notice(tx, "A full rescan will be performed to import disc subtitles")
|
||||
return forceFullRescan(tx)
|
||||
}
|
||||
|
||||
func Down20200512104202(tx *sql.Tx) error {
|
||||
return nil
|
||||
}
|
@ -18,6 +18,7 @@ type MediaFile struct {
|
||||
HasCoverArt bool `json:"hasCoverArt"`
|
||||
TrackNumber int `json:"trackNumber"`
|
||||
DiscNumber int `json:"discNumber"`
|
||||
DiscSubtitle string `json:"discSubtitle"`
|
||||
Year int `json:"year"`
|
||||
Size int `json:"size"`
|
||||
Suffix string `json:"suffix"`
|
||||
|
@ -108,10 +108,11 @@ func (r *albumRepository) GetRandom(options ...model.QueryOptions) (model.Albums
|
||||
func (r *albumRepository) Refresh(ids ...string) error {
|
||||
type refreshAlbum struct {
|
||||
model.Album
|
||||
CurrentId string
|
||||
HasCoverArt bool
|
||||
SongArtists string
|
||||
Years string
|
||||
CurrentId string
|
||||
HasCoverArt bool
|
||||
SongArtists string
|
||||
Years string
|
||||
DiscSubtitles string
|
||||
}
|
||||
var albums []refreshAlbum
|
||||
sel := Select(`album_id as id, album as name, f.artist, f.album_artist, f.artist_id, f.album_artist_id,
|
||||
@ -119,6 +120,7 @@ func (r *albumRepository) Refresh(ids ...string) error {
|
||||
f.order_album_name, f.order_album_artist_name,
|
||||
f.compilation, f.genre, max(f.year) as max_year, sum(f.duration) as duration,
|
||||
count(*) as song_count, a.id as current_id, f.id as cover_art_id, f.path as cover_art_path, f.has_cover_art,
|
||||
group_concat(f.disc_subtitle, ' ') as disc_subtitles,
|
||||
group_concat(f.artist, ' ') as song_artists, group_concat(f.year, ' ') as years`).
|
||||
From("media_file f").
|
||||
LeftJoin("album a on f.album_id = a.id").
|
||||
@ -151,7 +153,7 @@ func (r *albumRepository) Refresh(ids ...string) error {
|
||||
al.CreatedAt = time.Now()
|
||||
}
|
||||
al.FullText = getFullText(al.Name, al.Artist, al.AlbumArtist, al.SongArtists,
|
||||
al.SortAlbumName, al.SortArtistName, al.SortAlbumArtistName)
|
||||
al.SortAlbumName, al.SortArtistName, al.SortAlbumArtistName, al.DiscSubtitles)
|
||||
_, err := r.put(al.ID, al.Album)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -43,7 +43,7 @@ func (r mediaFileRepository) Exists(id string) (bool, error) {
|
||||
|
||||
func (r mediaFileRepository) Put(m *model.MediaFile) error {
|
||||
m.FullText = getFullText(m.Title, m.Album, m.Artist, m.AlbumArtist,
|
||||
m.SortTitle, m.SortAlbumName, m.SortArtistName, m.SortAlbumArtistName)
|
||||
m.SortTitle, m.SortAlbumName, m.SortArtistName, m.SortAlbumArtistName, m.DiscSubtitle)
|
||||
_, err := r.put(m.ID, m)
|
||||
return err
|
||||
}
|
||||
|
@ -40,6 +40,7 @@ func (m *Metadata) Genre() string { return m.getTag("genre") }
|
||||
func (m *Metadata) Year() int { return m.parseYear("date") }
|
||||
func (m *Metadata) TrackNumber() (int, int) { return m.parseTuple("track") }
|
||||
func (m *Metadata) DiscNumber() (int, int) { return m.parseTuple("tpa", "disc") }
|
||||
func (m *Metadata) DiscSubtitle() string { return m.getTag("tsst", "discsubtitle", "setsubtitle") }
|
||||
func (m *Metadata) HasPicture() bool { return m.getTag("has_picture", "metadata_block_picture") != "" }
|
||||
func (m *Metadata) Comment() string { return m.getTag("comment") }
|
||||
func (m *Metadata) Compilation() bool { return m.parseBool("compilation") }
|
||||
|
@ -258,6 +258,7 @@ func (s *TagScanner) toMediaFile(md *Metadata) model.MediaFile {
|
||||
mf.Year = md.Year()
|
||||
mf.TrackNumber, _ = md.TrackNumber()
|
||||
mf.DiscNumber, _ = md.DiscNumber()
|
||||
mf.DiscSubtitle = md.DiscSubtitle()
|
||||
mf.Duration = md.Duration()
|
||||
mf.BitRate = md.BitRate()
|
||||
mf.Path = md.FilePath()
|
||||
|
@ -14,6 +14,7 @@ const SongDetails = (props) => {
|
||||
const { record } = props
|
||||
const data = {
|
||||
path: <TextField record={record} source="path" />,
|
||||
discSubtitle: <TextField record={record} source="discSubtitle" />,
|
||||
albumArtist: <TextField record={record} source="albumArtist" />,
|
||||
genre: <TextField record={record} source="genre" />,
|
||||
compilation: <BooleanField record={record} source="compilation" />,
|
||||
@ -22,6 +23,9 @@ const SongDetails = (props) => {
|
||||
updatedAt: <DateField record={record} source="updatedAt" showTime />,
|
||||
playCount: <TextField record={record} source="playCount" />,
|
||||
}
|
||||
if (!record.discSubtitle) {
|
||||
delete data.discSubtitle
|
||||
}
|
||||
if (record.playCount > 0) {
|
||||
data.playDate = <DateField record={record} source="playDate" showTime />
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user