pass output filename

This commit is contained in:
j 2018-11-15 12:10:59 +00:00
parent 09e1f2833c
commit 60786749ec

12
edit.py
View file

@ -146,6 +146,9 @@ if __name__ == '__main__':
parser.add_argument('-c', '--config', dest='config', parser.add_argument('-c', '--config', dest='config',
help='config.json containing config', help='config.json containing config',
default='~/.ox/client.json') default='~/.ox/client.json')
parser.add_argument('-o', '--output', dest='output',
help='json output',
default='')
parser.add_argument('url', metavar='url', type=str, parser.add_argument('url', metavar='url', type=str,
help='edit url') help='edit url')
opts = parser.parse_args() opts = parser.parse_args()
@ -255,9 +258,12 @@ if __name__ == '__main__':
if not use_local: if not use_local:
cache_clips(api, videos, use_source, use_pandora) cache_clips(api, videos, use_source, use_pandora)
name = normalize(edit_id) if opts.output:
if sort_by != 'year': name = opts.output.replace('.json', '')
name += '_' + sort_by else:
name = normalize(edit_id)
if sort_by != 'year':
name += '_' + sort_by
if subtitles: if subtitles:
with open('%s.srt' % name, 'wb') as fd: with open('%s.srt' % name, 'wb') as fd:
fd.write(ox.srt.encode(subtitles)) fd.write(ox.srt.encode(subtitles))