diff --git a/ui/v2.5/src/components/Tagger/StashSearchResult.tsx b/ui/v2.5/src/components/Tagger/StashSearchResult.tsx index c823a8c48..75d3f45de 100755 --- a/ui/v2.5/src/components/Tagger/StashSearchResult.tsx +++ b/ui/v2.5/src/components/Tagger/StashSearchResult.tsx @@ -46,7 +46,10 @@ const getDurationStatus = ( ); - const minDiff = Math.min(scene.duration, ...durations); + const minDiff = Math.min( + Math.abs(scene.duration - stashDuration), + ...durations + ); return
Duration off by at least {Math.floor(minDiff)}s
; }; diff --git a/ui/v2.5/src/components/Tagger/Tagger.tsx b/ui/v2.5/src/components/Tagger/Tagger.tsx index 24e94dac4..f4b089fc0 100755 --- a/ui/v2.5/src/components/Tagger/Tagger.tsx +++ b/ui/v2.5/src/components/Tagger/Tagger.tsx @@ -2,6 +2,7 @@ import React, { useEffect, useRef, useState } from "react"; import { Button, Card, Form, InputGroup } from "react-bootstrap"; import { Link } from "react-router-dom"; import { HashLink } from "react-router-hash-link"; +import { uniqBy } from "lodash"; import { ScenePreview } from "src/components/Scenes/SceneCard"; import { useLocalForage } from "src/hooks"; @@ -333,11 +334,17 @@ const TaggerList: React.FC = ({ config.mode, config.blacklist ); - const fingerprintMatch = - fingerprints[scene.checksum ?? ""] ?? - fingerprints[scene.oshash ?? ""] ?? - fingerprints[scene.phash ?? ""] ?? - null; + + // Get all scenes matching one of the fingerprints, and return array of unique scenes + const fingerprintMatches = uniqBy( + [ + ...(fingerprints[scene.checksum ?? ""] ?? []), + ...(fingerprints[scene.oshash ?? ""] ?? []), + ...(fingerprints[scene.phash ?? ""] ?? []), + ].flat(), + (f) => f.stash_id + ); + const isTagged = taggedScenes[scene.id]; const hasStashIDs = scene.stash_ids.length > 0; const width = scene.file.width ? scene.file.width : 0; @@ -432,9 +439,9 @@ const TaggerList: React.FC = ({ } let searchResult; - if (fingerprintMatch && !isTagged && !hasStashIDs) { + if (fingerprintMatches.length > 0 && !isTagged && !hasStashIDs) { searchResult = sortScenesByDuration( - fingerprintMatch, + fingerprintMatches, scene.file.duration ?? 0 ).map((match, i) => ( = ({ } else if ( searchResults[scene.id]?.length > 0 && !isTagged && - !fingerprintMatch + fingerprintMatches.length === 0 ) { searchResult = (
    @@ -495,7 +502,7 @@ const TaggerList: React.FC = ({ ); } - return hideUnmatched && !fingerprintMatch ? null : ( + return hideUnmatched && fingerprintMatches.length === 0 ? null : (
    diff --git a/ui/v2.5/src/components/Tagger/utils.ts b/ui/v2.5/src/components/Tagger/utils.ts index c669a7769..3eec89786 100644 --- a/ui/v2.5/src/components/Tagger/utils.ts +++ b/ui/v2.5/src/components/Tagger/utils.ts @@ -179,6 +179,15 @@ export const sortScenesByDuration = ( if (aDur.length > 0 && bDur.length === 0) return -1; if (aDur.length === 0 && bDur.length > 0) return 1; + const aMatches = aDur.filter((match) => match <= 5); + const bMatches = bDur.filter((match) => match <= 5); + + if (aMatches.length > 0 || bMatches.length > 0) { + if (aMatches.length > bMatches.length) return -1; + if (aMatches.length < bMatches.length) return 1; + return 0; + } + const aDiff = Math.min(...aDur); const bDiff = Math.min(...bDur);