add MetaData from Tracker
parent
e14dc2136d
commit
0e416a2927
27
panels.py
27
panels.py
|
@ -154,10 +154,37 @@ class VSETB_PT_casting(VSETB_main, Panel):
|
||||||
col_tool.operator('sequencer.paste_casting', icon='PASTEDOWN', text="")
|
col_tool.operator('sequencer.paste_casting', icon='PASTEDOWN', text="")
|
||||||
|
|
||||||
|
|
||||||
|
class VSETB_PT_metadata(VSETB_main, Panel):
|
||||||
|
bl_label = "Shot Metadata"
|
||||||
|
bl_parent_id = "VSETB_PT_casting"
|
||||||
|
bl_options = {"DEFAULT_CLOSED"}
|
||||||
|
|
||||||
|
def draw(self, context):
|
||||||
|
layout = self.layout
|
||||||
|
scn = context.scene
|
||||||
|
active_strip = scn.sequence_editor.active_strip
|
||||||
|
|
||||||
|
if not active_strip:
|
||||||
|
return
|
||||||
|
|
||||||
|
settings = get_scene_settings()
|
||||||
|
strip_settings = get_strip_settings()
|
||||||
|
|
||||||
|
project = settings.active_project
|
||||||
|
|
||||||
|
if not project:
|
||||||
|
return
|
||||||
|
|
||||||
|
col = layout.column()
|
||||||
|
for key in strip_settings.metadata.keys():
|
||||||
|
print('key: ', key)
|
||||||
|
col.prop(strip_settings.metadata, key)
|
||||||
|
|
||||||
classes=(
|
classes=(
|
||||||
VSETB_PT_main,
|
VSETB_PT_main,
|
||||||
VSETB_PT_rename,
|
VSETB_PT_rename,
|
||||||
VSETB_PT_casting,
|
VSETB_PT_casting,
|
||||||
|
VSETB_PT_metadata,
|
||||||
)
|
)
|
||||||
|
|
||||||
def register():
|
def register():
|
||||||
|
|
|
@ -44,7 +44,6 @@ def update_episodes(self, context):
|
||||||
def get_tracker_items(self, context):
|
def get_tracker_items(self, context):
|
||||||
return [(norm_str(a.name, format=str.upper), a.name, "", i) for i, a in enumerate(TRACKERS)]
|
return [(norm_str(a.name, format=str.upper), a.name, "", i) for i, a in enumerate(TRACKERS)]
|
||||||
|
|
||||||
|
|
||||||
class Asset(PropertyGroup):
|
class Asset(PropertyGroup):
|
||||||
name : StringProperty(default='')
|
name : StringProperty(default='')
|
||||||
id : StringProperty(default='')
|
id : StringProperty(default='')
|
||||||
|
@ -80,6 +79,21 @@ class AssetCasting(PropertyGroup):
|
||||||
def to_dict(self):
|
def to_dict(self):
|
||||||
return {k: v for k,v in self.items()}
|
return {k: v for k,v in self.items()}
|
||||||
|
|
||||||
|
|
||||||
|
class MetaDataTypes(PropertyGroup):
|
||||||
|
choices : EnumProperty(items=[('NONE', 'None', '', 0)])
|
||||||
|
|
||||||
|
|
||||||
|
class MetaData(PropertyGroup):
|
||||||
|
|
||||||
|
notes : StringProperty()
|
||||||
|
|
||||||
|
def __iter__(self):
|
||||||
|
return (getattr(self, k) for k in self.keys())
|
||||||
|
|
||||||
|
def keys(self):
|
||||||
|
return (p for p in self.bl_rna.properties.keys() if p not in ('rna_type', 'name'))
|
||||||
|
|
||||||
class Episode(PropertyGroup):
|
class Episode(PropertyGroup):
|
||||||
id : StringProperty(default='')
|
id : StringProperty(default='')
|
||||||
|
|
||||||
|
@ -110,15 +124,7 @@ class Project(PropertyGroup):
|
||||||
episode_name : EnumProperty(items=get_episodes_items)
|
episode_name : EnumProperty(items=get_episodes_items)
|
||||||
episodes : CollectionProperty(type=Episode)
|
episodes : CollectionProperty(type=Episode)
|
||||||
assets : CollectionProperty(type=Asset)
|
assets : CollectionProperty(type=Asset)
|
||||||
|
metadata_types : CollectionProperty(type=MetaDataTypes)
|
||||||
|
|
||||||
#FIXME Trouver une solution pour mettre des method dans les CollectionProperty
|
|
||||||
class Projects(PropertyGroup):
|
|
||||||
pass
|
|
||||||
# @property
|
|
||||||
# def active(self):
|
|
||||||
# settings = get_scene_settings()
|
|
||||||
# return self.get(settings.project_name)
|
|
||||||
|
|
||||||
|
|
||||||
class VSETB_UL_casting(UIList):
|
class VSETB_UL_casting(UIList):
|
||||||
|
@ -130,13 +136,13 @@ class VSETB_UL_casting(UIList):
|
||||||
|
|
||||||
settings = get_scene_settings()
|
settings = get_scene_settings()
|
||||||
project = settings.active_project
|
project = settings.active_project
|
||||||
|
|
||||||
# asset = next((a for a in project.assets if a.id == item.id), None)
|
|
||||||
asset = item.asset
|
asset = item.asset
|
||||||
if asset is None:
|
if asset is None:
|
||||||
#TODO deal if asset was removed
|
#TODO deal if asset was removed
|
||||||
pass
|
layout.label(text='Load Assets')
|
||||||
|
return
|
||||||
|
|
||||||
icon_id = asset.icon_id
|
icon_id = asset.icon_id
|
||||||
params = {'icon_value': icon_id} if icon_id else {'icon': 'BLANK1'}
|
params = {'icon_value': icon_id} if icon_id else {'icon': 'BLANK1'}
|
||||||
|
|
||||||
|
@ -189,9 +195,13 @@ class VSETB_PGT_scene_settings(PropertyGroup):
|
||||||
projects : CollectionProperty(type=Project)
|
projects : CollectionProperty(type=Project)
|
||||||
project_name : EnumProperty(items=get_project_items, update=update_episodes)
|
project_name : EnumProperty(items=get_project_items, update=update_episodes)
|
||||||
tracker_name : EnumProperty(items=get_tracker_items)
|
tracker_name : EnumProperty(items=get_tracker_items)
|
||||||
toogle_prefs : BoolProperty(description='Toogle VSE ToolBox Preferences', default=True)
|
|
||||||
|
toogle_prefs : BoolProperty(
|
||||||
|
description='Toogle VSE ToolBox Preferences', default=True)
|
||||||
|
|
||||||
auto_select_strip : BoolProperty(
|
auto_select_strip : BoolProperty(
|
||||||
name='Auto Select Strip',description='Auto select strip', default=True)
|
name='Auto Select Strip',description='Auto select strip', default=True)
|
||||||
|
|
||||||
channel : EnumProperty(
|
channel : EnumProperty(
|
||||||
items=[
|
items=[
|
||||||
('AUDIO', 'Audio', '', 0),
|
('AUDIO', 'Audio', '', 0),
|
||||||
|
@ -203,7 +213,7 @@ class VSETB_PGT_scene_settings(PropertyGroup):
|
||||||
|
|
||||||
sequence_channel_name : StringProperty(
|
sequence_channel_name : StringProperty(
|
||||||
name="Sequences Channel Name", default="Sequences")
|
name="Sequences Channel Name", default="Sequences")
|
||||||
|
|
||||||
shot_channel_name : StringProperty(
|
shot_channel_name : StringProperty(
|
||||||
name="Shot Channel Name", default="Shots")
|
name="Shot Channel Name", default="Shots")
|
||||||
|
|
||||||
|
@ -217,18 +227,46 @@ class VSETB_PGT_scene_settings(PropertyGroup):
|
||||||
project = self.active_project
|
project = self.active_project
|
||||||
if project:
|
if project:
|
||||||
return project.episodes.get(project.episode_name)
|
return project.episodes.get(project.episode_name)
|
||||||
|
"""
|
||||||
|
def load_metadata_types(self):
|
||||||
|
settings = get_scene_settings()
|
||||||
|
print('settings: ', settings)
|
||||||
|
|
||||||
|
for project in settings.projects:
|
||||||
|
print('project: ', project)
|
||||||
|
|
||||||
|
metadata_props = {'__annotations__': {key : StringProperty() for key in project.metadata_types.keys()}}
|
||||||
|
MetadataProps = type(f"{project.name}_MetaData", (PropertyGroup,), metadata_props)
|
||||||
|
bpy.utils.register_class(MetadataProps)
|
||||||
|
|
||||||
|
setattr(VSETB_PGT_strip_settings, 'metadata', PointerProperty(type=MetadataProps))
|
||||||
|
|
||||||
|
# if "__annotations__" not in MetaData.__dict__:
|
||||||
|
# setattr(MetaData, "__annotations__", {})
|
||||||
|
|
||||||
|
# for metadata_type in project.metadata_types:
|
||||||
|
# print('metadata_type: ', metadata_type)
|
||||||
|
# MetaData.__annotations__[metadata_type.name] = StringProperty()
|
||||||
|
|
||||||
|
# bpy.utils.unregister_class(MetaData)
|
||||||
|
# bpy.utils.register_class(MetaData)
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
class VSETB_PGT_strip_settings(PropertyGroup):
|
class VSETB_PGT_strip_settings(PropertyGroup):
|
||||||
casting : CollectionProperty(type=AssetCasting)
|
casting : CollectionProperty(type=AssetCasting)
|
||||||
casting_index : IntProperty(name='Casting Index', default=0)
|
casting_index : IntProperty(name='Casting Index', default=0)
|
||||||
source_name : StringProperty(name='')
|
source_name : StringProperty(name='')
|
||||||
|
metadata : PointerProperty(type=MetaData)
|
||||||
|
|
||||||
|
|
||||||
classes=(
|
classes=(
|
||||||
Asset,
|
Asset,
|
||||||
Episode,
|
|
||||||
Project,
|
|
||||||
AssetCasting,
|
AssetCasting,
|
||||||
|
Episode,
|
||||||
|
MetaData,
|
||||||
|
MetaDataTypes,
|
||||||
|
Project,
|
||||||
VSETB_UL_casting,
|
VSETB_UL_casting,
|
||||||
VSETB_PGT_scene_settings,
|
VSETB_PGT_scene_settings,
|
||||||
VSETB_PGT_strip_settings,
|
VSETB_PGT_strip_settings,
|
||||||
|
@ -242,6 +280,7 @@ def register():
|
||||||
bpy.types.Scene.vsetb_settings = PointerProperty(type=VSETB_PGT_scene_settings)
|
bpy.types.Scene.vsetb_settings = PointerProperty(type=VSETB_PGT_scene_settings)
|
||||||
bpy.types.Sequence.vsetb_strip_settings = PointerProperty(type=VSETB_PGT_strip_settings)
|
bpy.types.Sequence.vsetb_strip_settings = PointerProperty(type=VSETB_PGT_strip_settings)
|
||||||
|
|
||||||
|
# load_metadata_types()
|
||||||
|
|
||||||
def unregister():
|
def unregister():
|
||||||
for cls in reversed(classes):
|
for cls in reversed(classes):
|
||||||
|
|
|
@ -37,9 +37,6 @@ class Kitsu(Tracker):
|
||||||
def get_episode(self, name):
|
def get_episode(self, name):
|
||||||
return gazu.shot.get_episode_by_name(self.project, name)
|
return gazu.shot.get_episode_by_name(self.project, name)
|
||||||
|
|
||||||
def new_episode(self, name):
|
|
||||||
return gazu.shot.new_episode(self.project, name)
|
|
||||||
|
|
||||||
def get_asset_types(self, project):
|
def get_asset_types(self, project):
|
||||||
asset_types = gazu.asset.all_asset_types_for_project(project)
|
asset_types = gazu.asset.all_asset_types_for_project(project)
|
||||||
return {t['id']:t['name'] for t in asset_types}
|
return {t['id']:t['name'] for t in asset_types}
|
||||||
|
@ -53,6 +50,16 @@ class Kitsu(Tracker):
|
||||||
|
|
||||||
return assets
|
return assets
|
||||||
|
|
||||||
|
def get_shots_metadata(self, project):
|
||||||
|
metadata = []
|
||||||
|
for md in gazu.project.all_metadata_descriptors(project):
|
||||||
|
entity_type = md.get('entity_type')
|
||||||
|
field_name = md.get('field_name')
|
||||||
|
if entity_type and entity_type.lower() == 'shot' and field_name:
|
||||||
|
metadata.append(field_name)
|
||||||
|
|
||||||
|
return metadata
|
||||||
|
|
||||||
def download_preview(self, preview_id, filepath):
|
def download_preview(self, preview_id, filepath):
|
||||||
if isinstance(filepath, str):
|
if isinstance(filepath, str):
|
||||||
filepath = Path(filepath)
|
filepath = Path(filepath)
|
||||||
|
|
Loading…
Reference in New Issue