appydave-tools 0.8.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e4f0fbf0d8d8efc742e691efe1e128bb49f5a1f1423fe2b5eb7a700d9d606c24
4
- data.tar.gz: 4a6ea3bba78bbb0c8983f462888e0c7e8c1910706e90bbb9db0bfbad99e47405
3
+ metadata.gz: 0ba996537dc1739ee3fb48dc8d7998d6162a5abf049a14532ca099061771f368
4
+ data.tar.gz: 725cfcaec333d10f74efcf249d4b06e1c671ba00f873ffdb86b8450db9b7ac0e
5
5
  SHA512:
6
- metadata.gz: 85058aef1eccdf67319578d1d4c929a17da0143492ba91095ab7e09702f12648174a17bcb611ab5e2951ab500386b98a7f020c5695772c488ebd782bc275e3a6
7
- data.tar.gz: fb4b852d1dff53cb256c190e586546d5ee2bf13a675da10b0d25c6abc4d04588d541541763bff650609816677e7e3fe407c9920508dcd843a8ab19ac6c2943ab
6
+ metadata.gz: d63ebd803779eee9bb7715911492ced07dd48b373bd541a6eef0106737374025919611bc0a00de1ef003dec98a9b17417236bcf1784c50a9cc81f3cc21d5d660
7
+ data.tar.gz: b191193647bdc0196fbbc47db9dde26f6dfa0e65f1d1d709aff7befbf1aa1ac0d17438bab94643f24860a177060862d86060bea9bcdc0a2ea54c46fb7d26171c
data/.rubocop.yml CHANGED
@@ -43,11 +43,6 @@ Metrics/BlockLength:
43
43
  RSpec/ExampleLength:
44
44
  Max: 25
45
45
 
46
- Metrics/MethodLength:
47
- Max: 25
48
- Exclude:
49
- - "**/spec/**/*"
50
- - "bin/*.rb"
51
46
 
52
47
  Layout/LineLength:
53
48
  Max: 200
@@ -80,6 +75,8 @@ Naming/MethodParameterName:
80
75
  Style/EmptyMethod:
81
76
  Exclude:
82
77
  - "**/spec/**/*"
78
+ Style/EmptyFile:
79
+ Enabled: false
83
80
  Metrics/ParameterLists:
84
81
  Exclude:
85
82
  - "**/spec/**/*"
@@ -120,19 +117,27 @@ RSpec/DescribeClass:
120
117
  RSpec/PendingWithoutReason:
121
118
  Enabled: false
122
119
 
120
+ RSpec/MultipleMemoizedHelpers:
121
+ Enabled: false
122
+
123
123
  Metrics/AbcSize:
124
124
  Max: 25
125
125
  Exclude:
126
126
  - "bin/*"
127
- - "lib/appydave/tools/subtitle_master/clean.rb"
127
+ - "**/spec/**/*"
128
+ - "lib/appydave/**/*.rb"
128
129
  Metrics/CyclomaticComplexity:
129
130
  Exclude:
130
- - "**/models/**/*"
131
- - "lib/appydave/tools/bank_reconciliation/clean/mapper.rb"
132
- - "lib/appydave/tools/subtitle_master/clean.rb"
131
+ - "**/spec/**/*"
132
+ - "lib/appydave/**/*.rb"
133
133
  Metrics/PerceivedComplexity:
134
134
  Exclude:
135
- - "**/models/**/*"
136
- - "lib/appydave/tools/subtitle_master/clean.rb"
137
- RSpec/MultipleMemoizedHelpers:
138
- Enabled: false
135
+ - "**/spec/**/*"
136
+ - "lib/appydave/**/*.rb"
137
+
138
+ Metrics/MethodLength:
139
+ Max: 25
140
+ Exclude:
141
+ - "**/spec/**/*"
142
+ - "bin/*.rb"
143
+ - "lib/appydave/**/*.rb"
data/CHANGELOG.md CHANGED
@@ -1,3 +1,16 @@
1
+ # [0.8.0](https://github.com/klueless-io/appydave-tools/compare/v0.7.0...v0.8.0) (2024-06-06)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * update bank reconciliation components ([0f5dea1](https://github.com/klueless-io/appydave-tools/commit/0f5dea1f75baced1458619ead3fc5bd5bc69e0d5))
7
+
8
+
9
+ ### Features
10
+
11
+ * subtitle master for cleaning the SRT files created by whisper AI ([9f7bd37](https://github.com/klueless-io/appydave-tools/commit/9f7bd3795f4361e0615307874a88370ab49f97a7))
12
+ * subtitle master for cleaning the SRT files created by whisper AI ([0475a9e](https://github.com/klueless-io/appydave-tools/commit/0475a9ec07f2735e52ce54db6afa96e30e00c0e6))
13
+
1
14
  # [0.7.0](https://github.com/klueless-io/appydave-tools/compare/v0.6.1...v0.7.0) (2024-05-29)
2
15
 
3
16
 
@@ -0,0 +1,73 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ $LOAD_PATH.unshift(File.expand_path('../lib', __dir__))
5
+
6
+ require 'appydave/tools'
7
+
8
+ # Process command line arguments for YouTubeVideoManager operations
9
+ class YouTubeVideoManagerCLI
10
+ def initialize
11
+ @commands = {
12
+ 'get' => method(:fetch_video_details)
13
+ # Additional commands can be added here
14
+ }
15
+ end
16
+
17
+ def run
18
+ command, *args = ARGV
19
+ if @commands.key?(command)
20
+ @commands[command].call(args)
21
+ else
22
+ puts "Unknown command: #{command}"
23
+ print_help
24
+ end
25
+ end
26
+
27
+ private
28
+
29
+ def fetch_video_details(args)
30
+ options = parse_options(args, 'get')
31
+ manager = Appydave::Tools::YouTubeManager::GetVideo.new
32
+ manager.get(options[:video_id])
33
+ # json = JSON.pretty_generate(details)
34
+ # puts json
35
+
36
+ # report = Appydave::Tools::YouTubeManager::Reports::VideoDetailsReport.new
37
+ # report.print(manager.data)
38
+
39
+ report = Appydave::Tools::YouTubeManager::Reports::VideoContentReport.new
40
+ report.print(manager.data)
41
+ end
42
+
43
+ def parse_options(args, command)
44
+ options = { video_id: nil }
45
+ OptionParser.new do |opts|
46
+ opts.banner = "Usage: youtube_video_manager.rb #{command} [options]"
47
+
48
+ opts.on('-v', '--video-id ID', 'YouTube Video ID') { |v| options[:video_id] = v }
49
+
50
+ opts.on_tail('-h', '--help', 'Show this message') do
51
+ puts opts
52
+ exit
53
+ end
54
+ end.parse!(args)
55
+
56
+ unless options[:video_id]
57
+ puts 'Missing required options. Use -h for help.'
58
+ exit
59
+ end
60
+
61
+ options
62
+ end
63
+
64
+ def print_help
65
+ puts 'Usage: youtube_video_manager.rb [command] [options]'
66
+ puts 'Commands:'
67
+ puts ' get Get details for a YouTube video'
68
+ # Additional commands can be listed here
69
+ puts "Run 'youtube_video_manager.rb [command] --help' for more information on a command."
70
+ end
71
+ end
72
+
73
+ YouTubeVideoManagerCLI.new.run
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Appydave
4
+ module Tools
5
+ # Hash with indifferent access
6
+ class IndifferentAccessHash < Hash
7
+ def initialize(initial_hash = {})
8
+ super()
9
+ update(initial_hash)
10
+ end
11
+
12
+ def [](key)
13
+ super(convert_key(key))
14
+ end
15
+
16
+ def []=(key, value)
17
+ super(convert_key(key), value)
18
+ end
19
+
20
+ def fetch(key, *args)
21
+ super(convert_key(key), *args)
22
+ end
23
+
24
+ def delete(key)
25
+ super(convert_key(key))
26
+ end
27
+
28
+ private
29
+
30
+ def convert_key(key)
31
+ key.is_a?(Symbol) ? key.to_s : key
32
+ end
33
+
34
+ def update(initial_hash)
35
+ initial_hash.each do |key, value|
36
+ self[convert_key(key)] = value
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -1,3 +1,21 @@
1
1
  # Subtitle Master
2
2
 
3
- [ChatGPT](https://chatgpt.com/c/f80dfca5-8168-4561-b5c6-8efed8672a88)
3
+ [ChatGPT](https://chatgpt.com/c/f80dfca5-8168-4561-b5c6-8efed8672a88)
4
+
5
+ ## SubtitleMaster - Clean Component
6
+
7
+ The `SubtitleMaster::Clean` component is designed to process subtitle (SRT) files to improve their readability and compatibility with various platforms like YouTube. The main functionalities of this component include:
8
+
9
+ - **Removing HTML Tags**: Strips out unnecessary HTML underline tags (`<u>` and `</u>`) that may be present in the subtitle content.
10
+ - **Normalizing Subtitle Lines**: Merges fragmented subtitle lines into coherent sentences. It adjusts the timestamps to ensure that each subtitle entry spans the correct duration, combining lines that were incorrectly split by the subtitle creation software.
11
+ - **Handling Timestamps**: Updates the end timestamp of each merged subtitle to reflect the actual end time of the last occurrence of the text, ensuring accurate timing for each subtitle entry.
12
+
13
+ This component reads the SRT file, processes the content to remove tags and normalize lines, and outputs a cleaned and formatted subtitle file that is easier to read and upload to platforms.
14
+
15
+ ```bash
16
+ ./bin/subtitle_master.rb clean -f path/to/example.srt -o path/to/example_cleaned.srt
17
+
18
+ # Example using alias
19
+
20
+ ad_subtitle_master clean -f transcript/a45-banned-from-midjourney-16-alternatives.srt -o a45-transcript.srt
21
+ ```
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Appydave
4
4
  module Tools
5
- VERSION = '0.8.0'
5
+ VERSION = '0.9.0'
6
6
  end
7
7
  end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Appydave
4
+ module Tools
5
+ module YouTubeManager
6
+ # Handle YouTube API Authorization
7
+ class Authorization
8
+ REDIRECT_URI = 'http://localhost:8080/'
9
+ CLIENT_SECRETS_PATH = File.join(Dir.home, '.config', 'appydave-google-youtube.json')
10
+ CREDENTIALS_PATH = File.join(Dir.home, '.credentials', 'ad_youtube.yaml')
11
+
12
+ SCOPE = [
13
+ 'https://www.googleapis.com/auth/youtube.readonly',
14
+ 'https://www.googleapis.com/auth/youtube'
15
+ ].freeze
16
+
17
+ def self.authorize
18
+ FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))
19
+
20
+ client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)
21
+ token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)
22
+ authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)
23
+ user_id = 'default'
24
+ credentials = authorizer.get_credentials(user_id)
25
+ credentials = wait_for_authorization(authorizer) if credentials.nil?
26
+ credentials
27
+ end
28
+
29
+ def self.wait_for_authorization(authorizer)
30
+ url = authorizer.get_authorization_url(base_url: REDIRECT_URI)
31
+ puts 'Open the following URL in your browser and authorize the application:'
32
+ puts url
33
+
34
+ server = WEBrick::HTTPServer.new(Port: 8080, AccessLog: [], Logger: WEBrick::Log.new(nil, 0))
35
+ trap('INT') { server.shutdown }
36
+
37
+ server.mount_proc '/' do |req, res|
38
+ auth_code = req.query['code']
39
+ res.body = 'Authorization successful. You can close this window now.'
40
+ server.shutdown
41
+ authorizer.get_and_store_credentials_from_code(
42
+ user_id: user_id, code: auth_code, base_url: REDIRECT_URI
43
+ )
44
+ end
45
+
46
+ server.start
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Appydave
4
+ module Tools
5
+ module YouTubeManager
6
+ # Manage YouTube video details
7
+ class GetVideo < YouTubeBase
8
+ attr_reader :video_id
9
+ attr_reader :data
10
+ attr_reader :video
11
+
12
+ def get(video_id)
13
+ @video_id = video_id
14
+ response = @service.list_videos('snippet,contentDetails,status,statistics', id: video_id)
15
+ @video = response.items.first
16
+
17
+ data = {
18
+ id: video.id,
19
+ title: video.snippet.title,
20
+ description: video.snippet.description,
21
+ published_at: video.snippet.published_at,
22
+ channel_id: video.snippet.channel_id,
23
+ channel_title: video.snippet.channel_title,
24
+ view_count: video.statistics.view_count,
25
+ like_count: video.statistics.like_count,
26
+ dislike_count: video.statistics.dislike_count,
27
+ comment_count: video.statistics.comment_count,
28
+ privacy_status: video.status.privacy_status,
29
+ embeddable: video.status.embeddable,
30
+ license: video.status.license,
31
+ recording_location: video.recording_details&.location,
32
+ recording_date: video.recording_details&.recording_date,
33
+ tags: video.snippet.tags,
34
+ thumbnails: video.snippet.thumbnails.to_h,
35
+ duration: video.content_details.duration,
36
+ definition: video.content_details.definition,
37
+ caption: video.content_details.caption,
38
+ licensed_content: video.content_details.licensed_content
39
+ }
40
+
41
+ @data = Appydave::Tools::IndifferentAccessHash.new(data)
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Appydave
4
+ module Tools
5
+ module YouTubeManager
6
+ module Reports
7
+ # Report on video content
8
+ class VideoContentReport
9
+ include KLog::Logging
10
+
11
+ def print(data)
12
+ # log.heading 'Video Details Report'
13
+ log.subheading data[:title]
14
+ log.kv 'Published At', data[:published_at]
15
+ log.kv 'View Count', data[:view_count]
16
+ log.kv 'Like Count', data[:like_count]
17
+ log.kv 'Dislike Count', data[:dislike_count]
18
+ log.kv 'Tags', data[:tags].join(', ')
19
+ log.line
20
+ puts data[:description]
21
+ log.line
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Appydave
4
+ module Tools
5
+ module YouTubeManager
6
+ module Reports
7
+ # Print video details
8
+ class VideoDetailsReport
9
+ include KLog::Logging
10
+
11
+ def print(data)
12
+ # log.heading 'Video Details Report'
13
+ # log.subheading 'Video Details Report'
14
+ log.section_heading 'Video Details Report'
15
+ log.kv 'ID', data[:id]
16
+ log.kv 'Title', data[:title]
17
+ log.kv 'Published At', data[:published_at]
18
+ log.kv 'View Count', data[:view_count]
19
+ log.kv 'Like Count', data[:like_count]
20
+ log.kv 'Dislike Count', data[:dislike_count]
21
+ log.kv 'Comment Count', data[:comment_count]
22
+ log.kv 'Privacy Status', data[:privacy_status]
23
+ log.kv 'Channel ID', data[:channel_id]
24
+ log.kv 'Channel Title', data[:channel_title]
25
+ log.kv 'Embeddable', data[:embeddable]
26
+ log.kv 'License', data[:license]
27
+ log.kv 'Recording Location', data[:recording_location]
28
+ log.kv 'Recording Date', data[:recording_date]
29
+ log.kv 'Tags', data[:tags].join(', ')
30
+ log.kv data[:description][0..100]
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Appydave
4
+ module Tools
5
+ module YouTubeManager
6
+ # Base class for YouTube API management
7
+ class YouTubeBase
8
+ def initialize
9
+ @service = Google::Apis::YoutubeV3::YouTubeService.new
10
+ @service.client_options.application_name = 'YouTube Video Manager'
11
+ @service.authorization = Authorization.authorize
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -8,9 +8,17 @@ require 'open3'
8
8
  require 'openai'
9
9
  require 'optparse'
10
10
  require 'k_log'
11
+
12
+ require 'google/apis/youtube_v3'
13
+ require 'googleauth'
14
+ require 'googleauth/stores/file_token_store'
15
+ require 'webrick'
16
+
11
17
  require 'pry'
12
18
 
13
19
  require 'appydave/tools/version'
20
+ require 'appydave/tools/indifferent_access_hash'
21
+
14
22
  require 'appydave/tools/gpt_context/file_collector'
15
23
 
16
24
  require 'appydave/tools/configuration/openai'
@@ -28,6 +36,12 @@ require 'appydave/tools/bank_reconciliation/models/transaction'
28
36
 
29
37
  require 'appydave/tools/subtitle_master/clean'
30
38
 
39
+ require 'appydave/tools/youtube_manager/youtube_base'
40
+ require 'appydave/tools/youtube_manager/authorization'
41
+ require 'appydave/tools/youtube_manager/get_video'
42
+ require 'appydave/tools/youtube_manager/reports/video_details_report'
43
+ require 'appydave/tools/youtube_manager/reports/video_content_report'
44
+
31
45
  Appydave::Tools::Configuration::Config.set_default do |config|
32
46
  config.config_path = File.expand_path('~/.config/appydave')
33
47
  config.register(:settings, Appydave::Tools::Configuration::Models::SettingsConfig)
data/package-lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "appydave-tools",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "appydave-tools",
9
- "version": "0.8.0",
9
+ "version": "0.9.0",
10
10
  "devDependencies": {
11
11
  "@klueless-js/semantic-release-rubygem": "github:klueless-js/semantic-release-rubygem",
12
12
  "@semantic-release/changelog": "^6.0.3",
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "appydave-tools",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "AppyDave YouTube Automation Tools",
5
5
  "scripts": {
6
6
  "release": "semantic-release"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appydave-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Cruwys
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-06-06 00:00:00.000000000 Z
11
+ date: 2024-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clipboard
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: google-api-client
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.53'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.53'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: k_log
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -80,6 +94,34 @@ dependencies:
80
94
  - - "~>"
81
95
  - !ruby/object:Gem::Version
82
96
  version: '7'
97
+ - !ruby/object:Gem::Dependency
98
+ name: googleauth
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: webrick
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
83
125
  description: " AppyDave YouTube Automation Tools\n"
84
126
  email:
85
127
  - david@ideasmen.com.au
@@ -106,6 +148,7 @@ files:
106
148
  - bin/gpt_context.rb
107
149
  - bin/setup
108
150
  - bin/subtitle_master.rb
151
+ - bin/youtube_manager.rb
109
152
  - images.log
110
153
  - lib/appydave/tools.rb
111
154
  - lib/appydave/tools/bank_reconciliation/_doc.md
@@ -124,11 +167,17 @@ files:
124
167
  - lib/appydave/tools/configuration/openai.rb
125
168
  - lib/appydave/tools/gpt_context/_doc.md
126
169
  - lib/appydave/tools/gpt_context/file_collector.rb
170
+ - lib/appydave/tools/indifferent_access_hash.rb
127
171
  - lib/appydave/tools/name_manager/_doc.md
128
172
  - lib/appydave/tools/name_manager/project_name.rb
129
173
  - lib/appydave/tools/subtitle_master/_doc.md
130
174
  - lib/appydave/tools/subtitle_master/clean.rb
131
175
  - lib/appydave/tools/version.rb
176
+ - lib/appydave/tools/youtube_manager/authorization.rb
177
+ - lib/appydave/tools/youtube_manager/get_video.rb
178
+ - lib/appydave/tools/youtube_manager/reports/video_content_report.rb
179
+ - lib/appydave/tools/youtube_manager/reports/video_details_report.rb
180
+ - lib/appydave/tools/youtube_manager/youtube_base.rb
132
181
  - package-lock.json
133
182
  - package.json
134
183
  - sig/appydave/tools.rbs