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

feat(blacklist): Automatically add media with blacklisted tags to the blacklist #1306

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

Conversation

benbeauchamp7
Copy link

@benbeauchamp7 benbeauchamp7 commented Jan 25, 2025

Description

This pull request introduces blacktags, which automatically blacklist media based on their tags (keywords). Blacktags are configured on the settings page and processed with the Process Blacktags job, which is configured to run weekly by default.

The job queries discover with each sort option round-robin style, with each sort being queries up to "Limit" times, where limit is configured in the settings just under where tags are entered. This is done so that media is blacklisted as much as possible no matter the sort used on the discover page (I don't want media with blacktags to appear when I sort popularity ascending for example). The default limit is 50 pages, resulting in a maximum of 32,000 blacklist entries per tag (2 media types * 50 pages * 20 entries per page * 16 sort options). The maximum limit is 250, which would cap out at 160,000 entries per tag.

Screenshot (if UI-related)

UI

chrome_XVWinkTagi
chrome_ymiZi0kj1E

Settings:

chrome_CFCZpmFnuH
chrome_pSSdNveEPp
chrome_Q6d25aKuCx

Job:

chrome_Wzg9UWzyce

To-Dos

  • Add copy and paste functionality to keyword setting to allow sharing of blacktag configurations
  • Add blacklist filter to hide media added by blacktag
  • Successful build pnpm build
  • Translation keys pnpm i18n:extract
  • Database migration (if required)
  • More bugtesting before ready for review

Issues Fixed or Closed

@gauthier-th gauthier-th changed the title feat(blacktags): Automatically add media with blacklisted tags to the blacklist feat(blacklist): Automatically add media with blacklisted tags to the blacklist Jan 25, 2025
@benbeauchamp7 benbeauchamp7 force-pushed the develop branch 2 times, most recently from 6221ba8 to 0d6d2d3 Compare January 26, 2025 21:43
@benbeauchamp7
Copy link
Author

That covers the functionality I was planning to implement. The only request I didn't cover from the original issue is an easy way to enable or disable the feature from the settings with a checkbox. I kind-of implemented a way to easily mass-unblock media by running the job without any blacktags configured, which will drop the blacktagged media.

Hoping to open everything up for review tomorrow night, want to do one last pass for bugs and code review

@gauthier-th
Copy link
Collaborator

Genuine question, I didn't look at the code yet: why do you have to implement it using a job? Why can't this be done the same way as the standard blacklist is done, i.e. dismissing the item when it is displayed if the condition matches?

@benbeauchamp7
Copy link
Author

benbeauchamp7 commented Jan 27, 2025 via email

@benbeauchamp7 benbeauchamp7 marked this pull request as ready for review January 27, 2025 23:29
Copy link
Owner

@fallenbagel fallenbagel left a comment

Choose a reason for hiding this comment

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

@benbeauchamp7 please rename it to blacklistTags

@benbeauchamp7
Copy link
Author

Changed all instances to some form of blacklistedTag. Rebased on top of develop (force push did not alter any previous commits)

@benbeauchamp7
Copy link
Author

benbeauchamp7 commented Feb 3, 2025 via email

Copy link

github-actions bot commented Feb 4, 2025

This pull request has merge conflicts. Please resolve the conflicts so the PR can be successfully reviewed and merged.

@github-actions github-actions bot added the merge conflict Cannot merge due to merge conflicts label Feb 4, 2025
@github-actions github-actions bot removed the merge conflict Cannot merge due to merge conflicts label Feb 4, 2025
@benbeauchamp7
Copy link
Author

Rebased on develop, no code was altered in the rebase

server/job/blacklistedTagsProcessor.ts Show resolved Hide resolved
server/job/blacklistedTagsProcessor.ts Show resolved Hide resolved
server/job/blacklistedTagsProcessor.ts Outdated Show resolved Hide resolved
src/components/BlacklistedTagsBadge/index.tsx Outdated Show resolved Hide resolved
server/job/blacklistedTagsProcessor.ts Outdated Show resolved Hide resolved
});

if (blacklistEntry != null) {
// Don't mark manual blacklists with tags
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why?

Copy link
Author

Choose a reason for hiding this comment

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

Because they weren't blacklisted for a tag, they were blacklisted manually. If I added a tag to the db, it would appear in the blacklist as blacklisted by a tag rather than a person. It would also mean it would get dropped at the start of the job, but not re-added if the job didn't find it in one of the tags. It could also get removed if a tag is removed from the setting.

Since it was blacklisted by a human, I felt it should remain as it did before and the job shouldn't touch it.

src/components/BlacklistBlock/index.tsx Outdated Show resolved Hide resolved
src/components/BlacklistBlock/index.tsx Outdated Show resolved Hide resolved
Comment on lines 173 to 212
type BlacklistedTagsCopyButtonProps = {
value: string;
};

const BlacklistedTagsCopyButton = ({
value,
}: BlacklistedTagsCopyButtonProps) => {
const intl = useIntl();
const [isCopied, setCopied] = useClipboard(value, {
successDuration: 1000,
});
const { addToast } = useToasts();

useEffect(() => {
if (isCopied) {
addToast(intl.formatMessage(messages.copyBlacklistedTags), {
appearance: 'info',
autoDismiss: true,
});
}
}, [isCopied, addToast, intl]);

return (
<Tooltip
content={intl.formatMessage(messages.copyBlacklistedTagsTip)}
tooltipConfig={{ followCursor: false }}
>
<button
onClick={(e) => {
e.preventDefault();
setCopied();
}}
className="input-action"
type="button"
>
<ClipboardDocumentIcon />
</button>
</Tooltip>
);
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why don't you use the already existing CopyButton instead of duplicating it here?

Copy link
Author

Choose a reason for hiding this comment

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

I was messing around with the button initially and forgot to merge my changes back into CopyButton. Fixed!

}}
/>

<BlacklistedTagsCopyButton value={value ?? ''} />
Copy link
Collaborator

Choose a reason for hiding this comment

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

You could maybe disable the button if the value is empty?

Copy link
Author

Choose a reason for hiding this comment

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

Good idea, added general CSS support for disabled button.input-actions too

Copy link
Collaborator

@gauthier-th gauthier-th left a comment

Choose a reason for hiding this comment

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

Currently, this will not work when a user search a media that have not been added with the job, i.e. for older movies not present in the discovery sections.
I didn't check if it's possible, but can you think of a convenient way of blacklisting it / hiding it in the search page too?

@benbeauchamp7
Copy link
Author

benbeauchamp7 commented Feb 7, 2025

Thank you for your review!

It looks like Jellyseerr's search uses the /search/multi endpoint here, which unfortunately doesn't have any keyword filtering capabilities. The only way I can think to resolve this is by

  1. Querying every shown tv show/movie's keywords (feels slow and bad)
  2. Increasing the limit setting to hopefully catch those shows

Since the original issue was "my feed's full of the kinda shows I don't want on my TV" I think this sufficiently solves that issue. Is probably worth writing up another issue for the search problem.

@gauthier-th
Copy link
Collaborator

It looks like Jellyseerr's search uses the /search/multi endpoint here, which unfortunately doesn't have any keyword filtering capabilities.

Yep, that's what I was afraid of. I'll look at TMDB forums to see if there is any open issue to add tags in the search response (or create one if there isn't), it would solve our issue.

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.

Add Tag-Based Content Filtering System in Blacklist Settings
3 participants