kelciour / playphrase

Search and play phrases from movies and audiobooks
173 stars 26 forks source link

PlayPhrase

Search for specific words or phrases in subtitle files and watch video fragments with mpv.

Inspired by videogrep and playphrase.me.

Video

YouTube: PlayPhrase for Movies

Usage

At first, run python playphrase.py -i <media_dir> _init_ to generate txt files from srt files that will be used for searching (only the first time or when you add a new movie in the media folder).

After that, use python playphrase.py -i <media_dir> <phrase>

Regular expressions can be used too, for example, \b for word boundary.

Keyboard Shortcuts

Use Enter to move to the next clip or Shift + < and Shift + > to switch between clips, Ctrl + Left and Ctrl + Right to move to the prev/next subtitle, q to close the video player.

More info: https://mpv.io/manual/stable/#keyboard-control

Batch Scripts

The repository contains videogrep.bat (Windows) and videogrep.sh (Linux) files to simplify the user input. Before running it for the first time, edit the file in a text editor and update media_dir path. Use quit, exit or q, x to exit from the batch script.

Here's a quick demo how to set up and run videogrep.bat on Windows (YouTube).

Additional Options:

Optional Configuration Changes

For example, you can modify mpv.conf

autofit=900
geometry=50%:50%

and input.conf

ENTER playlist-next force

More info: https://mpv.io/manual/

Download

See https://github.com/kelciour/playphrase/releases

Usage with AudioBooks

It's possible to use audiobooks as media input. For that purpose there's audiogrep.bat and audiogrep.sh files to simplify user input. But you need to generate subtitles for every audio file. It can be done almost automatically using aeneas. Also csplit can be used to split text of the book by chapters and Pragmatic Segmenter to split chapter's content by "sentences".

Here's example video how it looks like (YouTube):

YouTube: PlayPhrase for AudioBooks

Requirements

Note