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

Thumbnail product filtering #16

Merged
merged 9 commits into from
Feb 12, 2024
23 changes: 23 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 @@ -49,6 +50,8 @@ class ExtractThumbnail(pyblish.api.InstancePlugin):
# attribute presets from settings
oiiotool_defaults = None
ffmpeg_args = None
subsets = []
tokejepsen marked this conversation as resolved.
Show resolved Hide resolved
product_names = []

def process(self, instance):
# run main process
Expand Down Expand Up @@ -103,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.subsets + self.product_names
tokejepsen marked this conversation as resolved.
Show resolved Hide resolved
if product_names:
result = validate_string_against_patterns(
instance.data["subset"], product_names
)
if not result:
self.log.debug(
"Subset \"{}\" did not match any valid subsets: {}".format(
tokejepsen marked this conversation as resolved.
Show resolved Hide resolved
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
2 changes: 1 addition & 1 deletion client/ayon_core/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# -*- coding: utf-8 -*-
"""Package declaring AYON core addon version."""
__version__ = "0.2.1-dev.1"
__version__ = "0.2.2"
tokejepsen marked this conversation as resolved.
Show resolved Hide resolved
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
Loading