mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 04:44:37 +03:00
Make scene metadata from file metadata optional (#259)
This commit is contained in:
@@ -6,7 +6,7 @@ input GenerateMetadataInput {
|
|||||||
}
|
}
|
||||||
|
|
||||||
input ScanMetadataInput {
|
input ScanMetadataInput {
|
||||||
nameFromMetadata: Boolean!
|
useFileMetadata: Boolean!
|
||||||
}
|
}
|
||||||
|
|
||||||
input AutoTagMetadataInput {
|
input AutoTagMetadataInput {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (r *queryResolver) MetadataScan(ctx context.Context, input models.ScanMetadataInput) (string, error) {
|
func (r *queryResolver) MetadataScan(ctx context.Context, input models.ScanMetadataInput) (string, error) {
|
||||||
manager.GetInstance().Scan(input.NameFromMetadata)
|
manager.GetInstance().Scan(input.UseFileMetadata)
|
||||||
return "todo", nil
|
return "todo", nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ func (t *TaskStatus) updated() {
|
|||||||
t.LastUpdate = time.Now()
|
t.LastUpdate = time.Now()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *singleton) Scan(nameFromMetadata bool) {
|
func (s *singleton) Scan(useFileMetadata bool) {
|
||||||
if s.Status.Status != Idle {
|
if s.Status.Status != Idle {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -90,7 +90,7 @@ func (s *singleton) Scan(nameFromMetadata bool) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
task := ScanTask{FilePath: path, NameFromMetadata: nameFromMetadata}
|
task := ScanTask{FilePath: path, UseFileMetadata: useFileMetadata}
|
||||||
go task.Start(&wg)
|
go task.Start(&wg)
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import (
|
|||||||
|
|
||||||
type ScanTask struct {
|
type ScanTask struct {
|
||||||
FilePath string
|
FilePath string
|
||||||
NameFromMetadata bool
|
UseFileMetadata bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *ScanTask) Start(wg *sync.WaitGroup) {
|
func (t *ScanTask) Start(wg *sync.WaitGroup) {
|
||||||
@@ -92,8 +92,8 @@ func (t *ScanTask) scanScene() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Override title to be filename if nameFromMetadata is false
|
// Override title to be filename if UseFileMetadata is false
|
||||||
if !t.NameFromMetadata {
|
if !t.UseFileMetadata {
|
||||||
videoFile.SetTitleFromPath()
|
videoFile.SetTitleFromPath()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,8 +127,6 @@ func (t *ScanTask) scanScene() {
|
|||||||
Checksum: checksum,
|
Checksum: checksum,
|
||||||
Path: t.FilePath,
|
Path: t.FilePath,
|
||||||
Title: sql.NullString{String: videoFile.Title, Valid: true},
|
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},
|
||||||
@@ -140,6 +138,11 @@ func (t *ScanTask) scanScene() {
|
|||||||
CreatedAt: models.SQLiteTimestamp{Timestamp: currentTime},
|
CreatedAt: models.SQLiteTimestamp{Timestamp: currentTime},
|
||||||
UpdatedAt: models.SQLiteTimestamp{Timestamp: currentTime},
|
UpdatedAt: models.SQLiteTimestamp{Timestamp: currentTime},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if t.UseFileMetadata {
|
||||||
|
newScene.Details = sql.NullString{String: videoFile.Comment, Valid: true}
|
||||||
|
newScene.Date = models.SQLiteDate{String: videoFile.CreationTime.Format("2006-01-02")}
|
||||||
|
}
|
||||||
_, err = qb.Create(newScene, tx)
|
_, err = qb.Create(newScene, tx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ interface IProps {}
|
|||||||
export const SettingsTasksPanel: FunctionComponent<IProps> = (props: IProps) => {
|
export const SettingsTasksPanel: FunctionComponent<IProps> = (props: IProps) => {
|
||||||
const [isImportAlertOpen, setIsImportAlertOpen] = useState<boolean>(false);
|
const [isImportAlertOpen, setIsImportAlertOpen] = useState<boolean>(false);
|
||||||
const [isCleanAlertOpen, setIsCleanAlertOpen] = useState<boolean>(false);
|
const [isCleanAlertOpen, setIsCleanAlertOpen] = useState<boolean>(false);
|
||||||
const [nameFromMetadata, setNameFromMetadata] = useState<boolean>(true);
|
const [useFileMetadata, setUseFileMetadata] = useState<boolean>(false);
|
||||||
const [status, setStatus] = useState<string>("");
|
const [status, setStatus] = useState<string>("");
|
||||||
const [progress, setProgress] = useState<number | undefined>(undefined);
|
const [progress, setProgress] = useState<number | undefined>(undefined);
|
||||||
|
|
||||||
@@ -128,7 +128,7 @@ export const SettingsTasksPanel: FunctionComponent<IProps> = (props: IProps) =>
|
|||||||
|
|
||||||
async function onScan() {
|
async function onScan() {
|
||||||
try {
|
try {
|
||||||
await StashService.queryMetadataScan({nameFromMetadata});
|
await StashService.queryMetadataScan({useFileMetadata: useFileMetadata});
|
||||||
ToastUtils.success("Started scan");
|
ToastUtils.success("Started scan");
|
||||||
jobStatus.refetch();
|
jobStatus.refetch();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -199,9 +199,9 @@ export const SettingsTasksPanel: FunctionComponent<IProps> = (props: IProps) =>
|
|||||||
inline={true}
|
inline={true}
|
||||||
>
|
>
|
||||||
<Checkbox
|
<Checkbox
|
||||||
checked={nameFromMetadata}
|
checked={useFileMetadata}
|
||||||
label="Set name from metadata (if present)"
|
label="Set name, date, details from metadata (if present)"
|
||||||
onChange={() => setNameFromMetadata(!nameFromMetadata)}
|
onChange={() => setUseFileMetadata(!useFileMetadata)}
|
||||||
/>
|
/>
|
||||||
<Button id="scan" text="Scan" onClick={() => onScan()} />
|
<Button id="scan" text="Scan" onClick={() => onScan()} />
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
|
|||||||
Reference in New Issue
Block a user