Skip to content

Commit

Permalink
Merge pull request #16 from ynput/enhancement/OP-8103_thumbnail_subse…
Browse files Browse the repository at this point in the history
…t_filtering
  • Loading branch information
mkolar authored Feb 12, 2024
2 parents a91e2a4 + 53b2791 commit 64043c2
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
22 changes: 22 additions & 0 deletions client/ayon_core/plugins/publish/extract_thumbnail.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
import subprocess
import tempfile
import re

import pyblish.api
from ayon_core.lib import (
Expand Down Expand Up @@ -50,6 +51,7 @@ class ExtractThumbnail(pyblish.api.InstancePlugin):
# attribute presets from settings
oiiotool_defaults = None
ffmpeg_args = None
product_names = []

def process(self, instance):
# run main process
Expand Down Expand Up @@ -104,6 +106,26 @@ def _main_process(self, instance):
self.log.debug("Skipping crypto passes.")
return

# We only want to process the subsets needed from settings.
def validate_string_against_patterns(input_str, patterns):
for pattern in patterns:
if re.match(pattern, input_str):
return True
return False

product_names = self.product_names
if product_names:
result = validate_string_against_patterns(
instance.data["subset"], product_names
)
if not result:
self.log.debug(
"Product name \"{}\" did not match settings filters: {}".format(
instance.data["subset"], product_names
)
)
return

# first check for any explicitly marked representations for thumbnail
explicit_repres = self._get_explicit_repres_for_thumbnail(instance)
if explicit_repres:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
},
"ExtractThumbnail": {
"enabled": true,
"subsets": [],
"integrate_thumbnail": false,
"background_color": [
0,
Expand Down
5 changes: 5 additions & 0 deletions server/settings/publish_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ class ExtractThumbnailOIIODefaultsModel(BaseSettingsModel):
class ExtractThumbnailModel(BaseSettingsModel):
_isGroup = True
enabled: bool = SettingsField(True)
product_names: list[str] = SettingsField(
default_factory=list,
title="Product names"
)
integrate_thumbnail: bool = SettingsField(
True,
title="Integrate Thumbnail Representation"
Expand Down Expand Up @@ -844,6 +848,7 @@ class PublishPuginsModel(BaseSettingsModel):
},
"ExtractThumbnail": {
"enabled": True,
"product_names": [],
"integrate_thumbnail": True,
"target_size": {
"type": "source"
Expand Down

0 comments on commit 64043c2

Please sign in to comment.