use addAnnotations
This commit is contained in:
parent
495c9086a4
commit
0b2af37553
1 changed files with 22 additions and 17 deletions
|
@ -828,6 +828,9 @@ class Client(object):
|
|||
i.e.
|
||||
pandora_client ABC transcripts /path/to/transcript.srt
|
||||
'''
|
||||
if not args:
|
||||
print 'Usage: pandora_client ABC transcripts /path/to/transcript.srt'
|
||||
sys.exit(1)
|
||||
item = args[0]
|
||||
layer = args[1]
|
||||
filename = args[2]
|
||||
|
@ -835,13 +838,15 @@ class Client(object):
|
|||
if layer not in layers:
|
||||
print "invalid layer name, choices are: ", ', '.join(layers)
|
||||
sys.exit(1)
|
||||
for s in ox.srt.load(filename):
|
||||
r = self.api.addAnnotation({
|
||||
'item': item,
|
||||
'layer': layer,
|
||||
annotations = [{
|
||||
'in': s['in'],
|
||||
'out': s['out'],
|
||||
'value': s['value'],
|
||||
'value': s['value'].replace('\n', '<br>\n') if layer == 'subtitles' else s['value'],
|
||||
} for s in ox.srt.load(filename)]
|
||||
r = self.api.addAnnotations({
|
||||
'item': item,
|
||||
'layer': layer,
|
||||
'annotations': annotations
|
||||
})
|
||||
if r['status']['code'] == 400:
|
||||
print 'failed'
|
||||
|
|
Loading…
Reference in a new issue