Hello! I wrote a small script that searches for a given phrase for all subtitles in a folder (and in all subfolders) and shows the corresponding video file from this place. If there were several matches, a playlist will be created, which you can navigate either using "Enter" or "Shift + <" and "Shift +>".
Usage example:
playphrase.exe -i <media_dir> <phrase>
Before the first launch (or when adding new video files with subtitles) it is necessary to generate txt files using the existing srt subtitles that will be used during the search:
playphrase.exe -i <media_dir> _init_
Additional keys:
-e, --ending - automatic transition to the next clip (a kind of offline version of the service playphase.me)
-r, --randomize - move clips
-p, --padding PADDING - is added to the beginning and end of each clip (0.0 seconds by default)
-o, --output FILENAME - saves search results to a file
-d, --demo - just displays the number of matches without opening the video player
-ph, --phrases [GAP_BETWEEN_PHRASES] - the show will not start from the found subtitle line, but a little earlier (if possible, from the beginning of the phrase). If desired, the value GAP_BETWEEN_PHRASES can be set after the --phrases key (1.75 by default). All subtitles, the distance between which is no more than GAP_BETWEEN_PHRASES, will be combined into one phrase.
-l, --limit LIMIT - limit the maximum phrase length (by default 30 seconds)
For the script to work, it is necessary that the name of the file with subtitles coincide with the name of the video file.
When searching, you can use regular expressions.
If None appears in the console, then most likely an error in the search phrase. Perhaps you need to screen some specials. backslashes (\).
There is a ready-made Windows binary on the download page (playphrase.zip archive).
To simplify the introduction of new phrases, you can use the file videogrep.bat (under Windows) or videogrep.sh (under Linux), after having edited it and changed the path to the folder with video files and subtitles in a text editor. To exit, you can type quit, exit or q, x.
If desired, the script can be used with audiobooks, but you will need to pre-generate subtitles for each audio file. To do this, you can use the program aeneas (or online version ), intended primarily for creating EPUB 3 Audio-eBooks . For semi-automatic splitting of a book’s text into chapters, you can use, for example, the console utility csplit , and for further splitting into shorter fragments of the Pragmatic Segmenter .
In short, the sequence is approximately the following (it is assumed that the audiobook is divided into chapters):
Split the text of the book into chapters using csplit. Command example:
csplit "Last Mortal Bond, The - Brian Staveley.txt" /^[0-9]+$/ {*}
csplit "The Lion, the Witch and the Wardrobe.txt" -f "Chapter" -b "_%02d.txt""/^Chapter \w+$/" {*}
Split the text of each chapter with the Pragmatic Segmenter. For partial automation, you can use the script text-segmenter.rb (compiling responses to Stack Overflow).
Generate subtitles for each audio file using aeneas. Command example: