mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-06-02 21:24:20 -04:00
Init first transcoder migration
This commit is contained in:
parent
605756a794
commit
5854c731a3
@ -36,6 +36,7 @@ in
|
|||||||
postgresql_15
|
postgresql_15
|
||||||
pgformatter
|
pgformatter
|
||||||
biome
|
biome
|
||||||
|
go-migrate
|
||||||
];
|
];
|
||||||
|
|
||||||
DOTNET_ROOT = "${dotnet}";
|
DOTNET_ROOT = "${dotnet}";
|
||||||
|
0
transcoder/migrations/000001_init_db.down.sql
Normal file
0
transcoder/migrations/000001_init_db.down.sql
Normal file
18
transcoder/migrations/000001_init_db.up.sql
Normal file
18
transcoder/migrations/000001_init_db.up.sql
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
begin;
|
||||||
|
|
||||||
|
create table if not exists info(
|
||||||
|
sha varchar(20) not null primary key,
|
||||||
|
path varchar(4096) not null unique,
|
||||||
|
extension varchar(256),
|
||||||
|
mime_codec varchar(1024),
|
||||||
|
size bigint not null,
|
||||||
|
duration real not null,
|
||||||
|
container varchar(256)
|
||||||
|
);
|
||||||
|
|
||||||
|
create table if not exists videos(
|
||||||
|
sha varchar(20) not null primary key,
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
commit;
|
@ -30,7 +30,7 @@ type MediaInfo struct {
|
|||||||
/// The whole mimetype (defined as the RFC 6381). ex: `video/mp4; codecs="avc1.640028, mp4a.40.2"`
|
/// The whole mimetype (defined as the RFC 6381). ex: `video/mp4; codecs="avc1.640028, mp4a.40.2"`
|
||||||
MimeCodec *string `json:"mimeCodec"`
|
MimeCodec *string `json:"mimeCodec"`
|
||||||
/// The file size of the video file.
|
/// The file size of the video file.
|
||||||
Size uint64 `json:"size"`
|
Size int64 `json:"size"`
|
||||||
/// The length of the media in seconds.
|
/// The length of the media in seconds.
|
||||||
Duration float32 `json:"duration"`
|
Duration float32 `json:"duration"`
|
||||||
/// The container of the video file of this episode.
|
/// The container of the video file of this episode.
|
||||||
@ -129,8 +129,8 @@ func ParseUint(str string) uint32 {
|
|||||||
return uint32(i)
|
return uint32(i)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ParseUint64(str string) uint64 {
|
func ParseInt64(str string) int64 {
|
||||||
i, err := strconv.ParseUint(str, 10, 64)
|
i, err := strconv.ParseInt(str, 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
println(str)
|
println(str)
|
||||||
return 0
|
return 0
|
||||||
@ -260,7 +260,7 @@ func getInfo(path string) (*MediaInfo, error) {
|
|||||||
Path: path,
|
Path: path,
|
||||||
// Remove leading .
|
// Remove leading .
|
||||||
Extension: filepath.Ext(path)[1:],
|
Extension: filepath.Ext(path)[1:],
|
||||||
Size: ParseUint64(mi.Format.Size),
|
Size: ParseInt64(mi.Format.Size),
|
||||||
Duration: float32(mi.Format.DurationSeconds),
|
Duration: float32(mi.Format.DurationSeconds),
|
||||||
Container: OrNull(mi.Format.FormatName),
|
Container: OrNull(mi.Format.FormatName),
|
||||||
Videos: MapStream(mi.Streams, ffprobe.StreamVideo, func(stream *ffprobe.Stream, i uint32) Video {
|
Videos: MapStream(mi.Streams, ffprobe.StreamVideo, func(stream *ffprobe.Stream, i uint32) Video {
|
||||||
|
@ -52,7 +52,7 @@ func getHash(path string) (string, error) {
|
|||||||
h.Write([]byte(path))
|
h.Write([]byte(path))
|
||||||
h.Write([]byte(info.ModTime().String()))
|
h.Write([]byte(info.ModTime().String()))
|
||||||
sha := hex.EncodeToString(h.Sum(nil))
|
sha := hex.EncodeToString(h.Sum(nil))
|
||||||
return version + sha, nil
|
return sha, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func SanitizePath(path string) error {
|
func SanitizePath(path string) error {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user