screenkit 0.0.12 → 0.0.14

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cd0de2fa10f13914e8b0f2b9d8f0f1e295e4d964d54c7e8c045f7a5dc3b7e031
4
- data.tar.gz: e16a92ffb88856e3cf482bd9ae1eb5f99d8785a73e632e92b5ad37c688e87f5e
3
+ metadata.gz: e300f330550b46c23a90c6433c534bb473f65cc71c49c82a97a6d9dde1a35c61
4
+ data.tar.gz: 8030a806d8daab8ab3df20dfc93b4b315746e330e0c2f11d16ba70725f6f6e21
5
5
  SHA512:
6
- metadata.gz: b20e2485811c2cd0321251e2e2ea0d7f4402df4979be44bf269ea9fbe71da79d7963146ec39d5634718ef6bc6011887948acafffdcf361c0db172d81455417e6
7
- data.tar.gz: 0465a5f3f7b623021b510cd16e8bc927c58e0db8cbc3479363c5b87f5b545d43f969866244ea862875f3f65f4596fa02b223e22fe1056afd0acc50a832c1cab0
6
+ metadata.gz: ad8cdfd064da26fff6013df15e41562fb8b9463493dcc26510a5f48ddf4880c1b55bcf566c82c34ff1abd77b8102d93092283b4987ff8f62d19b33249e1e6e8b
7
+ data.tar.gz: 9b9302661f3b0c65a7b4c365a516b2833297d2fc683a2d6d75c84e051bfa70cc1daeeb0b22aa4f53be4aad8597604944100646a4a6d96935092b49f77a2a9b3e
data/CHANGELOG.md CHANGED
@@ -11,6 +11,16 @@ Prefix your message with one of the following:
11
11
  - [Security] in case of vulnerabilities.
12
12
  -->
13
13
 
14
+ ## v0.0.14
15
+
16
+ - [Fixed] Fix file redacting when no API key is defined.
17
+ - [Fixed] Trim transparent pixels from rendered text.
18
+ - [Fixed] Allow concurrency to be specified when generating voiceover.
19
+
20
+ ## v0.0.13
21
+
22
+ - [Fixed] Redact API key in config log.
23
+
14
24
  ## v0.0.12
15
25
 
16
26
  - [Fixed] Fix how configuration is merged.
data/DOCUMENTATION.md CHANGED
@@ -114,8 +114,6 @@ $ docker run \
114
114
  Notice that Chrome requires a lot of memory, so you need `--shm-size=2g` (or
115
115
  more).
116
116
 
117
- To create a new project:
118
-
119
117
  ---
120
118
 
121
119
  ## Quick Start
@@ -958,7 +956,7 @@ The engine name is camelized (e.g., `custom_engine` → `CustomEngine`,
958
956
 
959
957
  > [!TIP]
960
958
  >
961
- > If you host your TTS engine on Github, use the topic `screekit-tts`, so other
959
+ > If you host your TTS engine on Github, use the topic `screenkit-tts`, so other
962
960
  > people can find it.
963
961
 
964
962
  ---
@@ -1320,9 +1318,10 @@ bundle exec screenkit ...
1320
1318
 
1321
1319
  #### TTS not working
1322
1320
 
1323
- - For ElevenLabs: Set `--tts-api-key`
1324
- - For macOS `say`: Verify voice name with `say -v ?`
1325
- - For `espeak`: Ensure `espeak` is installed and in PATH
1321
+ - For ElevenLabs: set `--tts-api-key` with valid prefixed key, like
1322
+ `eleven_labs:API_KEY`
1323
+ - For macOS `say`: verify voice name with `say -v ?`
1324
+ - For `espeak`: ensure `espeak` is installed and in PATH
1326
1325
 
1327
1326
  #### Playwright scripts not working
1328
1327
 
@@ -69,15 +69,23 @@ module ScreenKit
69
69
  def export
70
70
  puts Banner.banner if options.banner
71
71
 
72
- project_config = if File.file?(options.config)
72
+ episode_config_path = File.join(options.dir, "config.yml")
73
+ has_project_config = File.file?(options.config)
74
+ has_episode_config = File.file?(episode_config_path)
75
+
76
+ if !has_project_config && !has_episode_config
77
+ shell.say "Error: No configuration file found.", :red
78
+ exit 1
79
+ end
80
+
81
+ project_config = if has_project_config
73
82
  Config.load_yaml_file(options.config)
74
83
  else
75
84
  {}
76
85
  end
77
86
 
78
- episode_config = File.join(options.dir, "config.yml")
79
- episode_config = if File.file?(episode_config)
80
- Config.load_yaml_file(episode_config)
87
+ episode_config = if has_episode_config
88
+ Config.load_yaml_file(episode_config_path)
81
89
  else
82
90
  {}
83
91
  end
@@ -95,6 +103,14 @@ module ScreenKit
95
103
  )
96
104
 
97
105
  exporter.export
106
+ ensure
107
+ exporter.output_dir.join("logs").glob("*.txt").each do |path|
108
+ redact_file(path, options.tts_api_key)
109
+ end
110
+ end
111
+
112
+ no_commands do
113
+ include RedactFile
98
114
  end
99
115
  end
100
116
  end
@@ -4,6 +4,7 @@ module ScreenKit
4
4
  module Exporter
5
5
  class Episode
6
6
  using CoreExt
7
+ include RedactFile
7
8
  include Utils
8
9
  include Shell
9
10
 
@@ -148,7 +149,8 @@ module ScreenKit
148
149
  spinner:,
149
150
  list: filtered_segments,
150
151
  message: "Exporting voiceovers (%{progress}/%{count})",
151
- log_path: logfile.create("%{prefix}", :voiceover)
152
+ log_path: logfile.create("%{prefix}", :voiceover),
153
+ concurrency: tts_engine.concurrency
152
154
  ).run(&:export_voiceover)
153
155
 
154
156
  log_elapsed("Generated voiceover in %{elapsed}", elapsed)
@@ -188,7 +190,7 @@ module ScreenKit
188
190
  source.search(watermark.path)
189
191
  else
190
192
  ScreenKit.root_dir
191
- .join("screenkit/resources/transparent.png")
193
+ .join("resources/transparent.png")
192
194
  end
193
195
 
194
196
  watermark_width, watermark_height = image_size(watermark_path)
@@ -401,10 +403,11 @@ module ScreenKit
401
403
 
402
404
  # Logs initial information about the episode export process.
403
405
  def prelude
404
- logfile.json_log(
406
+ path = logfile.json_log(
405
407
  :config,
406
- options.merge(pwd: Dir.pwd, config:)
408
+ options.merge(pwd: Dir.pwd, config: config.as_json)
407
409
  )
410
+ redact_file(path, options.tts_api_key)
408
411
 
409
412
  log(
410
413
  :info,
@@ -74,7 +74,7 @@ module ScreenKit
74
74
  .new(
75
75
  script_path: content_path,
76
76
  options: episode.playwright_options,
77
- log_path:,
77
+ log_path:
78
78
  )
79
79
  .export(video_path)
80
80
  when *ContentType.video
@@ -2,7 +2,10 @@
2
2
 
3
3
  module ScreenKit
4
4
  module HTTP
5
+ include RedactFile
6
+
5
7
  # Sends a POST request.
8
+ #
6
9
  # @param url [String] The request URL.
7
10
  # @param params [Hash] The request parameters.
8
11
  # @param headers [Hash] The request headers.
@@ -32,6 +35,7 @@ module ScreenKit
32
35
  end
33
36
 
34
37
  # Sends a JSON POST request.
38
+ #
35
39
  # @param url [String] The request URL.
36
40
  # @param params [Hash] The request parameters.
37
41
  # @param headers [Hash] The request headers.
@@ -42,17 +46,5 @@ module ScreenKit
42
46
  headers = headers.merge(content_type: "application/json")
43
47
  post(headers:, **)
44
48
  end
45
-
46
- # Redacts sensitive text from a file.
47
- # @param path [String] The file path.
48
- # @param text [String] The text to redact.
49
- # @return [void]
50
- def redact_file(path, text)
51
- return unless path
52
- return unless File.file?(path)
53
-
54
- content = File.read(path).gsub(text, "[REDACTED]")
55
- File.write(path, content)
56
- end
57
49
  end
58
50
  end
@@ -94,6 +94,8 @@ module ScreenKit
94
94
  image << "-pointsize"
95
95
  image << style.size.to_s
96
96
  image << "#{type}:#{escape_text_for_image(text)}"
97
+ image << "-trim"
98
+ image << "+repage"
97
99
  image << "PNG:#{path}"
98
100
  end
99
101
 
@@ -23,6 +23,7 @@ module ScreenKit
23
23
  path = create(*args)
24
24
  FileUtils.mkdir_p(File.dirname(path))
25
25
  File.open(path, "w") { it << message.to_s }
26
+ path
26
27
  end
27
28
 
28
29
  def json_log(*args)
@@ -2,10 +2,11 @@
2
2
 
3
3
  module ScreenKit
4
4
  class ParallelProcessor
5
- attr_reader :spinner, :list, :message, :mutex, :count, :log_path
5
+ attr_reader :spinner, :list, :message, :mutex, :count, :log_path,
6
+ :concurrency
6
7
  attr_accessor :progress
7
8
 
8
- def initialize(spinner:, list:, message:, log_path: nil)
9
+ def initialize(spinner:, list:, message:, log_path: nil, concurrency: nil)
9
10
  @list = list
10
11
  @message = message
11
12
  @spinner = spinner
@@ -13,6 +14,7 @@ module ScreenKit
13
14
  @progress = 0
14
15
  @count = list.size
15
16
  @log_path = log_path
17
+ @concurrency = concurrency || Etc.nprocessors
16
18
  end
17
19
 
18
20
  def run(&block)
@@ -20,7 +22,7 @@ module ScreenKit
20
22
  indexed_list = list.map.with_index {|item, index| [item, index] }
21
23
  arity = block.arity
22
24
 
23
- indexed_list.each_slice(Etc.nprocessors) do |slice|
25
+ indexed_list.each_slice(concurrency) do |slice|
24
26
  threads = slice.map do |args|
25
27
  thread = Thread.new do
26
28
  update_message
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ScreenKit
4
+ module RedactFile
5
+ # Redacts sensitive text from a file.
6
+ # @param path [String] The file path.
7
+ # @param text [String] The text to redact.
8
+ # @return [void]
9
+ def redact_file(path, text)
10
+ return unless path
11
+ return unless File.file?(path)
12
+ return if text.to_s.strip.empty?
13
+
14
+ content = File.read(path).gsub(text, "[REDACTED]")
15
+ File.write(path, content)
16
+ end
17
+ end
18
+ end
@@ -55,6 +55,10 @@ module ScreenKit
55
55
 
56
56
  @api_key = api_key.delete_prefix("#{self.class.engine_name}:")
57
57
  end
58
+
59
+ def concurrency
60
+ # to be implemented by subclasses if applicable
61
+ end
58
62
  end
59
63
  end
60
64
  end
@@ -14,6 +14,10 @@ module ScreenKit
14
14
  api_key.to_s.start_with?(api_key_prefix)
15
15
  end
16
16
 
17
+ def concurrency
18
+ 3
19
+ end
20
+
17
21
  def all_texts
18
22
  @all_texts ||= segments.map(&:script_content)
19
23
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ScreenKit
4
- VERSION = "0.0.12"
4
+ VERSION = "0.0.14"
5
5
  end
data/lib/screenkit.rb CHANGED
@@ -18,6 +18,7 @@ module ScreenKit
18
18
  require_relative "screenkit/duration"
19
19
  require_relative "screenkit/core_ext"
20
20
  require_relative "screenkit/content_type"
21
+ require_relative "screenkit/redact_file"
21
22
  require_relative "screenkit/anchor"
22
23
  require_relative "screenkit/banner"
23
24
  require_relative "screenkit/time_formatter"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: screenkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nando Vieira
@@ -348,6 +348,7 @@ files:
348
348
  - lib/screenkit/logfile.rb
349
349
  - lib/screenkit/parallel_processor.rb
350
350
  - lib/screenkit/path_lookup.rb
351
+ - lib/screenkit/redact_file.rb
351
352
  - lib/screenkit/resources/callout_styles/social/blog.png
352
353
  - lib/screenkit/resources/callout_styles/social/bsky.png
353
354
  - lib/screenkit/resources/callout_styles/social/discord.png
@@ -420,10 +421,10 @@ metadata:
420
421
  rubygems_mfa_required: 'true'
421
422
  homepage_uri: https://github.com/fnando/screenkit
422
423
  bug_tracker_uri: https://github.com/fnando/screenkit/issues
423
- source_code_uri: https://github.com/fnando/screenkit/tree/v0.0.12
424
- changelog_uri: https://github.com/fnando/screenkit/tree/v0.0.12/CHANGELOG.md
425
- documentation_uri: https://github.com/fnando/screenkit/tree/v0.0.12/README.md
426
- license_uri: https://github.com/fnando/screenkit/tree/v0.0.12/LICENSE.md
424
+ source_code_uri: https://github.com/fnando/screenkit/tree/v0.0.14
425
+ changelog_uri: https://github.com/fnando/screenkit/tree/v0.0.14/CHANGELOG.md
426
+ documentation_uri: https://github.com/fnando/screenkit/tree/v0.0.14/README.md
427
+ license_uri: https://github.com/fnando/screenkit/tree/v0.0.14/LICENSE.md
427
428
  rdoc_options: []
428
429
  require_paths:
429
430
  - lib