ssrt 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 698943f8c637cdefe2108c12735f8ee93e211b4897e5ca258b36e7f91f017f3e
4
+ data.tar.gz: 5fc6d85e3876b60a3f3c14c5e292d48f1796543f00f9eda457f0344b49663ec2
5
+ SHA512:
6
+ metadata.gz: 8e5847c12e916c2b49449a9dde7c7b6aa064381cf97bac213fd8ab69ac022a673b3c79cb7771797007c9b6da03049455b48cb75c8d5eb507e8c87908a989f776
7
+ data.tar.gz: 38b58a61fa147a783d1875fa3442cef41bb36c39621b5395ade6d3a454cc3e6eaf8f99b4dcef28a958e705116d77bbf7390baddcffbb6363cc0f235f8ef377be
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in ssrt.gemspec
6
+ gemspec
7
+
8
+
data/LICENSE.txt ADDED
@@ -0,0 +1,7 @@
1
+ Copyright (c) 2022 Sergio Romero
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,24 @@
1
+ # SSRT
2
+
3
+ SSRT is short for Simple Subtitle Resource Tracks, or Simple SRT. SRT is a file
4
+ format to create video captions. SRT format is repetitive because it requires an
5
+ index and a start and end time for each subtitle. Simple SRT is more
6
+ user-friendly. Write your subtitles in SSRT format and use ssrt2srt to get
7
+ equivalent SRT file.
8
+
9
+ For example, create a file test.ssrt with:
10
+
11
+ 00:00:2000 first line
12
+ 00:00:4000 second line
13
+
14
+ Transform it to SRT:
15
+
16
+ $ ssrt2srt test.ssrt > test.srt
17
+ $ cat test.srt
18
+ 1
19
+ 00:00:0000 --> 00:00:2000
20
+ first line
21
+
22
+ 2
23
+ 00:00:2000 --> 00:00:4000
24
+ second line
data/Rakefile ADDED
@@ -0,0 +1,15 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+ require 'rake/clean'
4
+
5
+ CLEAN.include ['**/.*.sw?', '**/*.gem', 'test/test.log']
6
+
7
+ task default: %i[test package]
8
+ task package: :clean
9
+
10
+ Rake::TestTask.new do |t|
11
+ t.libs << 'lib' << 'test'
12
+ t.test_files = FileList['test/**/*_test.rb']
13
+ t.warning = false
14
+ t.verbose = false
15
+ end
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "ssrt"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/exe/ssrt2srt ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH.unshift File.expand_path('../lib', __dir__)
4
+
5
+ require "ssrt"
6
+
7
+ puts SSRT.ssrt2srt(ARGV[0])
data/lib/ssrt.rb ADDED
@@ -0,0 +1,17 @@
1
+ class SSRT
2
+ VERSION = "0.1.0"
3
+ TIMESTAMP_PATTERN = /\d\d:\d\d:\d{4}/
4
+
5
+ def self.ssrt2srt(file)
6
+ str=file.read
7
+ new_buf = ['00:00:0000']
8
+
9
+ str.each_line.with_index do |l, i|
10
+ time_start = new_buf[i-1].scan(TIMESTAMP_PATTERN).last
11
+ time_end, text = l.split[0], l.split[1..].join(' ')
12
+ new_buf[i] = "#{i+1}\n#{time_start} --> #{time_end}\n#{text}\n\n"
13
+ end
14
+
15
+ new_str = new_buf.join.strip
16
+ end
17
+ end
data/ssrt.gemspec ADDED
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/ssrt"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "ssrt"
7
+ spec.version = SSRT::VERSION
8
+ spec.authors = ["Sergio"]
9
+ spec.email = ["romerose@protonmail.com"]
10
+
11
+ spec.summary = "Simple SRT format"
12
+ spec.description = "Simple format for video subtitles"
13
+ #spec.homepage = "TODO: Put your gem's website or public repo URL here."
14
+ #spec.required_ruby_version = ">= 2.6.0"
15
+
16
+ #spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
17
+
18
+ #spec.metadata["homepage_uri"] = spec.homepage
19
+ #spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
20
+ #spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
21
+
22
+ # Specify which files should be added to the gem when it is released.
23
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
24
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
25
+ `git ls-files -z`.split("\x0").reject do |f|
26
+ (f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
27
+ end
28
+ end
29
+ spec.bindir = "exe"
30
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
31
+ spec.require_paths = ["lib"]
32
+
33
+ # Uncomment to register a new dependency of your gem
34
+ # spec.add_dependency "example-gem", "~> 1.0"
35
+
36
+ # For more information and examples about making a new gem, checkout our
37
+ # guide at: https://bundler.io/guides/creating_gem.html
38
+ end
metadata ADDED
@@ -0,0 +1,52 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ssrt
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Sergio
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-06-04 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Simple format for video subtitles
14
+ email:
15
+ - romerose@protonmail.com
16
+ executables:
17
+ - ssrt2srt
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - Gemfile
22
+ - LICENSE.txt
23
+ - README.md
24
+ - Rakefile
25
+ - bin/console
26
+ - bin/setup
27
+ - exe/ssrt2srt
28
+ - lib/ssrt.rb
29
+ - ssrt.gemspec
30
+ homepage:
31
+ licenses: []
32
+ metadata: {}
33
+ post_install_message:
34
+ rdoc_options: []
35
+ require_paths:
36
+ - lib
37
+ required_ruby_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ required_rubygems_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ requirements: []
48
+ rubygems_version: 3.2.32
49
+ signing_key:
50
+ specification_version: 4
51
+ summary: Simple SRT format
52
+ test_files: []