Tagged: 

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #11917
    snovic
    Participant

    Hi, gays, congratulations for new site. Best wishes.
    I like to watch movies, and must do job about serbian (croation) subtitles, mostly in srt format..
    I wish to know, is it possible to make makro witch will correct next two things:
    I)

    If a row of subtitle have 2 lines, and first line not end with doth (so, sentence isn’t finished), and next line begin with capitol letter, makro must correct this to small letter.
    Example

    Wrong

    10
    00:02:59,203 –> 00:03:01,906
    ali porota i sudija Kris Nolan
    Su ga osudili

    Right

    10
    00:02:59,203 –> 00:03:01,906
    ali porota i sudija Kris Nolan
    su ga osudili

    II)

    If a row of subtitle have 2 lines, and first line finish with doth (so, sentence is finished), and next line begin with small letter, makro must correct this to capitol letter.

    Example

    Wrong

    17
    00:03:19,994 –> 00:03:23,130
    “Mekdonald protiv Čikaga”.
    tamo je predsednik.

    Right

    17
    00:03:19,994 –> 00:03:23,130
    “Mekdonald protiv Čikaga”.
    Tamo je predsednik.

    Thanks in advontage.

    #17281
    Stefan
    Participant

    You may want to try this script on COPIES of your srt subtitles files.

    1.) save this script as a textfile with JS extension or as a snippet to the snippet plugin.
    2.) load your srt file
    3.) execute that script one time for every line to modify. The script will tell you if nothing more is found.

    If this works and you have saved this script to a file, you can utilize menu “Macros > Run wit temporary Options…” to let it run more than one time at once.

    This script will:
    1.) Find line with leading dd:dd:dd,ddd
    2.) Check if last non-blank sign of next line is a dot
    3.) If not empty, get content of next line
    4.) If dot was found above; replace first char to upper case, else to lower case

    
    Redraw = false;
    //we use a RegEx search pattern to match first time from strings like: "00:02:59,203 –> 00:03:01,906"
    foundcount = document.selection.Find("^\\d\\d:\\d\\d:\\d\\d,\\d\\d\\d\\s",eeFindNext | eeFindReplaceRegExp);
    
    if(foundcount){
    	//if line starts with something like "00:02:59,203 ", then go one line down:
    	document.selection.LineDown( );
    	//get the last sign of thatline:
    	LineContent = document.GetLine( document.selection.GetActivePointY(eePosLogical) );
    	LineContent = LineContent.replace(/\s+$/,"");
    	LastSign = LineContent.slice(-1);
    	
    	//go again one line down:
    	document.selection.LineDown( );
    	yPos = document.selection.GetActivePointY( eePosLogical );
    	LineContent = document.GetLine( yPos );
    	//if that line is not empty ("If a row of subtitle have 2 lines"):
    	if(LineContent.length > 0){
    
    		//if the last sign was a dot:
    		if(LastSign=="."){
    			//be sure first char is upper case:
    			OUT = LineContent.slice(0,1).toUpperCase() + LineContent.slice(1);
    		}else{
    			//be sure first char is lower case:
    			OUT = LineContent.slice(0,1).toLowerCase()+ LineContent.slice(1);
    		}
    	
    		//replace origin line content:
    		document.selection.SelectLine();
    		document.selection.text = OUT + "\n";
    	}
    }
    else
    	alert("Search pattern not found.");
    document.HighlightFind = false;
    

    HTH?

    #17287
    snovic
    Participant

    Exelent, thank you very much.

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.