From 02f374af5552ceb09c9e724501be410f42d0b1fc Mon Sep 17 00:00:00 2001 From: Clement Ducarteron Date: Tue, 4 Apr 2023 12:21:45 +0200 Subject: [PATCH] set asset_type on project / assets --- TODO.md | 3 ++- operators/operators.py | 4 ++++ properties.py | 5 +++++ resources/trackers/kitsu.py | 16 ++++++++-------- resources/trackers/tracker_test/trackertest.py | 4 ++-- 5 files changed, 21 insertions(+), 11 deletions(-) diff --git a/TODO.md b/TODO.md index 7fc4bc4..18d8f70 100644 --- a/TODO.md +++ b/TODO.md @@ -3,11 +3,12 @@ In-House Video editing Tools ### Todo -- [ ] Get Set asset_types to project - [ ] implement clear all casting / or choosing by type (enum en expand ?) - [ ] implement copy casting by type (all, chars, props etc...) +- [ ] Faire l'operator d'export ### In Progress ### Done ✓ +- [x] Get Set asset_types to project \ No newline at end of file diff --git a/operators/operators.py b/operators/operators.py index 1893eca..4ee9274 100644 --- a/operators/operators.py +++ b/operators/operators.py @@ -327,6 +327,10 @@ class VSETB_OT_load_projects(Operator): for metadata_data in tracker.get_shots_metadata(project_data): metadata_type = project.metadata_types.add() metadata_type.name = metadata_data + + for asset_type_data in tracker.get_asset_types(project_data): + asset_type = project.asset_types.add() + asset_type.name = asset_type_data['name'] # settings.load_metadata_types() diff --git a/properties.py b/properties.py index ad10b8b..6764b66 100644 --- a/properties.py +++ b/properties.py @@ -79,6 +79,9 @@ class AssetCasting(PropertyGroup): def to_dict(self): return {k: v for k,v in self.items()} +class AssetTypes(PropertyGroup): + choices : EnumProperty(items=[('NONE', 'None', '', 0)]) + class MetaDataTypes(PropertyGroup): choices : EnumProperty(items=[('NONE', 'None', '', 0)]) @@ -126,6 +129,7 @@ class Project(PropertyGroup): episode_name : EnumProperty(items=get_episodes_items) episodes : CollectionProperty(type=Episode) assets : CollectionProperty(type=Asset) + asset_types : CollectionProperty(type=AssetTypes) metadata_types : CollectionProperty(type=MetaDataTypes) @@ -265,6 +269,7 @@ class VSETB_PGT_strip_settings(PropertyGroup): classes=( Asset, AssetCasting, + AssetTypes, Episode, MetaData, MetaDataTypes, diff --git a/resources/trackers/kitsu.py b/resources/trackers/kitsu.py index 9b4450e..94f91ce 100644 --- a/resources/trackers/kitsu.py +++ b/resources/trackers/kitsu.py @@ -38,24 +38,24 @@ class Kitsu(Tracker): return gazu.shot.get_episode_by_name(self.project, name) def get_asset_types(self, project): - asset_types = gazu.asset.all_asset_types_for_project(project) - return {t['id']:t['name'] for t in asset_types} + return gazu.asset.all_asset_types_for_project(project) def get_assets(self, project): - asset_types = self.get_asset_types(project) assets = gazu.asset.all_assets_for_project(project) - - for asset in assets: - asset['asset_type'] = asset_types[asset['entity_type_id']] + entity_types = self.get_asset_types(project) + entity_types_ids = {e['id']: e['name'] for e in entity_types} + + for asset_data in assets: + asset_data['asset_type'] = entity_types_ids[asset_data.pop('entity_type_id')] return assets def get_shots_metadata(self, project): metadata = [] for md in gazu.project.all_metadata_descriptors(project): - entity_type = md.get('entity_type') + asset_type = md.get('asset_type') field_name = md.get('field_name') - if entity_type and entity_type.lower() == 'shot' and field_name: + if asset_type and asset_type.lower() == 'shot' and field_name: metadata.append(field_name) return metadata diff --git a/resources/trackers/tracker_test/trackertest.py b/resources/trackers/tracker_test/trackertest.py index afa65c4..ed85c24 100644 --- a/resources/trackers/tracker_test/trackertest.py +++ b/resources/trackers/tracker_test/trackertest.py @@ -55,9 +55,9 @@ class TrackerTest(Tracker): def get_shots_metadata(self, project): metadata = [] for md in gazu.project.all_metadata_descriptors(project): - entity_type = md.get('entity_type') + asset_type = md.get('asset_type') field_name = md.get('field_name') - if entity_type and entity_type.lower() == 'shot' and field_name: + if asset_type and asset_type.lower() == 'shot' and field_name: metadata.append(field_name) return metadata