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
base: develop
Are you sure you want to change the base?
Conversation
@@ -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 \ |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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)). |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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{ |
There was a problem hiding this comment.
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{ |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
j.identifyGallery(ctx, gallery, sources) | ||
if countResult.Count > 1 { | ||
// Avoid flooding site | ||
time.Sleep(time.Duration(3+rand.Intn(3)) * time.Second) |
There was a problem hiding this comment.
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?
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.