from os import listdir
from os.path import isfile, join

vid_dir = "vclips_small"

header_written = False
entries = 0

with open( "videos.csv", "w" ) as fh:
    for vfile in listdir(vid_dir):
        if vfile.endswith(".mp4") and not vfile.endswith("tonecurve.mp4"):
            fields = vfile[:-4].split(",")

            if not header_written:
                for f in fields:
                    namval = f.split("=")
                    if f != fields[0]:
                        fh.write( ", " )
                    fh.write( namval[0] )                    
                fh.write( "\n" )
                header_written = True

            for f in fields:
                namval = f.split("=")
                if f != fields[0]:
                    fh.write( ", " )
                fh.write( namval[1] )
            fh.write( "\n" )
            entries += 1

print( "Generated a new list of videos with {ent} entries".format(ent=entries) )

