Blender Kitsu: Move Render Review into Blender Kitsu #296

Merged
7 changed files with 55 additions and 87 deletions
Showing only changes of commit 466ba38a9f - Show all commits

View File

@ -23,7 +23,6 @@ import bpy
from . import ( from . import (
util, util,
props, props,
core,
opsdata, opsdata,
checksqe, checksqe,
ops, ops,
@ -40,7 +39,6 @@ if _need_reload:
util = importlib.reload(util) util = importlib.reload(util)
props = importlib.reload(props) props = importlib.reload(props)
core = importlib.reload(core)
opsdata = importlib.reload(opsdata) opsdata = importlib.reload(opsdata)
checksqe = importlib.reload(checksqe) checksqe = importlib.reload(checksqe)
ops = importlib.reload(ops) ops = importlib.reload(ops)

View File

@ -1,69 +0,0 @@
# ***** BEGIN GPL LICENSE BLOCK *****
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# ***** END GPL LICENCE BLOCK *****
#
# (c) 2021, Blender Foundation - Paul Golter
from typing import List, Dict, Union, Any, Set, Optional
import bpy
from . import util
from .. import cache, types, prefs
from ..sqe import opsdata, pull, push
from ..logger import LoggerFactory
logger = LoggerFactory.getLogger()
def is_active_project() -> bool:
return bool(cache.project_active_get())
# TODO De-duplicate code from sqe code
def link_strip_by_name(
context: bpy.types.Context,
strip: bpy.types.Sequence,
shot_name: str,
sequence_name: str,
) -> None:
# Get seq and shot.
active_project = cache.project_active_get()
seq = active_project.get_sequence_by_name(sequence_name)
shot = active_project.get_shot_by_name(seq, shot_name)
if not shot:
logger.error("Unable to find shot %s on kitsu", shot_name)
return
# Pull shot meta.
pull.shot_meta(strip, shot)
# Rename strip.
strip.name = shot.name
# Pull sequence color.
opsdata.append_sequence_color(context, seq)
# Log.
t = "Linked strip: %s to shot: %s with ID: %s" % (
strip.name,
shot.name,
shot.id,
)
logger.info(t)
util.redraw_ui()

View File

@ -28,7 +28,7 @@ from collections import OrderedDict
import bpy import bpy
from . import vars, opsdata, util, core from . import vars, opsdata, util
from .. import prefs, cache from .. import prefs, cache
from ..sqe import opsdata as seq_opsdata from ..sqe import opsdata as seq_opsdata
from ..logger import LoggerFactory from ..logger import LoggerFactory
@ -145,7 +145,7 @@ class RR_OT_sqe_create_review_session(bpy.types.Operator):
# Perform kitsu operations if enabled. # Perform kitsu operations if enabled.
if prefs.session_auth(context) and imported_strips: if prefs.session_auth(context) and imported_strips:
if core.is_active_project(): if opsdata.is_active_project():
sequence_name = shot_version_folders[0].parent.parent.parent.name sequence_name = shot_version_folders[0].parent.parent.parent.name
# Create metadata strip. # Create metadata strip.
@ -164,7 +164,7 @@ class RR_OT_sqe_create_review_session(bpy.types.Operator):
) )
# Link metadata strip. # Link metadata strip.
core.link_strip_by_name(context, metadata_strip, shot_name, sequence_name) opsdata.link_strip_by_name(context, metadata_strip, shot_name, sequence_name)
else: else:
logger.error( logger.error(

View File

@ -25,8 +25,9 @@ from typing import Set, Union, Optional, List, Dict, Any, Tuple
import bpy import bpy
from . import vars, checksqe from . import vars, checksqe, util
from .. import prefs, cache from .. import prefs, cache
from ..sqe import opsdata as sqe_opsdata
from .exception import NoImageSequenceAvailableException from .exception import NoImageSequenceAvailableException
from ..logger import LoggerFactory from ..logger import LoggerFactory
@ -397,3 +398,34 @@ def setup_color_management(context: bpy.types.Context) -> None:
if context.scene.view_settings.view_transform != 'Standard': if context.scene.view_settings.view_transform != 'Standard':
context.scene.view_settings.view_transform = 'Standard' context.scene.view_settings.view_transform = 'Standard'
logger.info("Set view transform to: Standard") logger.info("Set view transform to: Standard")
def is_active_project() -> bool:
return bool(cache.project_active_get())
def link_strip_by_name(
context: bpy.types.Context,
strip: bpy.types.Sequence,
shot_name: str,
sequence_name: str,
) -> None:
# Get seq and shot.
active_project = cache.project_active_get()
seq = active_project.get_sequence_by_name(sequence_name)
shot = active_project.get_shot_by_name(seq, shot_name)
if not shot:
logger.error("Unable to find shot %s on kitsu", shot_name)
return
sqe_opsdata.link_metadata_strip(context, shot, seq, strip)
# Log.
t = "Linked strip: %s to shot: %s with ID: %s" % (
strip.name,
shot.name,
shot.id,
)
logger.info(t)
util.redraw_ui()

View File

@ -34,8 +34,8 @@ from .ops import (
RR_OT_open_path, RR_OT_open_path,
RR_OT_sqe_push_to_edit, RR_OT_sqe_push_to_edit,
) )
from . import opsdata, core from . import opsdata
from .. import prefs, cache from .. import prefs
class RR_PT_render_review(bpy.types.Panel): class RR_PT_render_review(bpy.types.Panel):
@ -86,7 +86,7 @@ class RR_PT_render_review(bpy.types.Panel):
row.label(text="Kitsu enabled but not logged in", icon="ERROR") row.label(text="Kitsu enabled but not logged in", icon="ERROR")
row.operator("kitsu.session_start", text="Login") row.operator("kitsu.session_start", text="Login")
elif not core.is_active_project(): elif not opsdata.is_active_project():
row = box.row(align=True) row = box.row(align=True)
row.label(text="Kitsu enabled but no active project", icon="ERROR") row.label(text="Kitsu enabled but no active project", icon="ERROR")

View File

@ -592,15 +592,8 @@ class KITSU_OT_sqe_link_shot(bpy.types.Operator):
self.report({"WARNING"}, "ID not found on server: %s" % shot_id) self.report({"WARNING"}, "ID not found on server: %s" % shot_id)
return {"CANCELLED"} return {"CANCELLED"}
# Pull shot meta.
pull.shot_meta(self._strip, shot)
# Rename strip.
self._strip.name = shot.name
# Pull sequence color.
seq = Sequence.by_id(shot.parent_id) seq = Sequence.by_id(shot.parent_id)
opsdata.append_sequence_color(context, seq) opsdata.link_metadata_strip(context, shot, seq, self._strip)
# Log. # Log.
t = "Linked strip: %s to shot: %s with ID: %s" % ( t = "Linked strip: %s to shot: %s with ID: %s" % (

View File

@ -21,7 +21,7 @@
import re import re
from pathlib import Path from pathlib import Path
from typing import Any, Dict, List, Tuple, Union, Optional from typing import Any, Dict, List, Tuple, Union, Optional
from . import pull
import bpy import bpy
from .. import bkglobals, prefs from .. import bkglobals, prefs
from ..logger import LoggerFactory from ..logger import LoggerFactory
@ -265,3 +265,17 @@ def create_metadata_strip(
init_start_frame_offset(strip) init_start_frame_offset(strip)
return strip return strip
def link_metadata_strip(
context, shot: Shot, seq: Sequence, strip: bpy.types.MovieSequence
) -> bpy.types.MovieSequence:
# Pull shot meta.
pull.shot_meta(strip, shot)
# Rename strip.
strip.name = shot.name
# Pull sequence color.
append_sequence_color(context, seq)
return strip