forked from voc/intro-outro-generator
-
Notifications
You must be signed in to change notification settings - Fork 2
/
script-Z-preroll-generator.py
executable file
·76 lines (59 loc) · 2.03 KB
/
script-Z-preroll-generator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env python3
import xmlrpc.client
import traceback
import socket
import time
import sys
import os
import renderlib
import c3t_rpc_client as rpc
try:
from termcolor import colored
except ImportError:
def colored(str, col):
return str
print("C3TT preroll generator")
renderlib.debug = True
if os.environ.get('CRS_TOKEN') is None or os.environ.get('CRS_SECRET') is None:
print('CRS_TOKEN or CRS_SECRET is empty. did you source the tracker-scripts-profile?')
sys.exit(1)
ticket_type = 'recording'
ticket_state = 'generating'
host = socket.getfqdn()
url = os.environ['CRS_TRACKER']
token = os.environ['CRS_TOKEN']
secret = os.environ['CRS_SECRET']
filter = {}
if not os.environ.get('CRS_ROOM') is None:
filter['Fahrplan.Room'] = os.environ['CRS_ROOM']
projects = {}
def generatePreroll(ticket):
print(ticket)
projectname = ticket.get('Processing.Prerolls.Slug', ticket['Meta.Acronym'])
if not projectname in projects:
projects[projectname] = renderlib.loadProject(projectname)
project = projects[projectname]
task = project.ticket(ticket)
task.outfile = os.path.join(ticket['Processing.Path.Intros'], ticket['Fahrplan.ID'] + '.dv')
task.workdir = os.path.join(os.getcwd(), projectname, 'artwork')
print(colored("rendering", 'green'))
renderlib.rendertask(task)
if hasattr(project, 'deploy'):
print(colored("deploying", 'green'))
project.deploy(ticket, task)
while True:
print(colored('Asking RPC for {0}-tickets which are ready for state {1}'.format(ticket_type, ticket_state), 'yellow'))
ticket_id = rpc.assignNextUnassignedForState(ticket_type, ticket_state, url, token, host, secret, filter)
if ticket_id != False:
ticket = rpc.getTicketProperties(str(ticket_id), url, token, host, secret)
try:
generatePreroll(ticket)
rpc.setTicketDone(str(ticket_id), url, token, host, secret)
except:
error = str(traceback.format_exc())
print(colored(error, 'red'))
rpc.setTicketFailed(str(ticket_id), error, url, token, host, secret)
else:
print('No ticket found')
print('Sleeping for 30 seconds')
time.sleep(30);