mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 04:44:37 +03:00
Parse title, details, date from file metadata
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"math"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -28,6 +29,8 @@ type VideoFile struct {
|
||||
VideoStream *FFProbeStream
|
||||
|
||||
Path string
|
||||
Title string
|
||||
Comment string
|
||||
Container string
|
||||
Duration 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)
|
||||
|
||||
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.Container = probeJSON.Format.FormatName
|
||||
|
||||
@@ -22,6 +22,8 @@ type FFProbeJSON struct {
|
||||
Encoder string `json:"encoder"`
|
||||
MajorBrand string `json:"major_brand"`
|
||||
MinorVersion string `json:"minor_version"`
|
||||
Title string `json:"title"`
|
||||
Comment string `json:"comment"`
|
||||
} `json:"tags"`
|
||||
} `json:"format"`
|
||||
Streams []FFProbeStream `json:"streams"`
|
||||
|
||||
Reference in New Issue
Block a user