mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 12:24:38 +03:00
Merge pull request #103 from WithoutPants/metadata_from_file
Set title, details and date from scene file metadata
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
|||||||
"math"
|
"math"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -28,6 +29,8 @@ type VideoFile struct {
|
|||||||
VideoStream *FFProbeStream
|
VideoStream *FFProbeStream
|
||||||
|
|
||||||
Path string
|
Path string
|
||||||
|
Title string
|
||||||
|
Comment string
|
||||||
Container string
|
Container string
|
||||||
Duration float64
|
Duration float64
|
||||||
StartTime float64
|
StartTime float64
|
||||||
@@ -82,6 +85,14 @@ func parse(filePath string, probeJSON *FFProbeJSON) (*VideoFile, error) {
|
|||||||
//} // TODO nil_or_unsupported.(video_stream) && nil_or_unsupported.(audio_stream)
|
//} // TODO nil_or_unsupported.(video_stream) && nil_or_unsupported.(audio_stream)
|
||||||
|
|
||||||
result.Path = filePath
|
result.Path = filePath
|
||||||
|
result.Title = probeJSON.Format.Tags.Title
|
||||||
|
|
||||||
|
if result.Title == "" {
|
||||||
|
// default title to filename
|
||||||
|
result.Title = filepath.Base(result.Path)
|
||||||
|
}
|
||||||
|
|
||||||
|
result.Comment = probeJSON.Format.Tags.Comment
|
||||||
|
|
||||||
result.Bitrate, _ = strconv.ParseInt(probeJSON.Format.BitRate, 10, 64)
|
result.Bitrate, _ = strconv.ParseInt(probeJSON.Format.BitRate, 10, 64)
|
||||||
result.Container = probeJSON.Format.FormatName
|
result.Container = probeJSON.Format.FormatName
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ type FFProbeJSON struct {
|
|||||||
Encoder string `json:"encoder"`
|
Encoder string `json:"encoder"`
|
||||||
MajorBrand string `json:"major_brand"`
|
MajorBrand string `json:"major_brand"`
|
||||||
MinorVersion string `json:"minor_version"`
|
MinorVersion string `json:"minor_version"`
|
||||||
|
Title string `json:"title"`
|
||||||
|
Comment string `json:"comment"`
|
||||||
} `json:"tags"`
|
} `json:"tags"`
|
||||||
} `json:"format"`
|
} `json:"format"`
|
||||||
Streams []FFProbeStream `json:"streams"`
|
Streams []FFProbeStream `json:"streams"`
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
package manager
|
package manager
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"path/filepath"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"github.com/bmatcuk/doublestar"
|
"github.com/bmatcuk/doublestar"
|
||||||
"github.com/stashapp/stash/pkg/logger"
|
"github.com/stashapp/stash/pkg/logger"
|
||||||
"github.com/stashapp/stash/pkg/manager/config"
|
"github.com/stashapp/stash/pkg/manager/config"
|
||||||
"github.com/stashapp/stash/pkg/models"
|
"github.com/stashapp/stash/pkg/models"
|
||||||
"github.com/stashapp/stash/pkg/utils"
|
"github.com/stashapp/stash/pkg/utils"
|
||||||
"path/filepath"
|
|
||||||
"sync"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s *singleton) Scan() {
|
func (s *singleton) Scan() {
|
||||||
@@ -34,6 +35,8 @@ func (s *singleton) Scan() {
|
|||||||
go task.Start(&wg)
|
go task.Start(&wg)
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.Info("Finished scan")
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,15 +3,16 @@ package manager
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
|
"path/filepath"
|
||||||
|
"strconv"
|
||||||
|
"sync"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/stashapp/stash/pkg/database"
|
"github.com/stashapp/stash/pkg/database"
|
||||||
"github.com/stashapp/stash/pkg/ffmpeg"
|
"github.com/stashapp/stash/pkg/ffmpeg"
|
||||||
"github.com/stashapp/stash/pkg/logger"
|
"github.com/stashapp/stash/pkg/logger"
|
||||||
"github.com/stashapp/stash/pkg/models"
|
"github.com/stashapp/stash/pkg/models"
|
||||||
"github.com/stashapp/stash/pkg/utils"
|
"github.com/stashapp/stash/pkg/utils"
|
||||||
"path/filepath"
|
|
||||||
"strconv"
|
|
||||||
"sync"
|
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type ScanTask struct {
|
type ScanTask struct {
|
||||||
@@ -115,6 +116,9 @@ func (t *ScanTask) scanScene() {
|
|||||||
newScene := models.Scene{
|
newScene := models.Scene{
|
||||||
Checksum: checksum,
|
Checksum: checksum,
|
||||||
Path: t.FilePath,
|
Path: t.FilePath,
|
||||||
|
Title: sql.NullString{String: videoFile.Title, Valid: true},
|
||||||
|
Details: sql.NullString{String: videoFile.Comment, Valid: true},
|
||||||
|
Date: models.SQLiteDate{String: videoFile.CreationTime.Format("2006-01-02")},
|
||||||
Duration: sql.NullFloat64{Float64: videoFile.Duration, Valid: true},
|
Duration: sql.NullFloat64{Float64: videoFile.Duration, Valid: true},
|
||||||
VideoCodec: sql.NullString{String: videoFile.VideoCodec, Valid: true},
|
VideoCodec: sql.NullString{String: videoFile.VideoCodec, Valid: true},
|
||||||
AudioCodec: sql.NullString{String: videoFile.AudioCodec, Valid: true},
|
AudioCodec: sql.NullString{String: videoFile.AudioCodec, Valid: true},
|
||||||
|
|||||||
Reference in New Issue
Block a user