appydave-tools 0.9.4 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -0
- data/bin/prompt_tools.rb +36 -0
- data/bin/youtube_manager.rb +22 -21
- data/lib/appydave/tools/cli_actions/_doc.md +5 -0
- data/lib/appydave/tools/cli_actions/base_action.rb +50 -0
- data/lib/appydave/tools/cli_actions/get_video_action.rb +41 -0
- data/lib/appydave/tools/cli_actions/prompt_completion_action.rb +80 -0
- data/lib/appydave/tools/cli_actions/update_video_action.rb +46 -0
- data/lib/appydave/tools/types/array_type.rb +2 -0
- data/lib/appydave/tools/types/hash_type.rb +2 -0
- data/lib/appydave/tools/version.rb +1 -1
- data/lib/appydave/tools/youtube_manager/_doc.md +3 -1
- data/lib/appydave/tools/youtube_manager/authorization.rb +3 -1
- data/lib/appydave/tools/youtube_manager/get_video.rb +36 -15
- data/lib/appydave/tools/youtube_manager/models/youtube_details.rb +62 -12
- data/lib/appydave/tools/youtube_manager/reports/video_details_report.rb +21 -16
- data/lib/appydave/tools/youtube_manager/update_video.rb +53 -0
- data/lib/appydave/tools.rb +7 -2
- data/package-lock.json +2 -2
- data/package.json +1 -1
- metadata +9 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2f8626d0968a1fb7485288c9e2faec7dfab9bc1d389f7834f76748116794ad4
|
4
|
+
data.tar.gz: f750a6e6132df67ebafefce2f94435a7801efc2ce374f94448d8c8b4d51c6255
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ec7c54c22a51070b33f66fd6fad9c60977f1e75c55fdc31e858545d1a79d5d74418a054d7fa538e99c2297831b41a3c20d6465ec4a311f806b02781a1a5925d
|
7
|
+
data.tar.gz: edaa750eed5eaf3ec55fca13fbeae3c703c9cf6845730bf6c00b3dafbe30f69b53891997041f5766a2ce837c4fa039303161df7035711d1f3c1dba66ca802ab3
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
## [0.9.5](https://github.com/klueless-io/appydave-tools/compare/v0.9.4...v0.9.5) (2024-06-13)
|
2
|
+
|
3
|
+
|
4
|
+
### Bug Fixes
|
5
|
+
|
6
|
+
* implement update video command ([c46473d](https://github.com/klueless-io/appydave-tools/commit/c46473dc550e34c041418adfd52444014e094917))
|
7
|
+
|
8
|
+
## [0.9.4](https://github.com/klueless-io/appydave-tools/compare/v0.9.3...v0.9.4) (2024-06-12)
|
9
|
+
|
10
|
+
|
11
|
+
### Bug Fixes
|
12
|
+
|
13
|
+
* move youtube management data to activemodel ([12d3351](https://github.com/klueless-io/appydave-tools/commit/12d3351b2243c436d0f59e2f2822d9d82cc6ebd6))
|
14
|
+
|
1
15
|
## [0.9.3](https://github.com/klueless-io/appydave-tools/compare/v0.9.2...v0.9.3) (2024-06-12)
|
2
16
|
|
3
17
|
|
data/bin/prompt_tools.rb
ADDED
@@ -0,0 +1,36 @@
|
|
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 Prompt operations
|
9
|
+
class PromptToolsCLI
|
10
|
+
def initialize
|
11
|
+
@commands = {
|
12
|
+
'completion' => Appydave::Tools::CliActions::PromptCompletionAction.new
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
def run
|
17
|
+
command, *args = ARGV
|
18
|
+
if @commands.key?(command)
|
19
|
+
@commands[command].action(args)
|
20
|
+
else
|
21
|
+
puts "Unknown command: #{command}"
|
22
|
+
print_help
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def print_help
|
29
|
+
puts 'Usage: prompt_tools.rb [command] [options]'
|
30
|
+
puts 'Commands:'
|
31
|
+
puts ' completion Run a completion prompt against the model'
|
32
|
+
puts "Run 'prompt.rb [command] --help' for more information on a command."
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
PromptToolsCLI.new.run
|
data/bin/youtube_manager.rb
CHANGED
@@ -11,15 +11,15 @@ class YouTubeVideoManagerCLI
|
|
11
11
|
|
12
12
|
def initialize
|
13
13
|
@commands = {
|
14
|
-
'get' =>
|
15
|
-
|
14
|
+
'get' => Appydave::Tools::CliActions::GetVideoAction.new,
|
15
|
+
'update' => Appydave::Tools::CliActions::UpdateVideoAction.new
|
16
16
|
}
|
17
17
|
end
|
18
18
|
|
19
19
|
def run
|
20
20
|
command, *args = ARGV
|
21
21
|
if @commands.key?(command)
|
22
|
-
@commands[command].
|
22
|
+
@commands[command].action(args)
|
23
23
|
else
|
24
24
|
puts "Unknown command: #{command}"
|
25
25
|
print_help
|
@@ -28,31 +28,32 @@ class YouTubeVideoManagerCLI
|
|
28
28
|
|
29
29
|
private
|
30
30
|
|
31
|
-
def
|
32
|
-
options =
|
33
|
-
manager = Appydave::Tools::YouTubeManager::GetVideo.new
|
34
|
-
manager.get(options[:video_id])
|
31
|
+
def update_video_details(args)
|
32
|
+
options = update_video_options(args)
|
35
33
|
|
36
|
-
|
37
|
-
|
38
|
-
# puts json
|
34
|
+
get_video = Appydave::Tools::YouTubeManager::GetVideo.new
|
35
|
+
get_video.get(options[:video_id])
|
39
36
|
|
40
|
-
|
41
|
-
# report.print(manager.data)
|
37
|
+
update_video = Appydave::Tools::YouTubeManager::UpdateVideo.new(get_video.data)
|
42
38
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
39
|
+
update_video.title(options[:title]) if options[:title]
|
40
|
+
update_video.description(options[:description]) if options[:description]
|
41
|
+
update_video.tags(options[:tags]) if options[:tags]
|
42
|
+
update_video.category_id(options[:category_id]) if options[:category_id]
|
43
|
+
|
44
|
+
update_video.save
|
48
45
|
end
|
49
46
|
|
50
|
-
def
|
47
|
+
def update_video_options(args)
|
51
48
|
options = { video_id: nil }
|
52
49
|
OptionParser.new do |opts|
|
53
|
-
opts.banner =
|
50
|
+
opts.banner = 'Usage: youtube_video_manager.rb update [options]'
|
54
51
|
|
55
52
|
opts.on('-v', '--video-id ID', 'YouTube Video ID') { |v| options[:video_id] = v }
|
53
|
+
opts.on('-t', '--title TITLE', 'Video Title') { |t| options[:title] = t }
|
54
|
+
opts.on('-d', '--description DESCRIPTION', 'Video Description') { |d| options[:description] = d }
|
55
|
+
opts.on('-g', '--tags TAGS', 'Video Tags (comma-separated)') { |g| options[:tags] = g.split(',') }
|
56
|
+
opts.on('-c', '--category-id CATEGORY_ID', 'Video Category ID') { |c| options[:category_id] = c }
|
56
57
|
|
57
58
|
opts.on_tail('-h', '--help', 'Show this message') do
|
58
59
|
puts opts
|
@@ -71,8 +72,8 @@ class YouTubeVideoManagerCLI
|
|
71
72
|
def print_help
|
72
73
|
puts 'Usage: youtube_video_manager.rb [command] [options]'
|
73
74
|
puts 'Commands:'
|
74
|
-
puts ' get
|
75
|
-
|
75
|
+
puts ' get Get details for a YouTube video'
|
76
|
+
puts ' update Update details for a YouTube video'
|
76
77
|
puts "Run 'youtube_video_manager.rb [command] --help' for more information on a command."
|
77
78
|
end
|
78
79
|
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Appydave
|
4
|
+
module Tools
|
5
|
+
module CliActions
|
6
|
+
# Base class for CLI actions
|
7
|
+
class BaseAction
|
8
|
+
def action(args)
|
9
|
+
options = parse_options(args)
|
10
|
+
execute(options)
|
11
|
+
end
|
12
|
+
|
13
|
+
protected
|
14
|
+
|
15
|
+
def parse_options(args)
|
16
|
+
options = {}
|
17
|
+
OptionParser.new do |opts|
|
18
|
+
opts.banner = "Usage: #{command_usage}"
|
19
|
+
|
20
|
+
define_options(opts, options)
|
21
|
+
|
22
|
+
opts.on_tail('-h', '--help', 'Show this message') do
|
23
|
+
puts opts
|
24
|
+
exit
|
25
|
+
end
|
26
|
+
end.parse!(args)
|
27
|
+
|
28
|
+
validate_options(options)
|
29
|
+
options
|
30
|
+
end
|
31
|
+
|
32
|
+
def command_usage
|
33
|
+
"#{self.class.name.split('::').last.downcase} [options]"
|
34
|
+
end
|
35
|
+
|
36
|
+
def define_options(opts, options)
|
37
|
+
# To be implemented by subclasses
|
38
|
+
end
|
39
|
+
|
40
|
+
def validate_options(options)
|
41
|
+
# To be implemented by subclasses
|
42
|
+
end
|
43
|
+
|
44
|
+
def execute(options)
|
45
|
+
# To be implemented by subclasses
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Appydave
|
4
|
+
module Tools
|
5
|
+
module CliActions
|
6
|
+
# CLI Action to get a YouTube video details
|
7
|
+
class GetVideoAction < BaseAction
|
8
|
+
protected
|
9
|
+
|
10
|
+
def define_options(opts, options)
|
11
|
+
opts.on('-v', '--video-id ID', 'YouTube Video ID') { |v| options[:video_id] = v }
|
12
|
+
end
|
13
|
+
|
14
|
+
def validate_options(options)
|
15
|
+
return if options[:video_id]
|
16
|
+
|
17
|
+
puts 'Missing required options: --video-id. Use -h for help.'
|
18
|
+
exit
|
19
|
+
end
|
20
|
+
|
21
|
+
def execute(options)
|
22
|
+
get_video = Appydave::Tools::YouTubeManager::GetVideo.new
|
23
|
+
get_video.get(options[:video_id])
|
24
|
+
|
25
|
+
if get_video.video?
|
26
|
+
# json = JSON.pretty_generate(details)
|
27
|
+
# puts json
|
28
|
+
|
29
|
+
report = Appydave::Tools::YouTubeManager::Reports::VideoDetailsReport.new
|
30
|
+
report.print(get_video.data)
|
31
|
+
|
32
|
+
# report = Appydave::Tools::YouTubeManager::Reports::VideoContentReport.new
|
33
|
+
# report.print(manager.data)
|
34
|
+
else
|
35
|
+
puts "Video not found! Maybe it's private or deleted. ID: #{options[:video_id]}"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'openai'
|
4
|
+
|
5
|
+
module Appydave
|
6
|
+
module Tools
|
7
|
+
module CliActions
|
8
|
+
# Action to run a completion prompt against the model
|
9
|
+
class PromptCompletionAction < BaseAction
|
10
|
+
DEFAULT_MODEL = 'gpt-4o'
|
11
|
+
DEFAULT_PLATFORM = 'openai'
|
12
|
+
|
13
|
+
protected
|
14
|
+
|
15
|
+
def define_options(opts, options)
|
16
|
+
opts.on('-p', '--prompt PROMPT', 'The prompt text') { |v| options[:prompt] = v }
|
17
|
+
opts.on('-f', '--file FILE', 'The prompt file') { |v| options[:file] = v }
|
18
|
+
opts.on('-o', '--output FILE', 'Output file') { |v| options[:output] = v }
|
19
|
+
opts.on('-c', '--clipboard', 'Copy result to clipboard') { |v| options[:clipboard] = v }
|
20
|
+
opts.on('-m', '--model MODEL', "Model to use (default: #{DEFAULT_MODEL})") { |v| options[:model] = v }
|
21
|
+
opts.on('-k', '--key-value PAIR', 'Key-value pairs for interpolation (format: key1=value1,key2=value2)') { |v| options[:key_value] = v }
|
22
|
+
end
|
23
|
+
|
24
|
+
def validate_options(options)
|
25
|
+
unless options[:prompt] || options[:file]
|
26
|
+
puts 'Missing required options: --prompt or --file. Use -h for help.'
|
27
|
+
exit
|
28
|
+
end
|
29
|
+
|
30
|
+
if options[:key_value]
|
31
|
+
key_value_pairs = options[:key_value].split(',').to_h { |pair| pair.split('=') }
|
32
|
+
options[:key_value] = key_value_pairs
|
33
|
+
else
|
34
|
+
options[:key_value] = {}
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def execute(options)
|
39
|
+
prompt_text = options[:prompt] || File.read(options[:file])
|
40
|
+
model = options[:model] || DEFAULT_MODEL
|
41
|
+
key_value_pairs = options[:key_value] || {}
|
42
|
+
|
43
|
+
# Interpolate key-value pairs into the prompt
|
44
|
+
key_value_pairs.each do |key, value|
|
45
|
+
prompt_text.gsub!("{#{key}}", value)
|
46
|
+
end
|
47
|
+
|
48
|
+
puts "Prompt: #{prompt_text}"
|
49
|
+
puts "Model: #{model}"
|
50
|
+
puts "Key-Value Pairs: #{key_value_pairs}"
|
51
|
+
|
52
|
+
# USE Library class to run this type of code
|
53
|
+
# client = OpenAI::Client.new(api_key: ENV['OPENAI_API_KEY'])
|
54
|
+
# response = client.completions(
|
55
|
+
# engine: model,
|
56
|
+
# parameters: {
|
57
|
+
# prompt: prompt_text,
|
58
|
+
# max_tokens: 100
|
59
|
+
# }
|
60
|
+
# )
|
61
|
+
|
62
|
+
# result = response['choices'].first['text'].strip
|
63
|
+
|
64
|
+
# if options[:output]
|
65
|
+
# File.write(options[:output], result)
|
66
|
+
# puts "Output written to #{options[:output]}"
|
67
|
+
# end
|
68
|
+
|
69
|
+
# if options[:clipboard]
|
70
|
+
# Clipboard.copy(result)
|
71
|
+
# puts 'Output copied to clipboard'
|
72
|
+
# end
|
73
|
+
|
74
|
+
puts 'Result:'
|
75
|
+
# puts result unless options[:output]
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Appydave
|
4
|
+
module Tools
|
5
|
+
module CliActions
|
6
|
+
# Action to update a YouTube video metadata (title, description, tags, category)
|
7
|
+
class UpdateVideoAction < BaseAction
|
8
|
+
protected
|
9
|
+
|
10
|
+
def define_options(opts, options)
|
11
|
+
opts.on('-v', '--video-id ID', 'YouTube Video ID') { |v| options[:video_id] = v }
|
12
|
+
opts.on('-t', '--title TITLE', 'Video Title') { |t| options[:title] = t }
|
13
|
+
opts.on('-d', '--description DESCRIPTION', 'Video Description') { |d| options[:description] = d }
|
14
|
+
opts.on('-g', '--tags TAGS', 'Video Tags (comma-separated)') { |g| options[:tags] = g.split(',') }
|
15
|
+
opts.on('-c', '--category-id CATEGORY_ID', 'Video Category ID') { |c| options[:category_id] = c }
|
16
|
+
end
|
17
|
+
|
18
|
+
def validate_options(options)
|
19
|
+
return if options[:video_id]
|
20
|
+
|
21
|
+
puts 'Missing required options: --video-id. Use -h for help.'
|
22
|
+
exit
|
23
|
+
end
|
24
|
+
|
25
|
+
def execute(options)
|
26
|
+
get_video = Appydave::Tools::YouTubeManager::GetVideo.new
|
27
|
+
get_video.get(options[:video_id])
|
28
|
+
|
29
|
+
if get_video.video?
|
30
|
+
update_video = Appydave::Tools::YouTubeManager::UpdateVideo.new(get_video.data)
|
31
|
+
|
32
|
+
update_video.title(options[:title]) if options[:title]
|
33
|
+
update_video.description(options[:description]) if options[:description]
|
34
|
+
update_video.tags(options[:tags]) if options[:tags]
|
35
|
+
update_video.category_id(options[:category_id]) if options[:category_id]
|
36
|
+
|
37
|
+
update_video.save
|
38
|
+
puts "Video updated successfully. ID: #{options[:video_id]}"
|
39
|
+
else
|
40
|
+
puts "Video not found! Maybe it's private or deleted. ID: #{options[:video_id]}"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -12,7 +12,9 @@ module Appydave
|
|
12
12
|
SCOPE = [
|
13
13
|
'https://www.googleapis.com/auth/youtube.readonly',
|
14
14
|
'https://www.googleapis.com/auth/youtube',
|
15
|
-
'https://www.googleapis.com/auth/youtube.force-ssl'
|
15
|
+
'https://www.googleapis.com/auth/youtube.force-ssl',
|
16
|
+
'https://www.googleapis.com/auth/youtubepartner',
|
17
|
+
'https://www.googleapis.com/auth/youtubepartner-channel-audit'
|
16
18
|
].freeze
|
17
19
|
|
18
20
|
def self.authorize
|
@@ -5,6 +5,8 @@ module Appydave
|
|
5
5
|
module YouTubeManager
|
6
6
|
# Manage YouTube video details
|
7
7
|
class GetVideo < YouTubeBase
|
8
|
+
include KLog::Logging
|
9
|
+
|
8
10
|
attr_reader :video_id
|
9
11
|
attr_reader :data
|
10
12
|
|
@@ -26,6 +28,8 @@ module Appydave
|
|
26
28
|
private
|
27
29
|
|
28
30
|
def build_data(video)
|
31
|
+
category_title = get_category_title(video.snippet.category_id)
|
32
|
+
|
29
33
|
data = {
|
30
34
|
id: video.id,
|
31
35
|
title: video.snippet.title,
|
@@ -33,6 +37,13 @@ module Appydave
|
|
33
37
|
published_at: video.snippet.published_at,
|
34
38
|
channel_id: video.snippet.channel_id,
|
35
39
|
channel_title: video.snippet.channel_title,
|
40
|
+
category_id: video.snippet.category_id,
|
41
|
+
tags: video.snippet.tags,
|
42
|
+
thumbnails: video.snippet.thumbnails.to_h,
|
43
|
+
default_audio_language: video.snippet.default_audio_language,
|
44
|
+
default_language: video.snippet.default_language,
|
45
|
+
live_broadcast_content: video.snippet.live_broadcast_content,
|
46
|
+
category_title: category_title,
|
36
47
|
view_count: video.statistics.view_count,
|
37
48
|
like_count: video.statistics.like_count,
|
38
49
|
dislike_count: video.statistics.dislike_count,
|
@@ -42,30 +53,35 @@ module Appydave
|
|
42
53
|
license: video.status.license,
|
43
54
|
recording_location: video.recording_details&.location,
|
44
55
|
recording_date: video.recording_details&.recording_date,
|
45
|
-
tags: video.snippet.tags,
|
46
|
-
thumbnails: video.snippet.thumbnails.to_h,
|
47
56
|
duration: video.content_details.duration,
|
48
57
|
definition: video.content_details.definition,
|
49
58
|
caption: video.content_details.caption,
|
50
59
|
licensed_content: video.content_details.licensed_content
|
51
60
|
}
|
61
|
+
get_captions(video.id) # Fetch captions and associate them
|
52
62
|
# HAVE NOT FIGURED OUT THE PERMISSION ISSUE WITH THIS YET
|
53
63
|
# captions: get_captions(video.id) # Fetch captions and associate them
|
54
64
|
@data = Appydave::Tools::YouTubeManager::Models::YouTubeDetails.new(data)
|
55
65
|
end
|
56
66
|
|
67
|
+
def get_category_title(category_id)
|
68
|
+
response = @service.list_video_categories('snippet', id: category_id)
|
69
|
+
category = response.items.first
|
70
|
+
category&.snippet&.title
|
71
|
+
end
|
72
|
+
|
57
73
|
def get_captions(video_id)
|
58
|
-
captions_response = @service.list_captions('snippet', video_id)
|
74
|
+
captions_response = @service.list_captions('id,snippet', video_id)
|
59
75
|
captions_response.items.map do |caption|
|
60
|
-
puts "Caption ID: #{caption.id}"
|
61
|
-
puts "Language: #{caption.snippet.language}"
|
62
|
-
puts "Status: #{caption.snippet.status}"
|
63
|
-
puts "Track Kind: #{caption.snippet.track_kind}"
|
64
|
-
puts "Name: #{caption.snippet.name}"
|
65
|
-
puts "Is Auto-Synced: #{caption.snippet.is_auto_synced}"
|
66
|
-
puts "Is CC: #{caption.snippet.is_cc}"
|
67
|
-
puts "Is Draft: #{caption.snippet.is_draft}"
|
68
|
-
puts "Last Updated: #{caption.snippet.last_updated}"
|
76
|
+
# puts "Caption ID: #{caption.id}"
|
77
|
+
# puts "Language: #{caption.snippet.language}"
|
78
|
+
# puts "Status: #{caption.snippet.status}"
|
79
|
+
# puts "Track Kind: #{caption.snippet.track_kind}"
|
80
|
+
# puts "Name: #{caption.snippet.name}"
|
81
|
+
# puts "Is Auto-Synced: #{caption.snippet.is_auto_synced}"
|
82
|
+
# puts "Is CC: #{caption.snippet.is_cc}"
|
83
|
+
# puts "Is Draft: #{caption.snippet.is_draft}"
|
84
|
+
# puts "Last Updated: #{caption.snippet.last_updated}"
|
69
85
|
|
70
86
|
next unless caption.snippet.status == 'serving'
|
71
87
|
|
@@ -83,6 +99,7 @@ module Appydave
|
|
83
99
|
def download_caption(caption)
|
84
100
|
content = ''
|
85
101
|
formats = %w[srv1 vtt srt ttml] # Try multiple formats to find a compatible one
|
102
|
+
success = false
|
86
103
|
formats.each do |format|
|
87
104
|
break if content.present?
|
88
105
|
|
@@ -90,14 +107,18 @@ module Appydave
|
|
90
107
|
@service.download_caption(caption.id, tfmt: format) do |result, error|
|
91
108
|
if error.nil?
|
92
109
|
content = result
|
93
|
-
|
94
|
-
|
110
|
+
success = true
|
111
|
+
# else
|
112
|
+
# log.info "An error occurred while downloading caption #{caption.id} with format #{format}: #{error.message}"
|
95
113
|
end
|
96
114
|
end
|
97
115
|
rescue Google::Apis::ClientError => e
|
98
|
-
|
116
|
+
log.error "An error occurred while downloading caption #{caption.id} with format #{format}: #{e.message}"
|
99
117
|
end
|
100
118
|
end
|
119
|
+
|
120
|
+
log.error 'Error occurred while downloading captions, make sure you have the correct permissions.' unless success
|
121
|
+
|
101
122
|
content
|
102
123
|
end
|
103
124
|
end
|
@@ -12,11 +12,21 @@ module Appydave
|
|
12
12
|
include ActiveModel::Attributes
|
13
13
|
|
14
14
|
attribute :id, :string
|
15
|
-
attribute :title, :string
|
16
|
-
attribute :description, :string
|
17
|
-
attribute :published_at, :datetime
|
18
|
-
attribute :channel_id, :string
|
19
|
-
attribute :channel_title, :string
|
15
|
+
attribute :title, :string # snippet
|
16
|
+
attribute :description, :string # snippet
|
17
|
+
attribute :published_at, :datetime # snippet
|
18
|
+
attribute :channel_id, :string # snippet
|
19
|
+
attribute :channel_title, :string # snippet
|
20
|
+
attribute :category_id, :string # snippet
|
21
|
+
|
22
|
+
attribute :default_audio_language # snippet
|
23
|
+
attribute :default_language # snippet
|
24
|
+
attribute :live_broadcast_content # snippet
|
25
|
+
|
26
|
+
attribute :tags, array: true # snippet
|
27
|
+
attribute :thumbnails, :hash # snippet
|
28
|
+
|
29
|
+
attribute :category_title, :string
|
20
30
|
attribute :view_count, :integer
|
21
31
|
attribute :like_count, :integer
|
22
32
|
attribute :dislike_count, :integer
|
@@ -26,18 +36,58 @@ module Appydave
|
|
26
36
|
attribute :license, :string
|
27
37
|
attribute :recording_location, :string
|
28
38
|
attribute :recording_date, :datetime
|
29
|
-
attribute :tags, array: true
|
30
|
-
attribute :thumbnails, :hash
|
31
39
|
attribute :duration, :string
|
32
40
|
attribute :definition, :string
|
33
41
|
attribute :caption, :boolean
|
34
42
|
attribute :licensed_content, :boolean
|
35
|
-
|
43
|
+
attribute :captions, :array # , default: []
|
44
|
+
|
45
|
+
def initialize(attributes = {})
|
46
|
+
super
|
47
|
+
self.captions = attributes[:captions].map { |caption| Captions.new(caption) } if attributes[:captions]
|
48
|
+
end
|
49
|
+
|
50
|
+
def map_video_snippet
|
51
|
+
{
|
52
|
+
title: title,
|
53
|
+
description: description,
|
54
|
+
category_id: category_id,
|
55
|
+
tags: tags || [],
|
56
|
+
thumbnails: thumbnails
|
57
|
+
}
|
58
|
+
end
|
36
59
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
60
|
+
def to_h
|
61
|
+
{
|
62
|
+
id: id,
|
63
|
+
title: title,
|
64
|
+
description: description,
|
65
|
+
published_at: published_at,
|
66
|
+
channel_id: channel_id,
|
67
|
+
channel_title: channel_title,
|
68
|
+
category_id: category_id,
|
69
|
+
category_title: category_title,
|
70
|
+
default_audio_language: default_audio_language,
|
71
|
+
default_language: default_language,
|
72
|
+
live_broadcast_content: live_broadcast_content,
|
73
|
+
tags: tags,
|
74
|
+
thumbnails: thumbnails,
|
75
|
+
view_count: view_count,
|
76
|
+
like_count: like_count,
|
77
|
+
dislike_count: dislike_count,
|
78
|
+
comment_count: comment_count,
|
79
|
+
privacy_status: privacy_status,
|
80
|
+
embeddable: embeddable,
|
81
|
+
license: license,
|
82
|
+
recording_location: recording_location,
|
83
|
+
recording_date: recording_date,
|
84
|
+
duration: duration,
|
85
|
+
definition: definition,
|
86
|
+
caption: caption,
|
87
|
+
licensed_content: licensed_content
|
88
|
+
}
|
89
|
+
# captions: captions.map(&:to_h)
|
90
|
+
end
|
41
91
|
end
|
42
92
|
end
|
43
93
|
end
|
@@ -12,22 +12,27 @@ module Appydave
|
|
12
12
|
# log.heading 'Video Details Report'
|
13
13
|
# log.subheading 'Video Details Report'
|
14
14
|
log.section_heading 'Video Details Report'
|
15
|
-
log.kv 'ID', data
|
16
|
-
log.kv 'Title', data
|
17
|
-
log.kv '
|
18
|
-
log.kv '
|
19
|
-
log.kv '
|
20
|
-
log.kv '
|
21
|
-
log.kv '
|
22
|
-
log.kv '
|
23
|
-
log.kv '
|
24
|
-
log.kv 'Channel
|
25
|
-
log.kv '
|
26
|
-
log.kv '
|
27
|
-
log.kv '
|
28
|
-
log.kv '
|
29
|
-
log.kv '
|
30
|
-
log.kv '
|
15
|
+
log.kv 'ID', data.id
|
16
|
+
log.kv 'Title', data.title
|
17
|
+
log.kv 'Description', data.description[0..100]
|
18
|
+
log.kv 'Published At', data.published_at
|
19
|
+
log.kv 'View Count', data.view_count
|
20
|
+
log.kv 'Like Count', data.like_count
|
21
|
+
log.kv 'Dislike Count', data.dislike_count
|
22
|
+
log.kv 'Comment Count', data.comment_count
|
23
|
+
log.kv 'Privacy Status', data.privacy_status
|
24
|
+
log.kv 'Channel ID', data.channel_id
|
25
|
+
log.kv 'Channel Title', data.channel_title
|
26
|
+
log.kv 'Category ID', data.category_id
|
27
|
+
log.kv 'Category Title', data.category_title
|
28
|
+
log.kv 'Default Audio Language', data.default_audio_language
|
29
|
+
log.kv 'Default Language', data.default_language
|
30
|
+
log.kv 'Live Broadcast Content', data.live_broadcast_content
|
31
|
+
log.kv 'Embeddable', data.embeddable
|
32
|
+
log.kv 'License', data.license
|
33
|
+
log.kv 'Recording Location', data.recording_location
|
34
|
+
log.kv 'Recording Date', data.recording_date
|
35
|
+
log.kv 'Tags', data.tags&.join(', ')
|
31
36
|
end
|
32
37
|
end
|
33
38
|
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Appydave
|
4
|
+
module Tools
|
5
|
+
module YouTubeManager
|
6
|
+
# Update YouTube video details
|
7
|
+
class UpdateVideo < YouTubeBase
|
8
|
+
attr_reader :video_details
|
9
|
+
attr_reader :snippet
|
10
|
+
|
11
|
+
def initialize(video_details)
|
12
|
+
super()
|
13
|
+
@video_details = video_details
|
14
|
+
end
|
15
|
+
|
16
|
+
def title(title)
|
17
|
+
video_details.title = title
|
18
|
+
|
19
|
+
self
|
20
|
+
end
|
21
|
+
|
22
|
+
def description(description)
|
23
|
+
video_details.description = description
|
24
|
+
|
25
|
+
self
|
26
|
+
end
|
27
|
+
|
28
|
+
def tags(tags)
|
29
|
+
video_details.tags = tags
|
30
|
+
|
31
|
+
self
|
32
|
+
end
|
33
|
+
|
34
|
+
def category_id(category_id)
|
35
|
+
video_details.category_id = category_id
|
36
|
+
|
37
|
+
self
|
38
|
+
end
|
39
|
+
|
40
|
+
def save
|
41
|
+
snippet = video_details.map_video_snippet
|
42
|
+
|
43
|
+
video = Google::Apis::YoutubeV3::Video.new(
|
44
|
+
id: video_details.id,
|
45
|
+
snippet: snippet
|
46
|
+
)
|
47
|
+
|
48
|
+
@service.update_video('snippet', video)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
data/lib/appydave/tools.rb
CHANGED
@@ -22,8 +22,12 @@ require 'appydave/tools/types/indifferent_access_hash'
|
|
22
22
|
require 'appydave/tools/types/hash_type'
|
23
23
|
require 'appydave/tools/types/array_type'
|
24
24
|
|
25
|
-
|
26
|
-
|
25
|
+
require 'appydave/tools/cli_actions/base_action'
|
26
|
+
|
27
|
+
# May want to move this into the tools location
|
28
|
+
require 'appydave/tools/cli_actions/prompt_completion_action'
|
29
|
+
require 'appydave/tools/cli_actions/get_video_action'
|
30
|
+
require 'appydave/tools/cli_actions/update_video_action'
|
27
31
|
|
28
32
|
require 'appydave/tools/gpt_context/file_collector'
|
29
33
|
|
@@ -50,6 +54,7 @@ require 'appydave/tools/youtube_manager/models/captions'
|
|
50
54
|
require 'appydave/tools/youtube_manager/youtube_base'
|
51
55
|
require 'appydave/tools/youtube_manager/authorization'
|
52
56
|
require 'appydave/tools/youtube_manager/get_video'
|
57
|
+
require 'appydave/tools/youtube_manager/update_video'
|
53
58
|
require 'appydave/tools/youtube_manager/reports/video_details_report'
|
54
59
|
require 'appydave/tools/youtube_manager/reports/video_content_report'
|
55
60
|
|
data/package-lock.json
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
{
|
2
2
|
"name": "appydave-tools",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.10.0",
|
4
4
|
"lockfileVersion": 3,
|
5
5
|
"requires": true,
|
6
6
|
"packages": {
|
7
7
|
"": {
|
8
8
|
"name": "appydave-tools",
|
9
|
-
"version": "0.
|
9
|
+
"version": "0.10.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
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.
|
4
|
+
version: 0.10.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-
|
11
|
+
date: 2024-06-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -160,6 +160,7 @@ files:
|
|
160
160
|
- bin/configuration.rb
|
161
161
|
- bin/console
|
162
162
|
- bin/gpt_context.rb
|
163
|
+
- bin/prompt_tools.rb
|
163
164
|
- bin/setup
|
164
165
|
- bin/subtitle_master.rb
|
165
166
|
- bin/youtube_automation.rb
|
@@ -171,6 +172,11 @@ files:
|
|
171
172
|
- lib/appydave/tools/bank_reconciliation/clean/mapper.rb
|
172
173
|
- lib/appydave/tools/bank_reconciliation/clean/read_transactions.rb
|
173
174
|
- lib/appydave/tools/bank_reconciliation/models/transaction.rb
|
175
|
+
- lib/appydave/tools/cli_actions/_doc.md
|
176
|
+
- lib/appydave/tools/cli_actions/base_action.rb
|
177
|
+
- lib/appydave/tools/cli_actions/get_video_action.rb
|
178
|
+
- lib/appydave/tools/cli_actions/prompt_completion_action.rb
|
179
|
+
- lib/appydave/tools/cli_actions/update_video_action.rb
|
174
180
|
- lib/appydave/tools/configuration/_doc.md
|
175
181
|
- lib/appydave/tools/configuration/config.rb
|
176
182
|
- lib/appydave/tools/configuration/configurable.rb
|
@@ -200,6 +206,7 @@ files:
|
|
200
206
|
- lib/appydave/tools/youtube_manager/models/youtube_details.rb
|
201
207
|
- lib/appydave/tools/youtube_manager/reports/video_content_report.rb
|
202
208
|
- lib/appydave/tools/youtube_manager/reports/video_details_report.rb
|
209
|
+
- lib/appydave/tools/youtube_manager/update_video.rb
|
203
210
|
- lib/appydave/tools/youtube_manager/youtube_base.rb
|
204
211
|
- package-lock.json
|
205
212
|
- package.json
|