Add representation name filtering to OIIO transcode

Adds support for filtering which representations to transcode based on
regex patterns. The profile now accepts a list of representation name
patterns, and only matching representations will be processed. If no
patterns are specified, all representations are processed.
This commit is contained in:
jakubjezek001 2025-12-18 10:10:48 +01:00
parent ca59ad7bf7
commit ae5eea56fe
No known key found for this signature in database
GPG key ID: 06DBD609ADF27FD9
2 changed files with 24 additions and 3 deletions

View file

@ -1,4 +1,5 @@
import os import os
import re
import copy import copy
import clique import clique
import pyblish.api import pyblish.api
@ -101,7 +102,7 @@ class ExtractOIIOTranscode(publish.Extractor):
for idx, repre in enumerate(list(repres)): for idx, repre in enumerate(list(repres)):
self.log.debug("repre ({}): `{}`".format(idx + 1, repre["name"])) self.log.debug("repre ({}): `{}`".format(idx + 1, repre["name"]))
if not self._repre_is_valid(repre): if not self._repre_is_valid(repre, profile):
continue continue
added_representations = False added_representations = False
@ -382,7 +383,7 @@ class ExtractOIIOTranscode(publish.Extractor):
return profile return profile
def _repre_is_valid(self, repre): def _repre_is_valid(self, repre, profile):
"""Validation if representation should be processed. """Validation if representation should be processed.
Args: Args:
@ -409,7 +410,23 @@ class ExtractOIIOTranscode(publish.Extractor):
"Skipped.".format(repre["name"])) "Skipped.".format(repre["name"]))
return False return False
return True representations = profile["representations"]
repre_name = repre["name"]
# make sure if not representations than it will return True
result = [True]
# check if any of representation patterns match in repre_name
if representations:
result = []
for r_pattern in representations:
if re.match(r_pattern, repre_name):
result.append(True)
break
else:
result.append(False)
return any(result)
def _mark_original_repre_for_deletion(self, repre, profile, added_review): def _mark_original_repre_for_deletion(self, repre, profile, added_review):
"""If new transcoded representation created, delete old.""" """If new transcoded representation created, delete old."""

View file

@ -556,6 +556,10 @@ class ExtractOIIOTranscodeProfileModel(BaseSettingsModel):
default_factory=list, default_factory=list,
title="Product names" title="Product names"
) )
representations: list[str] = SettingsField(
default_factory=list,
title="Representation names"
)
delete_original: bool = SettingsField( delete_original: bool = SettingsField(
True, True,
title="Delete Original Representation", title="Delete Original Representation",