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) )

# dst=hdr,vid=blue_planet_e2_the_deep,clip=0,Ypeak=100,Yblack=1,test=0,gtmo=CLAHEW,toneimp=cont_histogram,lce=LCE_Bilateral
# dst=hdr,vid=blue_planet_e2_the_deep,clip=0,Ypeak=100,Yblack=1,test=0,gtmo=CLAHEW,toneimp=cont_histogram,lce=LCE_Bilateral_tonecurve
# dst=hdr,vid=blue_planet_e2_the_deep,clip=0,Ypeak=100,Yblack=1,test=0,gtmo=CLAHEW,toneimp=histogram,lce=LCE_Bilateral
# dst=hdr,vid=blue_planet_e2_the_deep,clip=0,Ypeak=100,Yblack=1,test=0,gtmo=CLAHEW,toneimp=histogram,lce=LCE_Bilateral_tonecurve