Skip to content

Commit

Permalink
WIP on feature/AY-979_Resolve-update-to-new-publisher
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubjezek001 committed Jul 25, 2024
1 parent 2e7b487 commit 7fca424
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion client/ayon_resolve/api/lib.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import sys
import json
import re
import os
import json
import uuid
import contextlib
from typing import List, Dict, Any
from opentimelineio import opentime
Expand Down Expand Up @@ -40,6 +41,27 @@
self.pype_timeline_name = "OpenPypeTimeline"


def get_timeline_media_pool_item(timeline, root=None):
"""Return MediaPoolItem from Timeline"""

# Due to limitations in the Resolve API we can't get
# the media pool item directly from the timeline.
# We can find it by name, however names are not
# enforced to be unique across bins. So, we give it
# unique name.
original_name = timeline.GetName()
identifier = str(uuid.uuid4().hex)
try:
timeline.SetName(identifier)
for item in iter_all_media_pool_clips(root=root):
if item.GetName() != identifier:
continue
return item
finally:
# Revert to original name
timeline.SetName(original_name)


@contextlib.contextmanager
def maintain_current_timeline(to_timeline: object,
from_timeline: object = None):
Expand Down

0 comments on commit 7fca424

Please sign in to comment.