mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-07-09 03:04:20 -04:00
Add a constraint for subtitles
This commit is contained in:
parent
c84afc8e4c
commit
7d617a5d28
@ -57,6 +57,8 @@ create table subtitles(
|
|||||||
is_forced boolean not null,
|
is_forced boolean not null,
|
||||||
is_external boolean not null,
|
is_external boolean not null,
|
||||||
path varchar(4096)
|
path varchar(4096)
|
||||||
|
|
||||||
|
constraint subtitle_pk primary key (sha, idx, path)
|
||||||
);
|
);
|
||||||
|
|
||||||
create type chapter_type as enum('content', 'recap', 'intro', 'credits', 'preview');
|
create type chapter_type as enum('content', 'recap', 'intro', 'credits', 'preview');
|
||||||
|
@ -170,7 +170,7 @@ func (s *MetadataService) getMetadata(path string, sha string) (*MediaInfo, erro
|
|||||||
"%s/%s/subtitle/%d.%s",
|
"%s/%s/subtitle/%d.%s",
|
||||||
Settings.RoutePrefix,
|
Settings.RoutePrefix,
|
||||||
base64.RawURLEncoding.EncodeToString([]byte(ret.Path)),
|
base64.RawURLEncoding.EncodeToString([]byte(ret.Path)),
|
||||||
s.Index,
|
*s.Index,
|
||||||
*s.Extension,
|
*s.Extension,
|
||||||
)
|
)
|
||||||
s.Link = &link
|
s.Link = &link
|
||||||
@ -231,8 +231,8 @@ func (s *MetadataService) storeFreshMetadata(path string, sha string) (*MediaInf
|
|||||||
pq.Array(ret.Fonts), ret.Versions.Info, ret.Versions.Extract, ret.Versions.Thumbs, ret.Versions.Keyframes,
|
pq.Array(ret.Fonts), ret.Versions.Info, ret.Versions.Extract, ret.Versions.Thumbs, ret.Versions.Keyframes,
|
||||||
).Scan(&ret.Versions.Extract, &ret.Versions.Thumbs, &ret.Versions.Keyframes)
|
).Scan(&ret.Versions.Extract, &ret.Versions.Thumbs, &ret.Versions.Keyframes)
|
||||||
for _, v := range ret.Videos {
|
for _, v := range ret.Videos {
|
||||||
tx.Exec(
|
tx.Exec(`
|
||||||
`insert into videos(sha, idx, title, language, codec, mime_codec, width, height, bitrate)
|
insert into videos(sha, idx, title, language, codec, mime_codec, width, height, bitrate)
|
||||||
values ($1, $2, $3, $4, $5, $6, $7, $8, $9)
|
values ($1, $2, $3, $4, $5, $6, $7, $8, $9)
|
||||||
on conflict (sha, idx) do update set
|
on conflict (sha, idx) do update set
|
||||||
sha = excluded.sha,
|
sha = excluded.sha,
|
||||||
@ -249,8 +249,8 @@ func (s *MetadataService) storeFreshMetadata(path string, sha string) (*MediaInf
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
for _, a := range ret.Audios {
|
for _, a := range ret.Audios {
|
||||||
tx.Exec(
|
tx.Exec(`
|
||||||
`insert into audios(sha, idx, title, language, codec, mime_codec, is_default)
|
insert into audios(sha, idx, title, language, codec, mime_codec, is_default)
|
||||||
values ($1, $2, $3, $4, $5, $6, $7)
|
values ($1, $2, $3, $4, $5, $6, $7)
|
||||||
on conflict (sha, idx) do update set
|
on conflict (sha, idx) do update set
|
||||||
sha = excluded.sha,
|
sha = excluded.sha,
|
||||||
@ -265,15 +265,27 @@ 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, is_external, path)
|
||||||
values ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)`,
|
values ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)
|
||||||
|
on conflict (sha, idx, path) do update set
|
||||||
|
sha = excluded.sha,
|
||||||
|
idx = excluded.idx,
|
||||||
|
title = excluded.title,
|
||||||
|
language = excluded.language,
|
||||||
|
codec = excluded.codec,
|
||||||
|
extension = excluded.extension,
|
||||||
|
is_default = excluded.is_default,
|
||||||
|
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, s.IsExternal, s.Path,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
for _, c := range ret.Chapters {
|
for _, c := range ret.Chapters {
|
||||||
tx.Exec(
|
tx.Exec(`
|
||||||
`insert into chapters(sha, start_time, end_time, name, type)
|
insert into chapters(sha, start_time, end_time, name, type)
|
||||||
values ($1, $2, $3, $4, $5)
|
values ($1, $2, $3, $4, $5)
|
||||||
on conflict (sha, start_time) do update set
|
on conflict (sha, start_time) do update set
|
||||||
sha = excluded.sha,
|
sha = excluded.sha,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user