quote-clipper

Software
Cover image

Quote Clipper

A CLI Tool for finding quotes in series/movies/animes and automatically creating video compilations.

favicon GitHub\ A CLI Tool for creating video compilations of quotes of series/movies/animes automatically - GitHub - victornpb/quote-clipper: A CLI Tool for creating video compilations of quotes of series/movies/...\ https://github.com/victornpb/quote-clipper

Usage

Usage: quoteclipper [OPTIONS] [DIRECTORY]

Options:
  -m, --match TEXT                [required]
  -o, --output PATH               Name of the output movie.  [default:
                                  ./Compilation of {}.mp4]

  -e, --export-clips              Export individual clips
  -ed, --export-clips-dir PATH    Directory to export clips to (must exist)
                                  [default: .]

  -et, --export-clips-template TEXT
                                  Template to be used as clips filenames.
                                  (Variables: n, index, basename, quote,
                                  start, end, duration)  [default: {n} -
                                  {quote}.mp4]

  --dry-run / --no-dry-run        Skip the generation of clips
  -t, --offset <start> <end>      Offset the start and end timestamps. For
                                  example --offset -1.5 1.5 will make each
                                  clip 3s longer.  [default: 0.0, 0.0]

  -c, --case-sensitive            Case sensitive match (ignored by --regex)
  -re, --regex                    Interpret matches as regular expressions.
                                  Example '/foo \w+/i'

  --help                          Show this message and exit.

Examples

Finding occurences of a word

quoteclipper -match Hello

Multiple words

You can use the parameterĀ -mĀ orĀ -matchĀ as many times as you want

# find quotes containing Hello or Hey
quoteclipper -m Hello -m Hi -m Hey

Sentences

You need to use quotes if a sentence contain spaces

quoteclipper -m "Good Morning" -m "Good Night"

Specifying a folder

The last argument is the path it will scan files, by default it scans the current directory.

# Will look for every video inside the "video" folder
quoteclipper -m Hello "./videos"

Changing the output filename and path

You can change the output file name and location with theĀ --outputĀ orĀ -oĀ parameter.

quoteclipper -m Hello -o "~/Desktop/Greetings.mp4"

Exporting individual clips

You can also export individual clips withĀ --export-clipsĀ orĀ -e. For changing the default file name and location seeĀ --export-clips-dirĀ andĀ --export-clips-templateĀ in the Help

quoteclipper -m Hello --export-clips

Clip naming

When usingĀ --export-clipsĀ orĀ -eĀ you can change the default naming patter usingĀ --export-clips-templateĀ orĀ -et

  • -export-clips-template "Clip {n} - {quote} from ({basename}).mp4"

Variables:

  • nĀ - number (keep things in sequence and avoid overriding clips)
  • indexĀ - original subtitle index
  • basenameĀ - name of the original file without extension
  • quoteĀ - the quote text
  • startĀ - original start timestamp
  • endĀ - original end timestamp
  • durationĀ - duration of the clip

Extending clips

If you need to add extra time before and after each clip, you can offset the start and end cuts with theĀ --offsetĀ orĀ -t.

# starting 1.5s earlier and 1.5 after (3s longer)
quoteclipper -m Hello --offset -1.5 1.5

Regular expressions

For a more advanced matching, you can use power of python regular expressions by enabling theĀ --regexĀ orĀ -reĀ flag.

Regular expressions need to be delimited byĀ -m "/re/flags"

Case sensitiveness

Regular expressions are case sensitive by default, and theĀ --case-sensitiveĀ orĀ -cĀ flag has no effect when this mode is enabled. To make a regex insensitive add theĀ iĀ flag likeĀ /re/iĀ to each regex.

Escaping

Due to the nature of POSIX commands, you need to use quotes around the regex if it contains spaces, and in some cases you also need to escape extra characters like ! needs to be scaped as "!".

quoteclipper -re -m "/foo/i"
quoteclipper -re -m "/foo/i" -m "/bar/i" 

quoteclipper -re -m "/Call 555.\d+/i" 
quoteclipper -re -m "/Car?s|sandwich(es)?/i"
quoteclipper -re -m "/(Ya?|You)'? ?Know\!/i"

Instalation

Clone this repository and run

pip3 install .