mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Remove path/is_external in subtitle
This commit is contained in:
parent
fa03d835ed
commit
b14ac6ec02
@ -50,17 +50,15 @@ create table audios(
|
||||
create table subtitles(
|
||||
sha varchar(40) not null references info(sha) on delete cascade,
|
||||
-- Can be null when is_external is true
|
||||
idx integer,
|
||||
idx integer not null,
|
||||
title varchar(1024),
|
||||
language varchar(256),
|
||||
codec varchar(256) not null,
|
||||
extension varchar(16),
|
||||
is_default boolean not null,
|
||||
is_forced boolean not null,
|
||||
is_external boolean not null,
|
||||
path varchar(4096)
|
||||
|
||||
constraint subtitle_pk primary key (sha, idx, path)
|
||||
constraint subtitle_pk primary key (sha, idx)
|
||||
);
|
||||
|
||||
create type chapter_type as enum('content', 'recap', 'intro', 'credits', 'preview');
|
||||
|
@ -115,8 +115,7 @@ type Subtitle struct {
|
||||
IsForced bool `json:"isForced"`
|
||||
/// Is this an external subtitle (as in stored in a different file)
|
||||
IsExternal bool `json:"isExternal"`
|
||||
/// Where the subtitle is stored (either in library if IsExternal is true or in transcoder cache if false)
|
||||
/// Null if the subtitle can't be extracted (unsupported format)
|
||||
/// Where the subtitle is stored (null if stored inside the video)
|
||||
Path *string `json:"path"`
|
||||
/// The link to access this subtitle.
|
||||
Link *string `json:"link"`
|
||||
@ -272,10 +271,8 @@ func RetriveMediaInfo(path string, sha string) (*MediaInfo, error) {
|
||||
Subtitles: MapStream(mi.Streams, ffprobe.StreamSubtitle, func(stream *ffprobe.Stream, i uint32) Subtitle {
|
||||
extension := OrNull(SubtitleExtensions[stream.CodecName])
|
||||
var link string
|
||||
var spath string
|
||||
if extension != nil {
|
||||
link = fmt.Sprintf("%s/%s/subtitle/%d.%s", Settings.RoutePrefix, base64.RawURLEncoding.EncodeToString([]byte(path)), i, *extension)
|
||||
spath = fmt.Sprintf("%s/%s/sub/%d.%s", Settings.Metadata, sha, i, *extension)
|
||||
}
|
||||
lang, _ := language.Parse(stream.Tags.Language)
|
||||
idx := uint32(i)
|
||||
@ -288,7 +285,6 @@ func RetriveMediaInfo(path string, sha string) (*MediaInfo, error) {
|
||||
IsDefault: stream.Disposition.Default != 0,
|
||||
IsForced: stream.Disposition.Forced != 0,
|
||||
Link: &link,
|
||||
Path: &spath,
|
||||
}
|
||||
}),
|
||||
Chapters: Map(mi.Chapters, func(c *ffprobe.Chapter, _ int) Chapter {
|
||||
|
@ -151,7 +151,7 @@ func (s *MetadataService) getMetadata(path string, sha string) (*MediaInfo, erro
|
||||
}
|
||||
|
||||
rows, err = s.database.Query(
|
||||
`select s.idx, s.title, s.language, s.codec, s.extension, s.is_default, s.is_forced, s.is_external, s.path
|
||||
`select s.idx, s.title, s.language, s.codec, s.extension, s.is_default, s.is_forced
|
||||
from subtitles as s where s.sha=$1`,
|
||||
sha,
|
||||
)
|
||||
@ -160,7 +160,7 @@ func (s *MetadataService) getMetadata(path string, sha string) (*MediaInfo, erro
|
||||
}
|
||||
for rows.Next() {
|
||||
var s Subtitle
|
||||
err := rows.Scan(&s.Index, &s.Title, &s.Language, &s.Codec, &s.Extension, &s.IsDefault, &s.IsForced, &s.IsExternal, &s.Path)
|
||||
err := rows.Scan(&s.Index, &s.Title, &s.Language, &s.Codec, &s.Extension, &s.IsDefault, &s.IsForced)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -267,9 +267,9 @@ func (s *MetadataService) storeFreshMetadata(path string, sha string) (*MediaInf
|
||||
}
|
||||
for _, s := range ret.Subtitles {
|
||||
tx.Exec(`
|
||||
insert into subtitles(sha, idx, title, language, codec, extension, is_default, is_forced, is_external, path)
|
||||
values ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)
|
||||
on conflict (sha, idx, path) do update set
|
||||
insert into subtitles(sha, idx, title, language, codec, extension, is_default, is_forced)
|
||||
values ($1, $2, $3, $4, $5, $6, $7, $8)
|
||||
on conflict (sha, idx) do update set
|
||||
sha = excluded.sha,
|
||||
idx = excluded.idx,
|
||||
title = excluded.title,
|
||||
@ -277,11 +277,9 @@ func (s *MetadataService) storeFreshMetadata(path string, sha string) (*MediaInf
|
||||
codec = excluded.codec,
|
||||
extension = excluded.extension,
|
||||
is_default = excluded.is_default,
|
||||
is_forced = excluded.is_forced,
|
||||
is_external = excluded.is_external,
|
||||
path = excluded.path
|
||||
is_forced = excluded.is_forced
|
||||
`,
|
||||
ret.Sha, s.Index, s.Title, s.Language, s.Codec, s.Extension, s.IsDefault, s.IsForced, s.IsExternal, s.Path,
|
||||
ret.Sha, s.Index, s.Title, s.Language, s.Codec, s.Extension, s.IsDefault, s.IsForced,
|
||||
)
|
||||
}
|
||||
for _, c := range ret.Chapters {
|
||||
|
Loading…
x
Reference in New Issue
Block a user