Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Thumbnail product filtering #6197

Merged
merged 2 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions openpype/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 openpype.lib import (
Expand All @@ -14,9 +15,10 @@
path_to_subprocess_arg,
run_subprocess,
)
from openpype.lib.transcoding import convert_colorspace

from openpype.lib.transcoding import VIDEO_EXTENSIONS
from openpype.lib.transcoding import (
convert_colorspace,
VIDEO_EXTENSIONS,
)


class ExtractThumbnail(pyblish.api.InstancePlugin):
Expand Down Expand Up @@ -49,6 +51,8 @@ class ExtractThumbnail(pyblish.api.InstancePlugin):
# attribute presets from settings
oiiotool_defaults = None
ffmpeg_args = None
subsets = []
product_names = []

def process(self, instance):
# run main process
Expand Down Expand Up @@ -103,6 +107,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
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(
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
1 change: 1 addition & 0 deletions openpype/settings/defaults/project_settings/global.json
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
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,12 @@
"key": "enabled",
"label": "Enabled"
},
{
"type": "list",
"object_type": "text",
"key": "subsets",
"label": "Subsets"
},
{
"type": "boolean",
"key": "integrate_thumbnail",
Expand Down
5 changes: 5 additions & 0 deletions server_addon/core/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
2 changes: 1 addition & 1 deletion server_addon/core/server/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.1.4"
__version__ = "0.1.5"
Loading