make generate more generic

This commit is contained in:
j 2013-07-29 10:54:16 +02:00
parent fcbe201edc
commit 1d4ed3d073

View file

@ -6,8 +6,8 @@ import ox
import os
api = ox.API('https://0xdb.org/api/')
config = json.load(open(os.path.expanduser('~/.ox/client.json')))
api = ox.API(config['url'])
api.signin(username=config['username'], password=config['password'])
def get_files(item):
@ -38,12 +38,12 @@ def get_files(item):
return files
def get_clips(terms):
def get_clips(terms, layer):
clips = []
for term in terms:
r = api.findClips({
"keys":["position","annotations","id","in","out","videoRatio", "parts"],
"query":{"conditions":[{"operator":"=","key":"subtitles","value":term}],
"query":{"conditions":[{"operator":"=","key":layer,"value":term}],
"operator":"&"},
"range":[0,1000],
"sort":[{"operator":"+","key":"position"}],
@ -96,11 +96,12 @@ def get_clips(terms):
if __name__ == "__main__":
import sys
if len(sys.argv) != 3:
print 'usage: %s <term> <output.json>' % sys.argv[0]
if len(sys.argv) != 4:
print 'usage: %s <layer> <term> <output.json>' % sys.argv[0]
sys.exit(1)
terms = [sys.argv[1]]
output = sys.argv[2]
layer = sys.argv[1]
terms = [sys.argv[2]]
output = sys.argv[3]
playlist = get_clips(terms)
with open(output, 'w') as f:
json.dump(playlist, f, indent=2)