Blender Kitsu: Add Episode Support to Edit Export Directory Import/Export #299

Open
Nick Alberelli wants to merge 2 commits from TinyNick/blender-studio-pipeline:feature/episode-support-for-editorial-exports into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
6 changed files with 44 additions and 17 deletions

View File

@ -38,6 +38,12 @@ Sets are more tricky to define, since they can differ even on a shot level. In p
**TV Show Location:** `{project root}/pro/shots/{episode identifier}/{sequence number}/{shot identifier}/{shot identifier}-{task identifier}.blend` **TV Show Location:** `{project root}/pro/shots/{episode identifier}/{sequence number}/{shot identifier}/{shot identifier}-{task identifier}.blend`
## Edit Export
**Standard Location:** `{project root}/shared/editorial/export/{edit name}-v{version}.mp4`
**TV Show Location:** `{project root}/shared/editorial/{episode identifier}/export/{edit name}-v{version}.mp4`
## ##
Example: `prop-dresser_wood.faded-modeling.png` Example: `prop-dresser_wood.faded-modeling.png`

View File

@ -1,5 +1,5 @@
import bpy import bpy
from .. import prefs from .. import prefs, propsdata
import re import re
from pathlib import Path from pathlib import Path
@ -18,7 +18,7 @@ def edit_export_get_all(context: bpy.types.Context):
"""Find all renders in editorial export directory""" """Find all renders in editorial export directory"""
addon_prefs = prefs.addon_prefs_get(context) addon_prefs = prefs.addon_prefs_get(context)
edit_export_path = Path(addon_prefs.edit_export_dir) edit_export_path = propsdata.get_edit_export_dir()
files_list = [ files_list = [
f f

View File

@ -3,7 +3,7 @@ from bpy.types import Sequence, Context
import os import os
from typing import Set, List from typing import Set, List
from pathlib import Path from pathlib import Path
from .. import cache, prefs, util from .. import cache, prefs, util, propsdata
from ..types import Task, TaskStatus from ..types import Task, TaskStatus
from ..playblast.core import override_render_path, override_render_format from ..playblast.core import override_render_path, override_render_format
from . import opsdata from . import opsdata
@ -149,7 +149,13 @@ class KITSU_OT_edit_export_set_version(bpy.types.Operator):
@classmethod @classmethod
def poll(cls, context: bpy.types.Context) -> bool: def poll(cls, context: bpy.types.Context) -> bool:
addon_prefs = prefs.addon_prefs_get(context) addon_prefs = prefs.addon_prefs_get(context)
return bool(addon_prefs.edit_export_dir != "") if addon_prefs.edit_export_dir == "":
cls.poll_message_set("Edit Export Directory is not set, check add-on preferences")
return False
if not propsdata.get_edit_export_dir().exists():
cls.poll_message_set("Edit Export Directory does not exist")
return False
return True
def execute(self, context: bpy.types.Context) -> Set[str]: def execute(self, context: bpy.types.Context) -> Set[str]:
kitsu_props = context.scene.kitsu kitsu_props = context.scene.kitsu

View File

@ -20,7 +20,7 @@
from typing import Any, List, Tuple from typing import Any, List, Tuple
from pathlib import Path from pathlib import Path
from .. import prefs from .. import prefs, propsdata
import bpy import bpy
from ..models import FileListModel from ..models import FileListModel
@ -43,7 +43,7 @@ def init_edit_export_file_model(
addon_prefs = prefs.addon_prefs_get(context) addon_prefs = prefs.addon_prefs_get(context)
kitsu_props = context.scene.kitsu kitsu_props = context.scene.kitsu
edit_export_dir = Path(addon_prefs.edit_export_dir) edit_export_dir = propsdata.get_edit_export_dir()
# Is None if invalid. # Is None if invalid.
if addon_prefs.edit_export_dir == "" or not edit_export_dir.exists(): if addon_prefs.edit_export_dir == "" or not edit_export_dir.exists():

View File

@ -28,7 +28,7 @@ from pathlib import Path
import bpy import bpy
from . import cache, bkglobals from . import cache, bkglobals, propsdata
from .props import get_safely_string_prop from .props import get_safely_string_prop
# TODO: restructure this to not access ops_playblast_data. # TODO: restructure this to not access ops_playblast_data.
@ -608,7 +608,10 @@ class KITSU_addon_preferences(bpy.types.AddonPreferences):
def is_edit_export_root_valid(self) -> bool: def is_edit_export_root_valid(self) -> bool:
if self.edit_export_dir.strip() == "": if self.edit_export_dir.strip() == "":
return False return False
if not Path(self.edit_export_dir).exists(): edit_export_path = Path(self.edit_export_dir)
if '<episode>' in edit_export_path.parts:
edit_export_path = propsdata.get_edit_export_dir()
if not edit_export_path.exists():
return False return False
return True return True

View File

@ -130,12 +130,7 @@ def get_playblast_dir(self: Any) -> str:
else: else:
playblast_dir = addon_prefs.shot_playblast_root_path playblast_dir = addon_prefs.shot_playblast_root_path
# Inject episode name if available (and if specified as <episode>) playblast_dir = set_episode_variable(playblast_dir)
if episode and '<episode>' in playblast_dir.parts:
i = playblast_dir.parts.index('<episode>')
playblast_dir = Path(*playblast_dir.parts[:i]).joinpath(
episode.name, *playblast_dir.parts[i + 1 :]
)
if context_core.is_sequence_context(): if context_core.is_sequence_context():
playblast_dir = playblast_dir / sequence.name / 'sequence_previews' playblast_dir = playblast_dir / sequence.name / 'sequence_previews'
@ -181,14 +176,18 @@ def get_playblast_file(self: Any) -> str:
return Path(self.playblast_dir).joinpath(file_name).as_posix() return Path(self.playblast_dir).joinpath(file_name).as_posix()
def get_edit_export_dir() -> str:
addon_prefs = prefs.addon_prefs_get(bpy.context)
return set_episode_variable(Path(addon_prefs.edit_export_dir))
def get_edit_export_file(self: Any) -> str: def get_edit_export_file(self: Any) -> str:
addon_prefs = prefs.addon_prefs_get(bpy.context) addon_prefs = prefs.addon_prefs_get(bpy.context)
if not bool(addon_prefs.edit_export_dir): export_dir = get_edit_export_dir()
return ""
version = self.edit_export_version version = self.edit_export_version
file_pattern = addon_prefs.edit_export_file_pattern file_pattern = addon_prefs.edit_export_file_pattern
file_name = file_pattern.replace('v###', version) file_name = file_pattern.replace('v###', version)
return Path(addon_prefs.edit_export_dir).joinpath(file_name).as_posix() return export_dir.joinpath(file_name).as_posix()
_active_category_cache_init: bool = False _active_category_cache_init: bool = False
@ -227,3 +226,16 @@ def reset_all_kitsu_props(self: Any, context: bpy.types.Context) -> None:
cache.asset_active_reset(context) cache.asset_active_reset(context)
cache.episode_active_reset(context) cache.episode_active_reset(context)
cache.task_type_active_reset(context) cache.task_type_active_reset(context)
def set_episode_variable(base_path: Path) -> Path:
episode = cache.episode_active_get()
active_project = cache.project_active_get()
if not (
episode
and '<episode>' in base_path.parts
and active_project.production_type == bkglobals.KITSU_TV_PROJECT
):
return base_path
i = base_path.parts.index('<episode>')
return Path(*base_path.parts[:i]).joinpath(episode.name, *base_path.parts[i + 1 :])