Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Identify Galleries, much like Identify Scenes #4423

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

github-user-t
Copy link

@github-user-t github-user-t commented Jan 6, 2024

Added Gallery Identify, which is working the same way as the scene identify.

Most of the Gallery Identify code is an exact copy of the Scene Identify, although serving a different purpose. I have my doubts merging the 2 concerns would be beneficial.

Most of the Gallery Identify new code is in the same identify package. Could be split differently. No preference here.

Please also see PR comments in files.

Open to all suggestions for improvements.

Screenshot from 2024-01-05 22-30-44
image

@@ -32,7 +32,12 @@ RUN make flags-release flags-pie stash

# Final Runnable Image
FROM alpine:latest
RUN apk add --no-cache ca-certificates vips-tools ffmpeg
RUN apk add --no-cache --virtual .build-deps gcc python3-dev musl-dev \
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Python was missing from this "quick" image used locally.
Could not test scrapers without it.

Took it from the CI Dockerfile.

@@ -787,23 +800,58 @@ func (qb *GalleryStore) makeQuery(ctx context.Context, galleryFilter *models.Gal
return &query, nil
}

func (qb *GalleryStore) Query(ctx context.Context, galleryFilter *models.GalleryFilterType, findFilter *models.FindFilterType) ([]*models.Gallery, int, error) {
query, err := qb.makeQuery(ctx, galleryFilter, findFilter)
func (qb *GalleryStore) Query(ctx context.Context, options models.GalleryQueryOptions) (*models.GalleryQueryResult, error) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Align on how it work for Scene to be able use the exact same logic.
Multiple changes are just a side of this.

Alternative would've been to create an additional QueryWithOptions method, which would end up of having 2 ways to do the same thing.

@@ -25,15 +25,31 @@ func (r *queryResolver) FindGallery(ctx context.Context, id string) (ret *models

func (r *queryResolver) FindGalleries(ctx context.Context, galleryFilter *models.GalleryFilterType, filter *models.FindFilterType) (ret *FindGalleriesResultType, err error) {
if err := r.withReadTxn(ctx, func(ctx context.Context) error {
galleries, total, err := r.repository.Gallery.Query(ctx, galleryFilter, filter)
var galleries []*models.Gallery
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only related to this method definition change: https://github.com/stashapp/stash/pull/4423/files?diff=split&w=1#r1443579818
No change in behavior expected.

@@ -275,7 +276,8 @@ func testPerformerGalleries(t *testing.T, performerName, expectedRegex string) {
Direction: &direction,
}

db.Gallery.On("Query", mock.Anything, expectedGalleryFilter, expectedFindFilter).Return(galleries, len(galleries), nil).Once()
db.Gallery.On("Query", mock.Anything, gallery.QueryOptions(expectedGalleryFilter, expectedFindFilter, false)).
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only related to this method definition change: https://github.com/stashapp/stash/pull/4423/files?diff=split&w=1#r1443579818
No change in behavior expected.

@@ -1,6 +1,7 @@
package autotag
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only related to this method definition change: https://github.com/stashapp/stash/pull/4423/files?diff=split&w=1#r1443579818
No change in behavior expected.

@@ -1,6 +1,7 @@
package autotag
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only related to this method definition change: https://github.com/stashapp/stash/pull/4423/files?diff=split&w=1#r1443579818
No change in behavior expected.

@@ -15,18 +15,10 @@ import (
"github.com/stashapp/stash/pkg/utils"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code moved to identify_common.go

@@ -516,12 +517,19 @@ func (t *autoTagFilesTask) getCount(ctx context.Context) (int, error) {

imageCount := imageResults.Count

_, galleryCount, err := r.Gallery.Query(ctx, t.makeGalleryFilter(), findFilter)
galleryCount, err := r.Gallery.Query(ctx, models.GalleryQueryOptions{
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only related to this method definition change: https://github.com/stashapp/stash/pull/4423/files?diff=split&w=1#r1443579818
No change in behavior expected.

@@ -64,7 +65,7 @@ func (j *cleanJob) cleanEmptyGalleries(ctx context.Context) {
if err := r.WithTxn(ctx, func(ctx context.Context) error {
found := true
for found {
emptyGalleries, _, err := r.Gallery.Query(ctx, &models.GalleryFilterType{
emptyGalleries, err := gallery.Query(ctx, r.Gallery, &models.GalleryFilterType{
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only related to this method definition change: https://github.com/stashapp/stash/pull/4423/files?diff=split&w=1#r1443579818
No change in behavior expected.


"github.com/stashapp/stash/pkg/models"
)

// QueryOptions returns a GalleryQueryOptions populated with the provided filters.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related to this method definition change to accommodate the same structure for Identify Galleries as of Identify Scenes: https://github.com/stashapp/stash/pull/4423/files?diff=split&w=1#r1443579818


"github.com/stashapp/stash/pkg/models"
)

var ErrEmptyUpdater = errors.New("no fields have been set")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only related to this method definition change: https://github.com/stashapp/stash/pull/4423/files?diff=split&w=1#r1443579818
No change in behavior expected.

if !excluded["image"] {
if len(p.Images) > 0 {
img, err = utils.ProcessImageInput(ctx, p.Images[0])
} else if p.Image != nil && len(*p.Image) > 0 {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now downloading image from URL received in ScrapedPerformer.Image if there's nothing in ScrapedPerformer.Images

@@ -292,6 +292,15 @@ func (c Cache) RegisterPostHooks(ctx context.Context, id int, hookType HookTrigg
})
}

func (c Cache) ExecuteGalleryUpdatePostHooks(ctx context.Context, input models.GalleryUpdateInput, inputFields []string) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about that one.
I duplicated the Scene logic.
Everything seems to be there to make it work.

@github-user-t github-user-t marked this pull request as ready for review January 6, 2024 03:33
j.identifyGallery(ctx, gallery, sources)
if countResult.Count > 1 {
// Avoid flooding site
time.Sleep(time.Duration(3+rand.Intn(3)) * time.Second)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't seen an existing mechanism for this kind of behavior. Is there?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant