roger.magnusson wrote:You can't get the last rendered job as in find out when in time a job was rendered. But project.GetRenderJobList() has the jobs in the order they were added and you can use project.GetRenderJobStatus(jobId) to find out if it has ever been rendered or is currently being rendered.
You can of course go through all jobs in project.GetRenderJobList() and use TargetDir and OutputFilename to get the properties of the rendered files.
If all you want to do is do something with a file after it was rendered you should trigger a script from the Render Settings > Advanced Settings > Trigger script option instead. See how in the sample provided by BMD: 8_slack_notification_by_render_job.py
Thanks I actually desire something similar but message to telegram. But I'd like to send message only if render job is successful. And I'd prefer everything in one script.
I'm just not that experienced with Python to deal with such complex dictionaries. I would appreciate the help.
My code so far:
- Code: Select all
project = resolve.GetProjectManager().GetCurrentProject()
projname = project.GetName()
RenderType = ['RUS', 'ENG', 'Sound']
timeline = project.GetCurrentTimeline()
timelinename = timeline.GetName()
if timelinename == f"{projname}_ENG":
RenderType = ['ENG', 'Sound']
else:
timeline = project.GetTimelineByIndex(1)
project.SetCurrentTimeline(timeline)
resolve.OpenPage("Deliver")
project.DeleteAllRenderJobs()
if timeline.GetTrackName("audio", 2) != "ENG":
RenderType = ["RUS"]
for type in RenderType:
TargetDir = f"E:/Dropbox (TroomHand)/Папка рабочей группы TroomHand/Nikita_montag/{projname}/{type}"
project.LoadRenderPreset(type)
if type == "ENG":
index = 1
timelinecount = project.GetTimelineCount()
while index <= timelinecount:
timeline = project.GetTimelineByIndex(index)
timelinename = timeline.GetName()
index += 1
print(timelinename)
if timelinename == f"{projname}_ENG":
print(f"start {timelinename}")
project.SetCurrentTimeline(timeline)
else:
timeline = projname
if type == "Sound":
TargetDir = f"E:/Dropbox (TroomHand)/Папка рабочей группы TroomHand/Nikita_montag/{projname}/{type}"
renderset = project.SetRenderSettings({"SelectAllFrames": 1,
"TargetDir": TargetDir,
'CustomName': f"{projname}_{type}"})
project.AddRenderJob()
project.StartRendering()
import time
while True:
if not project.IsRenderingInProgress():
# Confusing Part
TypeLen = len(RenderType)
jobList = project.GetRenderJobList()
# Here we get JobId equal to TypeLen
JobStatus = project.GetRenderJobStatus(TypeLen)
print(JobStatus)
if JobStatus == "Cancelled":
sys.exit(0)
print("telegram started")
import requests
API_link = f'https://api.telegram.org/bot{API}'
sent_message = requests.get(API_link + f'/sendMessage?chat_id={chat_id}&text=Привет, {supervisor}. {projname}_{RenderType}, Готов. Приятного Просмотра. @zzohan619')
break
time.sleep(3)
print("done!")