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.
|
i.e.
|
||||||
pandora_client ABC transcripts /path/to/transcript.srt
|
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]
|
item = args[0]
|
||||||
layer = args[1]
|
layer = args[1]
|
||||||
filename = args[2]
|
filename = args[2]
|
||||||
|
@ -835,23 +838,25 @@ class Client(object):
|
||||||
if layer not in layers:
|
if layer not in layers:
|
||||||
print "invalid layer name, choices are: ", ', '.join(layers)
|
print "invalid layer name, choices are: ", ', '.join(layers)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
for s in ox.srt.load(filename):
|
annotations = [{
|
||||||
r = self.api.addAnnotation({
|
'in': s['in'],
|
||||||
'item': item,
|
'out': s['out'],
|
||||||
'layer': layer,
|
'value': s['value'].replace('\n', '<br>\n') if layer == 'subtitles' else s['value'],
|
||||||
'in': s['in'],
|
} for s in ox.srt.load(filename)]
|
||||||
'out': s['out'],
|
r = self.api.addAnnotations({
|
||||||
'value': s['value'],
|
'item': item,
|
||||||
})
|
'layer': layer,
|
||||||
if r['status']['code'] == 400:
|
'annotations': annotations
|
||||||
print 'failed'
|
})
|
||||||
sys.exit(1)
|
if r['status']['code'] == 400:
|
||||||
if r['status']['code'] == 403:
|
print 'failed'
|
||||||
print 'permission deinied'
|
sys.exit(1)
|
||||||
sys.exit(1)
|
if r['status']['code'] == 403:
|
||||||
elif r['status']['code'] == 404:
|
print 'permission deinied'
|
||||||
print 'item not found'
|
sys.exit(1)
|
||||||
sys.exit(1)
|
elif r['status']['code'] == 404:
|
||||||
|
print 'item not found'
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
def server(self, args):
|
def server(self, args):
|
||||||
import server
|
import server
|
||||||
|
|
Loading…
Add table
Reference in a new issue