mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
Merge remote-tracking branch 'origin/feature/911-new-traits-based-integrator' into feature/911-new-traits-based-integrator
This commit is contained in:
commit
a5acedba47
5 changed files with 38 additions and 12 deletions
3
.github/workflows/pr_linting.yml
vendored
3
.github/workflows/pr_linting.yml
vendored
|
|
@ -21,6 +21,7 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: astral-sh/ruff-action@v1
|
- uses: astral-sh/ruff-action@v3
|
||||||
with:
|
with:
|
||||||
changed-files: "true"
|
changed-files: "true"
|
||||||
|
version-file: "pyproject.toml"
|
||||||
|
|
|
||||||
|
|
@ -450,7 +450,7 @@ class ExtractThumbnail(pyblish.api.InstancePlugin):
|
||||||
# output arguments from presets
|
# output arguments from presets
|
||||||
jpeg_items.extend(ffmpeg_args.get("output") or [])
|
jpeg_items.extend(ffmpeg_args.get("output") or [])
|
||||||
# we just want one frame from movie files
|
# we just want one frame from movie files
|
||||||
jpeg_items.extend(["-vframes", "1"])
|
jpeg_items.extend(["-frames:v", "1"])
|
||||||
|
|
||||||
if resolution_arg:
|
if resolution_arg:
|
||||||
jpeg_items.extend(resolution_arg)
|
jpeg_items.extend(resolution_arg)
|
||||||
|
|
@ -498,7 +498,7 @@ class ExtractThumbnail(pyblish.api.InstancePlugin):
|
||||||
"-i", video_file_path,
|
"-i", video_file_path,
|
||||||
"-analyzeduration", max_int,
|
"-analyzeduration", max_int,
|
||||||
"-probesize", max_int,
|
"-probesize", max_int,
|
||||||
"-vframes", "1"
|
"-frames:v", "1"
|
||||||
]
|
]
|
||||||
|
|
||||||
# add output file path
|
# add output file path
|
||||||
|
|
|
||||||
|
|
@ -170,7 +170,7 @@ class ExtractThumbnailFromSource(pyblish.api.InstancePlugin):
|
||||||
"-analyzeduration", max_int,
|
"-analyzeduration", max_int,
|
||||||
"-probesize", max_int,
|
"-probesize", max_int,
|
||||||
"-i", src_path,
|
"-i", src_path,
|
||||||
"-vframes", "1",
|
"-frames:v", "1",
|
||||||
dst_path
|
dst_path
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,10 @@ import collections
|
||||||
|
|
||||||
import pyblish.api
|
import pyblish.api
|
||||||
import ayon_api
|
import ayon_api
|
||||||
|
from ayon_api import RequestTypes
|
||||||
from ayon_api.operations import OperationsSession
|
from ayon_api.operations import OperationsSession
|
||||||
|
|
||||||
|
|
||||||
InstanceFilterResult = collections.namedtuple(
|
InstanceFilterResult = collections.namedtuple(
|
||||||
"InstanceFilterResult",
|
"InstanceFilterResult",
|
||||||
["instance", "thumbnail_path", "version_id"]
|
["instance", "thumbnail_path", "version_id"]
|
||||||
|
|
@ -161,6 +163,30 @@ class IntegrateThumbnailsAYON(pyblish.api.ContextPlugin):
|
||||||
return None
|
return None
|
||||||
return os.path.normpath(filled_path)
|
return os.path.normpath(filled_path)
|
||||||
|
|
||||||
|
def _create_thumbnail(self, project_name: str, src_filepath: str) -> str:
|
||||||
|
"""Upload thumbnail to AYON and return its id.
|
||||||
|
|
||||||
|
This is temporary fix of 'create_thumbnail' function in ayon_api to
|
||||||
|
fix jpeg mime type.
|
||||||
|
|
||||||
|
"""
|
||||||
|
mime_type = None
|
||||||
|
with open(src_filepath, "rb") as stream:
|
||||||
|
if b"\xff\xd8\xff" == stream.read(3):
|
||||||
|
mime_type = "image/jpeg"
|
||||||
|
|
||||||
|
if mime_type is None:
|
||||||
|
return ayon_api.create_thumbnail(project_name, src_filepath)
|
||||||
|
|
||||||
|
response = ayon_api.upload_file(
|
||||||
|
f"projects/{project_name}/thumbnails",
|
||||||
|
src_filepath,
|
||||||
|
request_type=RequestTypes.post,
|
||||||
|
headers={"Content-Type": mime_type},
|
||||||
|
)
|
||||||
|
response.raise_for_status()
|
||||||
|
return response.json()["id"]
|
||||||
|
|
||||||
def _integrate_thumbnails(
|
def _integrate_thumbnails(
|
||||||
self,
|
self,
|
||||||
filtered_instance_items,
|
filtered_instance_items,
|
||||||
|
|
@ -179,7 +205,7 @@ class IntegrateThumbnailsAYON(pyblish.api.ContextPlugin):
|
||||||
).format(instance_label))
|
).format(instance_label))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
thumbnail_id = ayon_api.create_thumbnail(
|
thumbnail_id = self._create_thumbnail(
|
||||||
project_name, thumbnail_path
|
project_name, thumbnail_path
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,9 +27,12 @@ class ThumbnailsModel:
|
||||||
entity_type,
|
entity_type,
|
||||||
entity_ids,
|
entity_ids,
|
||||||
):
|
):
|
||||||
thumbnail_paths = set()
|
output = {
|
||||||
|
entity_id: None
|
||||||
|
for entity_id in entity_ids
|
||||||
|
}
|
||||||
if not project_name or not entity_type or not entity_ids:
|
if not project_name or not entity_type or not entity_ids:
|
||||||
return thumbnail_paths
|
return output
|
||||||
|
|
||||||
thumbnail_id_by_entity_id = {}
|
thumbnail_id_by_entity_id = {}
|
||||||
if entity_type == "folder":
|
if entity_type == "folder":
|
||||||
|
|
@ -43,7 +46,7 @@ class ThumbnailsModel:
|
||||||
)
|
)
|
||||||
|
|
||||||
if not thumbnail_id_by_entity_id:
|
if not thumbnail_id_by_entity_id:
|
||||||
return thumbnail_paths
|
return output
|
||||||
|
|
||||||
entity_ids_by_thumbnail_id = collections.defaultdict(set)
|
entity_ids_by_thumbnail_id = collections.defaultdict(set)
|
||||||
for entity_id, thumbnail_id in thumbnail_id_by_entity_id.items():
|
for entity_id, thumbnail_id in thumbnail_id_by_entity_id.items():
|
||||||
|
|
@ -51,10 +54,6 @@ class ThumbnailsModel:
|
||||||
continue
|
continue
|
||||||
entity_ids_by_thumbnail_id[thumbnail_id].add(entity_id)
|
entity_ids_by_thumbnail_id[thumbnail_id].add(entity_id)
|
||||||
|
|
||||||
output = {
|
|
||||||
entity_id: None
|
|
||||||
for entity_id in entity_ids
|
|
||||||
}
|
|
||||||
for thumbnail_id, entity_ids in entity_ids_by_thumbnail_id.items():
|
for thumbnail_id, entity_ids in entity_ids_by_thumbnail_id.items():
|
||||||
thumbnail_path = self._get_thumbnail_path(
|
thumbnail_path = self._get_thumbnail_path(
|
||||||
project_name, entity_type, next(iter(entity_ids)), thumbnail_id
|
project_name, entity_type, next(iter(entity_ids)), thumbnail_id
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue