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