upload
This commit is contained in:
+178
-10
@@ -4,6 +4,7 @@ import bpy
|
||||
import importlib
|
||||
import json
|
||||
import re
|
||||
import time
|
||||
import vse_toolbox
|
||||
|
||||
from bpy_extras.io_utils import ImportHelper
|
||||
@@ -29,6 +30,7 @@ from vse_toolbox.constants import (
|
||||
PREVIEWS_DIR,
|
||||
SOUNDS,
|
||||
SOUND_SUFFIXES,
|
||||
TASK_ITEMS
|
||||
)
|
||||
from vse_toolbox.sequencer_utils import (
|
||||
clean_sequencer,
|
||||
@@ -41,8 +43,11 @@ from vse_toolbox.sequencer_utils import (
|
||||
render_strips,
|
||||
set_channels,
|
||||
get_channel_index,
|
||||
new_text_strip
|
||||
new_text_strip,
|
||||
get_strip_render_path,
|
||||
get_strip_sequence_name
|
||||
)
|
||||
|
||||
from vse_toolbox.bl_utils import get_addon_prefs, get_scene_settings, get_strip_settings
|
||||
from vse_toolbox.file_utils import install_module, norm_name, norm_str
|
||||
|
||||
@@ -88,6 +93,133 @@ class VSETB_OT_export_csv(Operator):
|
||||
return {"CANCELLED"}
|
||||
|
||||
|
||||
def get_task_status_items(self, context):
|
||||
settings = get_scene_settings()
|
||||
project = settings.active_project
|
||||
|
||||
status_items = [('CURRENT', 'Current', '')]
|
||||
status_items += [(t.name, t.name, '') for t in project.task_statuses]
|
||||
return status_items
|
||||
|
||||
def get_task_type_items(self, context):
|
||||
settings = get_scene_settings()
|
||||
project = settings.active_project
|
||||
|
||||
return [(t.name, t.name, '') for t in project.task_types]
|
||||
|
||||
class VSETB_OT_upload_to_tracker(Operator):
|
||||
bl_idname = "vse_toolbox.upload_to_tracker"
|
||||
bl_label = "Upload to tracker"
|
||||
bl_description = "Upload selected strip to tracker"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
task: EnumProperty(items=get_task_type_items)
|
||||
status: EnumProperty(items=get_task_status_items)
|
||||
comment : StringProperty()
|
||||
add_preview : BoolProperty(default=False)
|
||||
preview_mode : EnumProperty(items=[(m, m.title().replace('_', ' '), '') for m in ('ONLY_NEW', 'REPLACE', 'ADD')])
|
||||
casting : BoolProperty(default=True)
|
||||
custom_data : BoolProperty(default=True)
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return True
|
||||
|
||||
def invoke(self, context, event):
|
||||
prefs = get_addon_prefs()
|
||||
settings = get_scene_settings()
|
||||
project = settings.active_project
|
||||
|
||||
tracker = prefs.tracker
|
||||
tracker.connect()
|
||||
|
||||
#self.bl_label = f"Upload to {settings.tracker_name.title()}"
|
||||
|
||||
return context.window_manager.invoke_props_dialog(self)
|
||||
|
||||
def draw(self, context):
|
||||
scn = context.scene
|
||||
settings = get_scene_settings()
|
||||
|
||||
layout = self.layout
|
||||
col = layout.column()
|
||||
col.use_property_split = True
|
||||
col.prop(self, 'task', text='Task')
|
||||
col.prop(self, 'status', text='Status')
|
||||
col.prop(self, 'comment', text='Comment')
|
||||
row = col.row(heading='Add Preview')
|
||||
row.prop(self, 'add_preview', text='')
|
||||
row.prop(self, 'preview_mode', text='')
|
||||
col.separator()
|
||||
col.prop(self, 'casting', text='Casting')
|
||||
col.prop(self, 'custom_data', text='Custom Data')
|
||||
|
||||
def execute(self, context):
|
||||
#self.report({'ERROR'}, f'Export not implemented yet.')
|
||||
prefs = get_addon_prefs()
|
||||
settings = get_scene_settings()
|
||||
#project = settings.active_project
|
||||
tracker = prefs.tracker
|
||||
|
||||
status = self.status
|
||||
if status == 'CURRENT':
|
||||
status = None
|
||||
|
||||
for strip in get_strips(channel='Shots', selected_only=True):
|
||||
sequence_name = get_strip_sequence_name(strip)
|
||||
shot_name = strip.name
|
||||
sequence = tracker.get_sequence(sequence_name)
|
||||
|
||||
if not sequence:
|
||||
self.report({"INFO"}, f'Create sequence {sequence_name} in Kitsu')
|
||||
sequence = tracker.new_sequence(sequence_name)
|
||||
|
||||
shot = tracker.get_shot(shot_name, sequence=sequence)
|
||||
if not shot:
|
||||
self.report({"INFO"}, f'Create shot {shot_name} in Kitsu')
|
||||
shot = tracker.new_shot(shot_name, sequence=sequence)
|
||||
|
||||
task = tracker.get_task(self.task, entity=shot)
|
||||
|
||||
print(task)
|
||||
tracker.new_comment(task, comment=self.comment, status=status)
|
||||
#status = tracker.get_task(shot, self.task)
|
||||
# if self.add_preview:
|
||||
# strip_movie_path = Path(get_strip_render_path(strip, template))
|
||||
# if path.exists():
|
||||
|
||||
# else:
|
||||
# self.report({"WARNING"}, f"{strip_movie_path} not exist, skipped")
|
||||
|
||||
|
||||
return {"FINISHED"}
|
||||
|
||||
# if add_to_kitsu:
|
||||
# shot_name = T['shot_tracker_name'].fields['shot'].format(data['shot'])
|
||||
# seq_name = T['sequence_tracker_name'].fields['sequence'].format(data['sequence'])
|
||||
# sequence = p.sequences.add(seq_name)
|
||||
# shot = sequence.shots.add(shot_name)
|
||||
# animatic_task = shot.tasks.add('animatic')
|
||||
|
||||
# animatic_task.comments.new(
|
||||
# comment=f'Reel edit v{version:03d}',
|
||||
# status='done',
|
||||
# preview=movie_output,
|
||||
# set_main_preview=True
|
||||
# )
|
||||
|
||||
# shot_data = {
|
||||
# 'fps': int(FPS),
|
||||
# 'frame_in': strip.frame_final_start,
|
||||
# 'frame_out': strip.frame_final_end-1,
|
||||
# 'nb_frames': strip.frame_final_duration
|
||||
# }
|
||||
|
||||
# shot.update_data(shot_data)
|
||||
|
||||
# return {"CANCELLED"}
|
||||
|
||||
|
||||
class VSETB_OT_auto_select_files(Operator):
|
||||
bl_idname = "import.auto_select_files"
|
||||
bl_label = "Auto Select"
|
||||
@@ -317,8 +449,6 @@ class VSETB_OT_load_projects(Operator):
|
||||
tracker.connect()
|
||||
|
||||
for project_data in tracker.get_projects():
|
||||
|
||||
|
||||
project = settings.projects.add()
|
||||
project.type = project_data['production_type'].upper().replace(' ', '')
|
||||
project.name = project_data['name']
|
||||
@@ -335,6 +465,15 @@ class VSETB_OT_load_projects(Operator):
|
||||
metadata_type = project.metadata_types.add()
|
||||
metadata_type.name = metadata_data['field_name']
|
||||
metadata_type['choices'] = metadata_data['choices']
|
||||
|
||||
for status_data in tracker.get_task_statuses(project_data):
|
||||
#print(metadata_data)
|
||||
task_status = project.task_statuses.add()
|
||||
task_status.name = status_data['short_name'].upper()
|
||||
|
||||
for task_type_data in tracker.get_shot_task_types(project_data):
|
||||
task_type = project.task_types.add()
|
||||
task_type.name = task_type_data['name']
|
||||
|
||||
for asset_type_data in tracker.get_asset_types(project_data):
|
||||
asset_type = project.asset_types.add()
|
||||
@@ -465,11 +604,12 @@ class VSETB_OT_render(Operator):
|
||||
bl_description = "Render Shots Strips"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
selected_only : BoolProperty(name="Selected Only", default=False)
|
||||
#selected_only : BoolProperty(name="Selected Only", default=False)
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return True
|
||||
settings = get_scene_settings()
|
||||
return settings.active_project
|
||||
|
||||
def invoke(self, context, event):
|
||||
scn = context.scene
|
||||
@@ -485,15 +625,20 @@ class VSETB_OT_render(Operator):
|
||||
col = layout.column()
|
||||
col.use_property_split = True
|
||||
col.use_property_decorate = False
|
||||
col.prop(settings, 'channel', text='Channel')
|
||||
col.prop(self, 'selected_only')
|
||||
#col.prop(settings, 'channel', text='Channel')
|
||||
#col.prop(self, 'selected_only')
|
||||
|
||||
col.prop(settings.active_project, "render_template")
|
||||
|
||||
def execute(self, context):
|
||||
scn = context.scene
|
||||
settings = get_scene_settings()
|
||||
strips = get_strips(channel=settings.channel, selected_only=self.selected_only)
|
||||
strips = get_strips(channel='Shots', selected_only=True)
|
||||
|
||||
render_strips(strips)
|
||||
start_time = time.perf_counter()
|
||||
render_strips(strips, settings.active_project.render_template)
|
||||
|
||||
self.report({"INFO"}, f'Strips rendered in {time.perf_counter()-start_time} seconds')
|
||||
|
||||
return {"FINISHED"}
|
||||
|
||||
@@ -522,6 +667,16 @@ class VSETB_OT_set_sequencer(Operator):
|
||||
else:
|
||||
self.report({'INFO'}, f'Cannot set Resolution. No Movie Found.')
|
||||
|
||||
scn.view_settings.view_transform = 'Standard'
|
||||
scn.render.image_settings.file_format = 'FFMPEG'
|
||||
scn.render.ffmpeg.gopsize = 5
|
||||
scn.render.ffmpeg.constant_rate_factor = 'HIGH'
|
||||
scn.render.ffmpeg.format = 'QUICKTIME'
|
||||
scn.render.ffmpeg.audio_codec = 'AAC'
|
||||
scn.render.ffmpeg.audio_codec = 'MP3'
|
||||
scn.render.ffmpeg.audio_mixrate = 44100
|
||||
scn.render.ffmpeg.audio_bitrate = 128
|
||||
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
@@ -744,6 +899,9 @@ class VSETB_OT_set_stamps(Operator):
|
||||
|
||||
bpy.ops.sequencer.select_all(action='DESELECT')
|
||||
|
||||
crop_x = int(scn.render.resolution_x * 0.33)
|
||||
crop_y = int(scn.render.resolution_y * 0.95)
|
||||
|
||||
# Project Name
|
||||
project_strip_stamp = new_text_strip(
|
||||
'project_name_stamp', channel=1, start=scn.frame_start, end=scn.frame_end,
|
||||
@@ -752,6 +910,9 @@ class VSETB_OT_set_stamps(Operator):
|
||||
box_color=(0, 0, 0, 0.5), box_margin=0.005,
|
||||
)
|
||||
|
||||
project_strip_stamp.crop.max_x = crop_x * 2
|
||||
project_strip_stamp.crop.max_y = crop_y
|
||||
|
||||
# Shot Name
|
||||
shot_strip_stamp = new_text_strip(
|
||||
f'shot_name_stamp', channel=2, start=scn.frame_start, end=scn.frame_end,
|
||||
@@ -760,6 +921,10 @@ class VSETB_OT_set_stamps(Operator):
|
||||
box_color=(0, 0, 0, 0.5), box_margin=0.005,
|
||||
)
|
||||
|
||||
shot_strip_stamp.crop.min_x = crop_x
|
||||
shot_strip_stamp.crop.max_x = crop_x
|
||||
shot_strip_stamp.crop.max_y = crop_y
|
||||
|
||||
# Frame Range
|
||||
frame_strip_stamp = new_text_strip(
|
||||
'frame_range_stamp', channel=3, start=scn.frame_start, end=scn.frame_end,
|
||||
@@ -768,6 +933,8 @@ class VSETB_OT_set_stamps(Operator):
|
||||
box_color=(0, 0, 0, 0.5), box_margin=0.005,
|
||||
)
|
||||
|
||||
frame_strip_stamp.crop.min_x = int(scn.render.resolution_x * 0.66)
|
||||
frame_strip_stamp.crop.max_y = crop_y
|
||||
# for shot_strip in get_strips('Shots'):
|
||||
# # Shot Name
|
||||
# shot_strip_stamp = new_text_strip(
|
||||
@@ -806,7 +973,8 @@ classes = (
|
||||
VSETB_OT_render,
|
||||
VSETB_OT_set_sequencer,
|
||||
VSETB_OT_tracker_connect,
|
||||
VSETB_OT_set_stamps
|
||||
VSETB_OT_set_stamps,
|
||||
VSETB_OT_upload_to_tracker
|
||||
)
|
||||
|
||||
def register():
|
||||
|
||||
Reference in New Issue
Block a user