def videogrep(inputfile, outputfile, search, searchtype, maxclips=0, padding=0, test=False, randomize=False, sync=0, use_transcript=False, use_vtt=False, export_clips=False):
    """Search through and find all instances of the search term in an srt or transcript,
    create a supercut around that instance, and output a new video file
    comprised of those supercuts.
    """

    padding = padding / 1000.0
    sync = sync / 1000.0
    composition = []
    foundSearchTerm = False

    if use_transcript:
        composition = compose_from_transcript(inputfile, search, searchtype)
    elif use_vtt:
        vtts = get_vtt_files(inputfile)
        composition = compose_from_vtt(vtts, search, searchtype)
    else:
        srts = get_subtitle_files(inputfile)
        composition = compose_from_srts(srts, search, searchtype)


    # If the search term was not found in any subtitle file...
    if len(composition) == 0:
        print("[!] Search term '" + search + "'" + " was not found in any file.")
        exit(1)

    else:
        print("[+] Search term '" + search + "'" + " was found in " + str(len(composition)) + " places.")

        # apply padding and sync
        for c in composition:
            c['start'] = c['start'] + sync - padding
            c['end'] = c['end'] + sync + padding

        if maxclips > 0:
            composition = composition[:maxclips]

        if randomize is True:
            random.shuffle(composition)

        if test is True:
            demo_supercut(composition, padding)
        else:
            if os.path.splitext(outputfile)[1].lower() == '.edl':
                make_edl(composition, outputfile)
            elif export_clips:
                split_clips(composition, outputfile)
            else:
                if len(composition) > BATCH_SIZE:
                    print("[+} Starting batch job.")
                    create_supercut_in_batches(composition, outputfile, padding)
                else:
                    create_supercut(composition, outputfile, padding)
def videogrep ( inputfile , outputfile , search , searchtype , maxclips = 0 , padding = 0 , test = False , randomize = False , sync = 0 , use_transcript = False , use_vtt = False , export_clips = False ) : padding = padding / 1000.0 sync = sync / 1000.0 composition = [ ] foundSearchTerm = False if use_transcript : composition = compose_from_transcript ( inputfile , search , searchtype ) elif use_vtt : vtts = get_vtt_files ( inputfile ) composition = compose_from_vtt ( vtts , search , searchtype ) else : srts = get_subtitle_files ( inputfile ) composition = compose_from_srts ( srts , search , searchtype ) if len ( composition ) == 0 : print ( "[!] Search term '" + search + "'" + " was not found in any file." ) exit ( 1 ) else : print ( "[+] Search term '" + search + "'" + " was found in " + str ( len ( composition ) ) + " places." ) for c in composition : c [ 'start' ] = c [ 'start' ] + sync - padding c [ 'end' ] = c [ 'end' ] + sync + padding if maxclips > 0 : composition = composition [ : maxclips ] if randomize is True : random . shuffle ( composition ) if test is True : demo_supercut ( composition , padding ) else : if os . path . splitext ( outputfile ) [ 1 ] . lower ( ) == '.edl' : make_edl ( composition , outputfile ) elif export_clips : split_clips ( composition , outputfile ) else : if len ( composition ) > BATCH_SIZE : print ( "[+} Starting batch job." ) create_supercut_in_batches ( composition , outputfile , padding ) else : create_supercut ( composition , outputfile , padding )
Search through and find all instances of the search term in an srt or transcript,
    create a supercut around that instance, and output a new video file
    comprised of those supercuts.