mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-07-09 03:04:20 -04:00
Use os.Stat instead of mediainfo for thumbnails cache path
This commit is contained in:
parent
9fd7ca35f1
commit
983b558510
@ -1,6 +1,8 @@
|
|||||||
package src
|
package src
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/sha1"
|
||||||
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
"image"
|
"image"
|
||||||
"image/color"
|
"image/color"
|
||||||
@ -67,11 +69,18 @@ func (t *ThumbnailsCreator) ExtractThumbnail(path string, name string) (string,
|
|||||||
}
|
}
|
||||||
|
|
||||||
func extractThumbnail(path string, name string) (string, error) {
|
func extractThumbnail(path string, name string) (string, error) {
|
||||||
ret, err := GetInfo(path)
|
defer printExecTime("extracting thumbnails for %s", path)()
|
||||||
|
info, err := os.Stat(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
out := fmt.Sprintf("%s/%s", Settings.Metadata, ret.Sha)
|
h := sha1.New()
|
||||||
|
h.Write([]byte(path))
|
||||||
|
h.Write([]byte(info.ModTime().String()))
|
||||||
|
sha := hex.EncodeToString(h.Sum(nil))
|
||||||
|
|
||||||
|
out := fmt.Sprintf("%s/%s", Settings.Metadata, sha)
|
||||||
|
os.MkdirAll(out, 0o755)
|
||||||
sprite_path := fmt.Sprintf("%s/sprite.png", out)
|
sprite_path := fmt.Sprintf("%s/sprite.png", out)
|
||||||
vtt_path := fmt.Sprintf("%s/sprite.vtt", out)
|
vtt_path := fmt.Sprintf("%s/sprite.vtt", out)
|
||||||
|
|
||||||
@ -134,8 +143,14 @@ func extractThumbnail(path string, name string) (string, error) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
os.WriteFile(vtt_path, []byte(vtt), 0o644)
|
err = os.WriteFile(vtt_path, []byte(vtt), 0o644)
|
||||||
imaging.Save(sprite, sprite_path)
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
err = imaging.Save(sprite, sprite_path)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user