mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 04:44:37 +03:00
Add phash generation and dupe checking (#1158)
This commit is contained in:
@@ -66,7 +66,7 @@ func (c Client) QueryStashBoxScene(queryStr string) ([]*models.ScrapedScene, err
|
||||
}
|
||||
|
||||
// FindStashBoxScenesByFingerprints queries stash-box for scenes using every
|
||||
// scene's MD5 checksum and/or oshash.
|
||||
// scene's MD5/OSHASH checksum, or PHash
|
||||
func (c Client) FindStashBoxScenesByFingerprints(sceneIDs []string) ([]*models.ScrapedScene, error) {
|
||||
ids, err := utils.StringSliceToIntSlice(sceneIDs)
|
||||
if err != nil {
|
||||
@@ -95,6 +95,10 @@ func (c Client) FindStashBoxScenesByFingerprints(sceneIDs []string) ([]*models.S
|
||||
if scene.OSHash.Valid {
|
||||
fingerprints = append(fingerprints, scene.OSHash.String)
|
||||
}
|
||||
|
||||
if scene.Phash.Valid {
|
||||
fingerprints = append(fingerprints, utils.PhashToString(scene.Phash.Int64))
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -189,6 +193,18 @@ func (c Client) SubmitStashBoxFingerprints(sceneIDs []string, endpoint string) (
|
||||
Fingerprint: &fingerprint,
|
||||
})
|
||||
}
|
||||
|
||||
if scene.Phash.Valid && scene.Duration.Valid {
|
||||
fingerprint := graphql.FingerprintInput{
|
||||
Hash: utils.PhashToString(scene.Phash.Int64),
|
||||
Algorithm: graphql.FingerprintAlgorithmPhash,
|
||||
Duration: int(scene.Duration.Float64),
|
||||
}
|
||||
fingerprints = append(fingerprints, graphql.FingerprintSubmission{
|
||||
SceneID: sceneStashID,
|
||||
Fingerprint: &fingerprint,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user