mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 20:34:37 +03:00
Make title from file metadata optional
This commit is contained in:
@@ -6,8 +6,8 @@ query MetadataExport {
|
|||||||
metadataExport
|
metadataExport
|
||||||
}
|
}
|
||||||
|
|
||||||
query MetadataScan {
|
query MetadataScan($input: ScanMetadataInput!) {
|
||||||
metadataScan
|
metadataScan(input: $input)
|
||||||
}
|
}
|
||||||
|
|
||||||
query MetadataGenerate($input: GenerateMetadataInput!) {
|
query MetadataGenerate($input: GenerateMetadataInput!) {
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ type Query {
|
|||||||
"""Start an export. Returns the job ID"""
|
"""Start an export. Returns the job ID"""
|
||||||
metadataExport: String!
|
metadataExport: String!
|
||||||
"""Start a scan. Returns the job ID"""
|
"""Start a scan. Returns the job ID"""
|
||||||
metadataScan: String!
|
metadataScan(input: ScanMetadataInput!): String!
|
||||||
"""Start generating content. Returns the job ID"""
|
"""Start generating content. Returns the job ID"""
|
||||||
metadataGenerate(input: GenerateMetadataInput!): String!
|
metadataGenerate(input: GenerateMetadataInput!): String!
|
||||||
"""Clean metadata. Returns the job ID"""
|
"""Clean metadata. Returns the job ID"""
|
||||||
|
|||||||
@@ -3,4 +3,8 @@ input GenerateMetadataInput {
|
|||||||
previews: Boolean!
|
previews: Boolean!
|
||||||
markers: Boolean!
|
markers: Boolean!
|
||||||
transcodes: Boolean!
|
transcodes: Boolean!
|
||||||
|
}
|
||||||
|
|
||||||
|
input ScanMetadataInput {
|
||||||
|
nameFromMetadata: Boolean!
|
||||||
}
|
}
|
||||||
@@ -2,12 +2,13 @@ package api
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/stashapp/stash/pkg/manager"
|
"github.com/stashapp/stash/pkg/manager"
|
||||||
"github.com/stashapp/stash/pkg/models"
|
"github.com/stashapp/stash/pkg/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (r *queryResolver) MetadataScan(ctx context.Context) (string, error) {
|
func (r *queryResolver) MetadataScan(ctx context.Context, input models.ScanMetadataInput) (string, error) {
|
||||||
manager.GetInstance().Scan()
|
manager.GetInstance().Scan(input.NameFromMetadata)
|
||||||
return "todo", nil
|
return "todo", nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ func parse(filePath string, probeJSON *FFProbeJSON) (*VideoFile, error) {
|
|||||||
|
|
||||||
if result.Title == "" {
|
if result.Title == "" {
|
||||||
// default title to filename
|
// default title to filename
|
||||||
result.Title = filepath.Base(result.Path)
|
result.SetTitleFromPath()
|
||||||
}
|
}
|
||||||
|
|
||||||
result.Comment = probeJSON.Format.Tags.Comment
|
result.Comment = probeJSON.Format.Tags.Comment
|
||||||
@@ -161,3 +161,7 @@ func (v *VideoFile) getStreamIndex(fileType string, probeJSON FFProbeJSON) int {
|
|||||||
|
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (v *VideoFile) SetTitleFromPath() {
|
||||||
|
v.Title = filepath.Base(v.Path)
|
||||||
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import (
|
|||||||
"github.com/stashapp/stash/pkg/utils"
|
"github.com/stashapp/stash/pkg/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s *singleton) Scan() {
|
func (s *singleton) Scan(nameFromMetadata bool) {
|
||||||
if s.Status != Idle {
|
if s.Status != Idle {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -31,7 +31,7 @@ func (s *singleton) Scan() {
|
|||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
for _, path := range results {
|
for _, path := range results {
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
task := ScanTask{FilePath: path}
|
task := ScanTask{FilePath: path, NameFromMetadata: nameFromMetadata}
|
||||||
go task.Start(&wg)
|
go task.Start(&wg)
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type ScanTask struct {
|
type ScanTask struct {
|
||||||
FilePath string
|
FilePath string
|
||||||
|
NameFromMetadata bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *ScanTask) Start(wg *sync.WaitGroup) {
|
func (t *ScanTask) Start(wg *sync.WaitGroup) {
|
||||||
@@ -90,6 +91,11 @@ func (t *ScanTask) scanScene() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Override title to be filename if nameFromMetadata is false
|
||||||
|
if !t.NameFromMetadata {
|
||||||
|
videoFile.SetTitleFromPath()
|
||||||
|
}
|
||||||
|
|
||||||
checksum, err := t.calculateChecksum()
|
checksum, err := t.calculateChecksum()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error(err.Error())
|
logger.Error(err.Error())
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ type ComplexityRoot struct {
|
|||||||
MetadataExport func(childComplexity int) int
|
MetadataExport func(childComplexity int) int
|
||||||
MetadataGenerate func(childComplexity int, input GenerateMetadataInput) int
|
MetadataGenerate func(childComplexity int, input GenerateMetadataInput) int
|
||||||
MetadataImport func(childComplexity int) int
|
MetadataImport func(childComplexity int) int
|
||||||
MetadataScan func(childComplexity int) int
|
MetadataScan func(childComplexity int, input ScanMetadataInput) int
|
||||||
SceneMarkerTags func(childComplexity int, sceneID string) int
|
SceneMarkerTags func(childComplexity int, sceneID string) int
|
||||||
SceneWall func(childComplexity int, q *string) int
|
SceneWall func(childComplexity int, q *string) int
|
||||||
ScrapeFreeones func(childComplexity int, performerName string) int
|
ScrapeFreeones func(childComplexity int, performerName string) int
|
||||||
@@ -351,7 +351,7 @@ type QueryResolver interface {
|
|||||||
Directories(ctx context.Context, path *string) ([]string, error)
|
Directories(ctx context.Context, path *string) ([]string, error)
|
||||||
MetadataImport(ctx context.Context) (string, error)
|
MetadataImport(ctx context.Context) (string, error)
|
||||||
MetadataExport(ctx context.Context) (string, error)
|
MetadataExport(ctx context.Context) (string, error)
|
||||||
MetadataScan(ctx context.Context) (string, error)
|
MetadataScan(ctx context.Context, input ScanMetadataInput) (string, error)
|
||||||
MetadataGenerate(ctx context.Context, input GenerateMetadataInput) (string, error)
|
MetadataGenerate(ctx context.Context, input GenerateMetadataInput) (string, error)
|
||||||
MetadataClean(ctx context.Context) (string, error)
|
MetadataClean(ctx context.Context) (string, error)
|
||||||
AllPerformers(ctx context.Context) ([]*Performer, error)
|
AllPerformers(ctx context.Context) ([]*Performer, error)
|
||||||
@@ -1156,7 +1156,12 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
return e.complexity.Query.MetadataScan(childComplexity), true
|
args, err := ec.field_Query_metadataScan_args(context.TODO(), rawArgs)
|
||||||
|
if err != nil {
|
||||||
|
return 0, false
|
||||||
|
}
|
||||||
|
|
||||||
|
return e.complexity.Query.MetadataScan(childComplexity, args["input"].(ScanMetadataInput)), true
|
||||||
|
|
||||||
case "Query.sceneMarkerTags":
|
case "Query.sceneMarkerTags":
|
||||||
if e.complexity.Query.SceneMarkerTags == nil {
|
if e.complexity.Query.SceneMarkerTags == nil {
|
||||||
@@ -1887,7 +1892,7 @@ type Query {
|
|||||||
"""Start an export. Returns the job ID"""
|
"""Start an export. Returns the job ID"""
|
||||||
metadataExport: String!
|
metadataExport: String!
|
||||||
"""Start a scan. Returns the job ID"""
|
"""Start a scan. Returns the job ID"""
|
||||||
metadataScan: String!
|
metadataScan(input: ScanMetadataInput!): String!
|
||||||
"""Start generating content. Returns the job ID"""
|
"""Start generating content. Returns the job ID"""
|
||||||
metadataGenerate(input: GenerateMetadataInput!): String!
|
metadataGenerate(input: GenerateMetadataInput!): String!
|
||||||
"""Clean metadata. Returns the job ID"""
|
"""Clean metadata. Returns the job ID"""
|
||||||
@@ -2070,6 +2075,10 @@ type FindGalleriesResultType {
|
|||||||
previews: Boolean!
|
previews: Boolean!
|
||||||
markers: Boolean!
|
markers: Boolean!
|
||||||
transcodes: Boolean!
|
transcodes: Boolean!
|
||||||
|
}
|
||||||
|
|
||||||
|
input ScanMetadataInput {
|
||||||
|
nameFromMetadata: Boolean!
|
||||||
}`},
|
}`},
|
||||||
&ast.Source{Name: "graphql/schema/types/performer.graphql", Input: `type Performer {
|
&ast.Source{Name: "graphql/schema/types/performer.graphql", Input: `type Performer {
|
||||||
id: ID!
|
id: ID!
|
||||||
@@ -2803,6 +2812,20 @@ func (ec *executionContext) field_Query_metadataGenerate_args(ctx context.Contex
|
|||||||
return args, nil
|
return args, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ec *executionContext) field_Query_metadataScan_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
|
||||||
|
var err error
|
||||||
|
args := map[string]interface{}{}
|
||||||
|
var arg0 ScanMetadataInput
|
||||||
|
if tmp, ok := rawArgs["input"]; ok {
|
||||||
|
arg0, err = ec.unmarshalNScanMetadataInput2githubᚗcomᚋstashappᚋstashᚋpkgᚋmodelsᚐScanMetadataInput(ctx, tmp)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
args["input"] = arg0
|
||||||
|
return args, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (ec *executionContext) field_Query_sceneMarkerTags_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
|
func (ec *executionContext) field_Query_sceneMarkerTags_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
|
||||||
var err error
|
var err error
|
||||||
args := map[string]interface{}{}
|
args := map[string]interface{}{}
|
||||||
@@ -5357,10 +5380,17 @@ func (ec *executionContext) _Query_metadataScan(ctx context.Context, field graph
|
|||||||
IsMethod: true,
|
IsMethod: true,
|
||||||
}
|
}
|
||||||
ctx = graphql.WithResolverContext(ctx, rctx)
|
ctx = graphql.WithResolverContext(ctx, rctx)
|
||||||
|
rawArgs := field.ArgumentMap(ec.Variables)
|
||||||
|
args, err := ec.field_Query_metadataScan_args(ctx, rawArgs)
|
||||||
|
if err != nil {
|
||||||
|
ec.Error(ctx, err)
|
||||||
|
return graphql.Null
|
||||||
|
}
|
||||||
|
rctx.Args = args
|
||||||
ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)
|
ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)
|
||||||
resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
|
resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
|
||||||
ctx = rctx // use context from middleware stack in children
|
ctx = rctx // use context from middleware stack in children
|
||||||
return ec.resolvers.Query().MetadataScan(rctx)
|
return ec.resolvers.Query().MetadataScan(rctx, args["input"].(ScanMetadataInput))
|
||||||
})
|
})
|
||||||
if resTmp == nil {
|
if resTmp == nil {
|
||||||
if !ec.HasError(rctx) {
|
if !ec.HasError(rctx) {
|
||||||
@@ -8623,6 +8653,24 @@ func (ec *executionContext) unmarshalInputPerformerUpdateInput(ctx context.Conte
|
|||||||
return it, nil
|
return it, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ec *executionContext) unmarshalInputScanMetadataInput(ctx context.Context, v interface{}) (ScanMetadataInput, error) {
|
||||||
|
var it ScanMetadataInput
|
||||||
|
var asMap = v.(map[string]interface{})
|
||||||
|
|
||||||
|
for k, v := range asMap {
|
||||||
|
switch k {
|
||||||
|
case "nameFromMetadata":
|
||||||
|
var err error
|
||||||
|
it.NameFromMetadata, err = ec.unmarshalNBoolean2bool(ctx, v)
|
||||||
|
if err != nil {
|
||||||
|
return it, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return it, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (ec *executionContext) unmarshalInputSceneFilterType(ctx context.Context, v interface{}) (SceneFilterType, error) {
|
func (ec *executionContext) unmarshalInputSceneFilterType(ctx context.Context, v interface{}) (SceneFilterType, error) {
|
||||||
var it SceneFilterType
|
var it SceneFilterType
|
||||||
var asMap = v.(map[string]interface{})
|
var asMap = v.(map[string]interface{})
|
||||||
@@ -11454,6 +11502,10 @@ func (ec *executionContext) unmarshalNPerformerUpdateInput2githubᚗcomᚋstasha
|
|||||||
return ec.unmarshalInputPerformerUpdateInput(ctx, v)
|
return ec.unmarshalInputPerformerUpdateInput(ctx, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ec *executionContext) unmarshalNScanMetadataInput2githubᚗcomᚋstashappᚋstashᚋpkgᚋmodelsᚐScanMetadataInput(ctx context.Context, v interface{}) (ScanMetadataInput, error) {
|
||||||
|
return ec.unmarshalInputScanMetadataInput(ctx, v)
|
||||||
|
}
|
||||||
|
|
||||||
func (ec *executionContext) marshalNScene2githubᚗcomᚋstashappᚋstashᚋpkgᚋmodelsᚐScene(ctx context.Context, sel ast.SelectionSet, v Scene) graphql.Marshaler {
|
func (ec *executionContext) marshalNScene2githubᚗcomᚋstashappᚋstashᚋpkgᚋmodelsᚐScene(ctx context.Context, sel ast.SelectionSet, v Scene) graphql.Marshaler {
|
||||||
return ec._Scene(ctx, sel, &v)
|
return ec._Scene(ctx, sel, &v)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -153,6 +153,10 @@ type PerformerUpdateInput struct {
|
|||||||
Image *string `json:"image"`
|
Image *string `json:"image"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ScanMetadataInput struct {
|
||||||
|
NameFromMetadata bool `json:"nameFromMetadata"`
|
||||||
|
}
|
||||||
|
|
||||||
type SceneFileType struct {
|
type SceneFileType struct {
|
||||||
Size *string `json:"size"`
|
Size *string `json:"size"`
|
||||||
Duration *float64 `json:"duration"`
|
Duration *float64 `json:"duration"`
|
||||||
|
|||||||
@@ -1,13 +1,10 @@
|
|||||||
import {
|
import {
|
||||||
Alert,
|
Alert,
|
||||||
Button,
|
Button,
|
||||||
|
Checkbox,
|
||||||
Divider,
|
Divider,
|
||||||
FormGroup,
|
FormGroup,
|
||||||
H1,
|
|
||||||
H4,
|
H4,
|
||||||
H6,
|
|
||||||
InputGroup,
|
|
||||||
Tag,
|
|
||||||
} from "@blueprintjs/core";
|
} from "@blueprintjs/core";
|
||||||
import React, { FunctionComponent, useState } from "react";
|
import React, { FunctionComponent, useState } from "react";
|
||||||
import * as GQL from "../../../core/generated-graphql";
|
import * as GQL from "../../../core/generated-graphql";
|
||||||
@@ -21,6 +18,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 [nameFromMetadata, setNameFromMetadata] = useState<boolean>(true);
|
||||||
|
|
||||||
function onImport() {
|
function onImport() {
|
||||||
setIsImportAlertOpen(false);
|
setIsImportAlertOpen(false);
|
||||||
@@ -48,7 +46,7 @@ export const SettingsTasksPanel: FunctionComponent<IProps> = (props: IProps) =>
|
|||||||
|
|
||||||
async function onScan() {
|
async function onScan() {
|
||||||
try {
|
try {
|
||||||
await StashService.queryMetadataScan();
|
await StashService.queryMetadataScan({nameFromMetadata});
|
||||||
ToastUtils.success("Started scan");
|
ToastUtils.success("Started scan");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
ErrorUtils.handle(e);
|
ErrorUtils.handle(e);
|
||||||
@@ -65,6 +63,11 @@ export const SettingsTasksPanel: FunctionComponent<IProps> = (props: IProps) =>
|
|||||||
labelFor="scan"
|
labelFor="scan"
|
||||||
inline={true}
|
inline={true}
|
||||||
>
|
>
|
||||||
|
<Checkbox
|
||||||
|
checked={nameFromMetadata}
|
||||||
|
label="Set name from metadata (if present)"
|
||||||
|
onChange={() => setNameFromMetadata(!nameFromMetadata)}
|
||||||
|
/>
|
||||||
<Button id="scan" text="Scan" onClick={() => onScan()} />
|
<Button id="scan" text="Scan" onClick={() => onScan()} />
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
<Divider />
|
<Divider />
|
||||||
|
|||||||
@@ -175,9 +175,10 @@ export class StashService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static queryMetadataScan() {
|
public static queryMetadataScan(input: GQL.ScanMetadataInput) {
|
||||||
return StashService.client.query<GQL.MetadataScanQuery>({
|
return StashService.client.query<GQL.MetadataScanQuery>({
|
||||||
query: GQL.MetadataScanDocument,
|
query: GQL.MetadataScanDocument,
|
||||||
|
variables: { input },
|
||||||
fetchPolicy: "network-only",
|
fetchPolicy: "network-only",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* tslint:disable */
|
/* tslint:disable */
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
// Generated in 2019-08-23T07:28:41+10:00
|
// Generated in 2019-10-12T18:20:41+11:00
|
||||||
export type Maybe<T> = T | undefined;
|
export type Maybe<T> = T | undefined;
|
||||||
|
|
||||||
export interface SceneFilterType {
|
export interface SceneFilterType {
|
||||||
@@ -54,6 +54,10 @@ export interface PerformerFilterType {
|
|||||||
filter_favorites?: Maybe<boolean>;
|
filter_favorites?: Maybe<boolean>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ScanMetadataInput {
|
||||||
|
nameFromMetadata: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
export interface GenerateMetadataInput {
|
export interface GenerateMetadataInput {
|
||||||
sprites: boolean;
|
sprites: boolean;
|
||||||
|
|
||||||
@@ -875,7 +879,9 @@ export type MetadataExportQuery = {
|
|||||||
metadataExport: string;
|
metadataExport: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type MetadataScanVariables = {};
|
export type MetadataScanVariables = {
|
||||||
|
input: ScanMetadataInput;
|
||||||
|
};
|
||||||
|
|
||||||
export type MetadataScanQuery = {
|
export type MetadataScanQuery = {
|
||||||
__typename?: "Query";
|
__typename?: "Query";
|
||||||
@@ -2425,8 +2431,8 @@ export function useMetadataExport(
|
|||||||
>(MetadataExportDocument, baseOptions);
|
>(MetadataExportDocument, baseOptions);
|
||||||
}
|
}
|
||||||
export const MetadataScanDocument = gql`
|
export const MetadataScanDocument = gql`
|
||||||
query MetadataScan {
|
query MetadataScan($input: ScanMetadataInput!) {
|
||||||
metadataScan
|
metadataScan(input: $input)
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
export function useMetadataScan(
|
export function useMetadataScan(
|
||||||
|
|||||||
Reference in New Issue
Block a user