mirror of https://github.com/stashapp/stash.git
Add codec filters (#3843)
* Add video_codec and audio_codec filter criteria * Add Audio Codec and Video Codec UI filters
This commit is contained in:
parent
93b41fb650
commit
f0d901a697
|
@ -194,6 +194,10 @@ input SceneFilterType {
|
|||
duplicated: PHashDuplicationCriterionInput
|
||||
"""Filter by resolution"""
|
||||
resolution: ResolutionCriterionInput
|
||||
"""Filter by video codec"""
|
||||
video_codec: StringCriterionInput
|
||||
"""Filter by audio codec"""
|
||||
audio_codec: StringCriterionInput
|
||||
"""Filter by duration (in seconds)"""
|
||||
duration: IntCriterionInput
|
||||
"""Filter to only include scenes which have markers. `true` or `false`"""
|
||||
|
|
|
@ -45,6 +45,10 @@ type SceneFilterType struct {
|
|||
Duplicated *PHashDuplicationCriterionInput `json:"duplicated"`
|
||||
// Filter by resolution
|
||||
Resolution *ResolutionCriterionInput `json:"resolution"`
|
||||
// Filter by video codec
|
||||
VideoCodec *StringCriterionInput `json:"video_codec"`
|
||||
// Filter by audio codec
|
||||
AudioCodec *StringCriterionInput `json:"audio_codec"`
|
||||
// Filter by duration (in seconds)
|
||||
Duration *IntCriterionInput `json:"duration"`
|
||||
// Filter to only include scenes which have markers. `true` or `false`
|
||||
|
|
|
@ -926,6 +926,9 @@ func (qb *SceneStore) makeFilter(ctx context.Context, sceneFilter *models.SceneF
|
|||
query.handleCriterion(ctx, floatIntCriterionHandler(sceneFilter.Duration, "video_files.duration", qb.addVideoFilesTable))
|
||||
query.handleCriterion(ctx, resolutionCriterionHandler(sceneFilter.Resolution, "video_files.height", "video_files.width", qb.addVideoFilesTable))
|
||||
|
||||
query.handleCriterion(ctx, codecCriterionHandler(sceneFilter.VideoCodec, "video_files.video_codec", qb.addVideoFilesTable))
|
||||
query.handleCriterion(ctx, codecCriterionHandler(sceneFilter.AudioCodec, "video_files.audio_codec", qb.addVideoFilesTable))
|
||||
|
||||
query.handleCriterion(ctx, hasMarkersCriterionHandler(sceneFilter.HasMarkers))
|
||||
query.handleCriterion(ctx, sceneIsMissingCriterionHandler(qb, sceneFilter.IsMissing))
|
||||
query.handleCriterion(ctx, stringCriterionHandler(sceneFilter.URL, "scenes.url"))
|
||||
|
@ -1201,6 +1204,18 @@ func resolutionCriterionHandler(resolution *models.ResolutionCriterionInput, hei
|
|||
}
|
||||
}
|
||||
|
||||
func codecCriterionHandler(codec *models.StringCriterionInput, codecColumn string, addJoinFn func(f *filterBuilder)) criterionHandlerFunc {
|
||||
return func(ctx context.Context, f *filterBuilder) {
|
||||
if codec != nil {
|
||||
if addJoinFn != nil {
|
||||
addJoinFn(f)
|
||||
}
|
||||
|
||||
stringCriterionHandler(codec, codecColumn)(ctx, f)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func hasMarkersCriterionHandler(hasMarkers *string) criterionHandlerFunc {
|
||||
return func(ctx context.Context, f *filterBuilder) {
|
||||
if hasMarkers != nil {
|
||||
|
|
|
@ -129,6 +129,7 @@
|
|||
"also_known_as": "Also known as",
|
||||
"appears_with": "Appears With",
|
||||
"ascending": "Ascending",
|
||||
"audio_codec": "Audio Codec",
|
||||
"average_resolution": "Average Resolution",
|
||||
"between_and": "and",
|
||||
"birth_year": "Birth Year",
|
||||
|
@ -1259,6 +1260,7 @@
|
|||
"required": "${path} is a required field"
|
||||
},
|
||||
"videos": "Videos",
|
||||
"video_codec": "Video Codec",
|
||||
"view_all": "View All",
|
||||
"weight": "Weight",
|
||||
"weight_kg": "Weight (kg)",
|
||||
|
|
|
@ -107,6 +107,10 @@ export function makeCriteria(
|
|||
return new ResolutionCriterion();
|
||||
case "average_resolution":
|
||||
return new AverageResolutionCriterion();
|
||||
case "video_codec":
|
||||
return new StringCriterion(new StringCriterionOption(type, type));
|
||||
case "audio_codec":
|
||||
return new StringCriterion(new StringCriterionOption(type, type));
|
||||
case "resume_time":
|
||||
case "duration":
|
||||
case "play_duration":
|
||||
|
|
|
@ -75,6 +75,8 @@ const criterionOptions = [
|
|||
new NullNumberCriterionOption("rating", "rating100"),
|
||||
createMandatoryNumberCriterionOption("o_counter"),
|
||||
ResolutionCriterionOption,
|
||||
createStringCriterionOption("video_codec"),
|
||||
createStringCriterionOption("audio_codec"),
|
||||
createMandatoryNumberCriterionOption("duration"),
|
||||
createMandatoryNumberCriterionOption("resume_time"),
|
||||
createMandatoryNumberCriterionOption("play_duration"),
|
||||
|
|
|
@ -109,6 +109,8 @@ export type CriterionType =
|
|||
| "o_counter"
|
||||
| "resolution"
|
||||
| "average_resolution"
|
||||
| "video_codec"
|
||||
| "audio_codec"
|
||||
| "duration"
|
||||
| "favorite"
|
||||
| "hasMarkers"
|
||||
|
|
Loading…
Reference in New Issue