proper path join; normalize file names

This commit is contained in:
rlx 2017-08-10 12:04:54 +02:00
parent 4245416b33
commit 46b94fa3e3

11
edit.py
View file

@ -22,11 +22,14 @@ def get_info(api, oshash):
'keys': ['id', 'instances', 'resolution']
})['data']
files[oshash] = {
'path': r['items'][0]['instances'][0]['path'],
'path': os.path.join(prefix, r['items'][0]['instances'][0]['path']),
'resolution': r['items'][0]['resolution']
}
return files[oshash]
def normalize(name):
return name.replace(':', '_').replace('/', '_')
def sort_clips(clips, sort):
reverse = sort.startswith('-')
last = '' if reverse else 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
@ -44,7 +47,7 @@ if __name__ == '__main__':
api = ox.API(base_url + '/api/')
api.signin(**credentials)
edit = api.getEdit(id=edit_id)['data']
with open('%s_info.json' % edit_id, 'w') as fd:
with open('%s_info.json' % normalize(edit_id), 'w') as fd:
json.dump(edit, fd, indent=4, ensure_ascii=False)
videos = []
@ -90,9 +93,9 @@ if __name__ == '__main__':
position += clip['duration']
with open('%s.srt' % edit_id, 'wb') as fd:
with open('%s.srt' % normalize(edit_id), 'wb') as fd:
fd.write(ox.srt.encode(subtitles))
with open('%s.json' % edit_id, 'w') as fd:
with open('%s.json' % normalize(edit_id), 'w') as fd:
json.dump(videos, fd, indent=4, ensure_ascii=False)
with open('files.json', 'w') as fd: