#!/usr/bin/env python3

import os, sys, io
import json

def main():
  try:
    targets = sys.argv[1:]
  except IndexError:
    targets = []
  result = { 'videos': [] }
  for target in targets:
    if not target or target.lower() in ('-h', '--help'):
      print('Usage: genMakefile [dir]')
      print('Seed your Makefile.config.json with the contents of a directory of your choise.')
      return 1

    #counter = 0
    result['videos'].append({
      'input': [],
      'output': 'build/result.mp4',
      'filter_complex': [ '' ]
    })
    for root, dirs, files in os.walk(target):
      for f in sorted(files):
        result['videos'][0]['input'].append({ 'i': os.path.join(root, f) })
        #counter += 1
  with io.open('Makefile.config.json', 'w') as res:
    json.dump(result, res, indent=2)
    res.write('\n')
    res.flush()
  print('Written to Makefile.config.json!')
  return 0

sys.exit(main())

