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