Project

captive

0.0
No commit activity in last 3 years
No release in over 3 years
Captive allows for parsing and converting of subtitles across different formats in addition to JSON
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 12.3, >= 12.3.3
~> 3.9
~> 0.87, >= 0.87.1
 Project Readme

Captive - Ruby Subtitle Editor and Converter

Captive can read subtitles from various formats. Subtitles can be modified and exported to another format as well as JSON. Captive currently supports SRT and WebVTT formats.

Supported Features

  • Read subtitles
  • Convert to another format (SRT, WebVTT)
  • Save to file
  • Serialize as JSON

Usage

Parse subtitles

Subtitles can be read from a file using from_file and providing a filename

s = Captive::SRT.from_file(filename: 'test.srt')

s = Captive::VTT.from_file(filename: 'test.vtt')

Alternately, subtitles can be parsed from a blob of text if you don't want to load from a file

s = Captive::SRT.from_blob(filename: 'test.srt')

s = Captive::VTT.from_blob(filename: 'test.vtt')

Or to get instantiate an empty captive object simply

s = Captive::SRT.new

s = Captive::VTT.new

Save to File

Subtitles can be saved to a file using save_as

s = Captive::VTT.from_file(filename: 'test.vtt')
s.save_as(filaname: 'output.vtt')

Serializing as JSON

Need to store your subtitle data in a format agnostic way? as_json is your friend

s = Captive::VTT.from_file(filename: 'test.vtt')
s.as_json

Switch Formats

Subtitles parsed in one format can be converted to another format. Currently, SRT and WebVTT are supported.

s = Captive::SRT.new('test.srt')
vtt = s.as_vtt # Will return a Captive::VTT instance
vtt.save_as(filename: 'conversion.vtt')

Installation

Simply add captive to your Gemfile

gem 'captive'

Or install it yourself with:

$ gem install captive

Dependencies

Captive is lightweight and has no external dependencies.

Development

After cloning the repo, run bundle install to get the development dependencies. Use bin/console to spin up an IRB instance with captive loaded.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/mserran2/captive.

License

The gem is available as open source under the terms of the MIT License.