mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 20:34:37 +03:00
Prevent invalid date tag in video file from aborting scan (#836)
* Give more context when ffprobe fails * Suppress JSONTime unmarshal error * Tidy scan logging
This commit is contained in:
@@ -236,7 +236,7 @@ func NewVideoFile(ffprobePath string, videoPath string) (*VideoFile, error) {
|
|||||||
|
|
||||||
probeJSON := &FFProbeJSON{}
|
probeJSON := &FFProbeJSON{}
|
||||||
if err := json.Unmarshal(out, probeJSON); err != nil {
|
if err := json.Unmarshal(out, probeJSON); err != nil {
|
||||||
return nil, err
|
return nil, fmt.Errorf("Error unmarshalling video data for <%s>: %s", videoPath, err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
return parse(videoPath, probeJSON)
|
return parse(videoPath, probeJSON)
|
||||||
@@ -244,7 +244,7 @@ func NewVideoFile(ffprobePath string, videoPath string) (*VideoFile, error) {
|
|||||||
|
|
||||||
func parse(filePath string, probeJSON *FFProbeJSON) (*VideoFile, error) {
|
func parse(filePath string, probeJSON *FFProbeJSON) (*VideoFile, error) {
|
||||||
if probeJSON == nil {
|
if probeJSON == nil {
|
||||||
return nil, fmt.Errorf("failed to get ffprobe json")
|
return nil, fmt.Errorf("failed to get ffprobe json for <%s>", filePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
result := &VideoFile{}
|
result := &VideoFile{}
|
||||||
@@ -273,7 +273,7 @@ func parse(filePath string, probeJSON *FFProbeJSON) (*VideoFile, error) {
|
|||||||
result.Duration = math.Round(duration*100) / 100
|
result.Duration = math.Round(duration*100) / 100
|
||||||
fileStat, err := os.Stat(filePath)
|
fileStat, err := os.Stat(filePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Errorf("Error statting file: %v", err)
|
logger.Errorf("Error statting file <%s>: %s", filePath, err.Error())
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
result.Size = fileStat.Size()
|
result.Size = fileStat.Size()
|
||||||
|
|||||||
@@ -47,10 +47,6 @@ func (t *ScanTask) scanGallery() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ok, err := utils.IsZipFileUncompressed(t.FilePath)
|
|
||||||
if err == nil && !ok {
|
|
||||||
logger.Warnf("%s is using above store (0) level compression.", t.FilePath)
|
|
||||||
}
|
|
||||||
checksum, err := t.calculateChecksum()
|
checksum, err := t.calculateChecksum()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error(err.Error())
|
logger.Error(err.Error())
|
||||||
@@ -82,6 +78,12 @@ func (t *ScanTask) scanGallery() {
|
|||||||
|
|
||||||
// don't create gallery if it has no images
|
// don't create gallery if it has no images
|
||||||
if newGallery.CountFiles() > 0 {
|
if newGallery.CountFiles() > 0 {
|
||||||
|
// only warn when creating the gallery
|
||||||
|
ok, err := utils.IsZipFileUncompressed(t.FilePath)
|
||||||
|
if err == nil && !ok {
|
||||||
|
logger.Warnf("%s is using above store (0) level compression.", t.FilePath)
|
||||||
|
}
|
||||||
|
|
||||||
logger.Infof("%s doesn't exist. Creating new item...", t.FilePath)
|
logger.Infof("%s doesn't exist. Creating new item...", t.FilePath)
|
||||||
_, err = qb.Create(newGallery, tx)
|
_, err = qb.Create(newGallery, tx)
|
||||||
}
|
}
|
||||||
@@ -251,7 +253,7 @@ func (t *ScanTask) scanScene() {
|
|||||||
|
|
||||||
var checksum string
|
var checksum string
|
||||||
|
|
||||||
logger.Infof("%s not found. Calculating oshash...", t.FilePath)
|
logger.Infof("%s not found. Calculating oshash...", t.FilePath)
|
||||||
oshash, err := utils.OSHashFromFilePath(t.FilePath)
|
oshash, err := utils.OSHashFromFilePath(t.FilePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error(err.Error())
|
logger.Error(err.Error())
|
||||||
@@ -289,9 +291,9 @@ func (t *ScanTask) scanScene() {
|
|||||||
if scene != nil {
|
if scene != nil {
|
||||||
exists, _ := utils.FileExists(scene.Path)
|
exists, _ := utils.FileExists(scene.Path)
|
||||||
if exists {
|
if exists {
|
||||||
logger.Infof("%s already exists. Duplicate of %s ", t.FilePath, scene.Path)
|
logger.Infof("%s already exists. Duplicate of %s", t.FilePath, scene.Path)
|
||||||
} else {
|
} else {
|
||||||
logger.Infof("%s already exists. Updating path...", t.FilePath)
|
logger.Infof("%s already exists. Updating path...", t.FilePath)
|
||||||
scenePartial := models.ScenePartial{
|
scenePartial := models.ScenePartial{
|
||||||
ID: scene.ID,
|
ID: scene.ID,
|
||||||
Path: &t.FilePath,
|
Path: &t.FilePath,
|
||||||
@@ -299,7 +301,7 @@ func (t *ScanTask) scanScene() {
|
|||||||
_, err = qb.Update(scenePartial, tx)
|
_, err = qb.Update(scenePartial, tx)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
logger.Infof("%s doesn't exist. Creating new item...", t.FilePath)
|
logger.Infof("%s doesn't exist. Creating new item...", t.FilePath)
|
||||||
currentTime := time.Now()
|
currentTime := time.Now()
|
||||||
newScene := models.Scene{
|
newScene := models.Scene{
|
||||||
Checksum: sql.NullString{String: checksum, Valid: checksum != ""},
|
Checksum: sql.NullString{String: checksum, Valid: checksum != ""},
|
||||||
@@ -342,7 +344,6 @@ func (t *ScanTask) makeScreenshots(probeResult *ffmpeg.VideoFile, checksum strin
|
|||||||
normalExists, _ := utils.FileExists(normalPath)
|
normalExists, _ := utils.FileExists(normalPath)
|
||||||
|
|
||||||
if thumbExists && normalExists {
|
if thumbExists && normalExists {
|
||||||
logger.Debug("Screenshots already exist for this path... skipping")
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/stashapp/stash/pkg/logger"
|
||||||
"github.com/stashapp/stash/pkg/utils"
|
"github.com/stashapp/stash/pkg/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -14,15 +15,21 @@ type JSONTime struct {
|
|||||||
time.Time
|
time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
func (jt *JSONTime) UnmarshalJSON(b []byte) (err error) {
|
func (jt *JSONTime) UnmarshalJSON(b []byte) error {
|
||||||
s := strings.Trim(string(b), "\"")
|
s := strings.Trim(string(b), "\"")
|
||||||
if s == "null" {
|
if s == "null" {
|
||||||
jt.Time = time.Time{}
|
jt.Time = time.Time{}
|
||||||
return
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// #731 - returning an error here causes the entire JSON parse to fail for ffprobe.
|
||||||
|
// Changing so that it logs a warning instead.
|
||||||
|
var err error
|
||||||
jt.Time, err = utils.ParseDateStringAsTime(s)
|
jt.Time, err = utils.ParseDateStringAsTime(s)
|
||||||
return
|
if err != nil {
|
||||||
|
logger.Warnf("error unmarshalling JSONTime: %s", err.Error())
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (jt *JSONTime) MarshalJSON() ([]byte, error) {
|
func (jt *JSONTime) MarshalJSON() ([]byte, error) {
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
* Re-show preview thumbnail when mousing away from scene card.
|
* Re-show preview thumbnail when mousing away from scene card.
|
||||||
|
|
||||||
### 🐛 Bug fixes
|
### 🐛 Bug fixes
|
||||||
|
* Fix invalid date tag preventing video file from being scanned.
|
||||||
* Fix error when creating movie from scene scrape dialog.
|
* Fix error when creating movie from scene scrape dialog.
|
||||||
* Fix incorrect date timezone.
|
* Fix incorrect date timezone.
|
||||||
* Fix search filters not persisting for studios, markers and galleries.
|
* Fix search filters not persisting for studios, markers and galleries.
|
||||||
|
|||||||
Reference in New Issue
Block a user