Skip to content

Commit

Permalink
Add error handling for missing timeline in media pool
Browse files Browse the repository at this point in the history
- Added a check to handle cases where the timeline is not found in the media pool, raising a NameError.
- Refactored code to set clip color based on a random choice.
  • Loading branch information
jakubjezek001 committed Jul 18, 2024
1 parent 7a8c241 commit e39f5b5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@ def process(self):
timeline_media_pool_item.SetMetadata(
lib.pype_tag_name, json.dumps(publish_data)
)
else:
NameError("Timeline not found in media pool.")
21 changes: 10 additions & 11 deletions client/ayon_resolve/plugins/load/load_editorial_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,17 @@ def load(self, context, name, namespace, data):
break

# Update the metadata
if timeline_media_pool_item:
clip_data = self._get_container_data(
context, data)
clip_data = self._get_container_data(
context, data)

timeline_media_pool_item.SetMetadata(
lib.pype_tag_name, json.dumps(clip_data)
)
timeline_media_pool_item.SetMetadata(
lib.pype_tag_name, json.dumps(clip_data)
)

# set clip color based on random choice
clip_color = self.get_clip_color()
timeline_media_pool_item.SetClipColor(clip_color)

# set clip color based on random choice
clip_color = self.get_clip_color()
print("Clip color: ", clip_color)
timeline_media_pool_item.SetClipColor(clip_color)

# TODO: there are two ways to import timeline resources (representation
# and resources folder) but Resolve seems to ignore any of this
Expand Down Expand Up @@ -135,7 +134,7 @@ def _get_container_data(
return data

def get_clip_color(self):
"""Return clip color based on version data."""
"""Return clip color."""

# list of all available davinci resolve clip colors
colors = [
Expand Down

0 comments on commit e39f5b5

Please sign in to comment.