phoseum-cli 0.0.12 → 0.0.13
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 +4 -4
- data/bin/phoseum-cli +30 -4
- data/lib/phoseum/phoseum-cli-lib.rb +19 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 052beefab210d213c09986b11dfe93e499d328f6523f7f3cba71ecb2502ead53
|
|
4
|
+
data.tar.gz: 75fd5b65b74758d1517c61e65f69295ca445e70ba37e32ae57863da0ddb825d9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 44173a8f4ed5893c0fdd6b5a9ef2b4ab463b091ed4c35f237be7f3ad369044a281d9067edbf7bd9d72670c45973827d9428fc015a6071f4eff5e1ff1ffd55c5f
|
|
7
|
+
data.tar.gz: 68c50ae1d3cc2c35e4d369bc02bbba99236a07a1a3f3e314f73ff411bab7e3ee27965507afbb22b44220df36a411ee10a84586ad5109be62e4e2bf974cba7f95
|
data/bin/phoseum-cli
CHANGED
|
@@ -23,7 +23,7 @@ $MULTI = options[:multiple] ? true : false
|
|
|
23
23
|
|
|
24
24
|
client_checks
|
|
25
25
|
|
|
26
|
-
def upload(album)
|
|
26
|
+
def upload(album,syn_name='',description='')
|
|
27
27
|
headers = {}
|
|
28
28
|
if !validate_token($config['TOKEN'])
|
|
29
29
|
if token = user_login()
|
|
@@ -65,7 +65,8 @@ def upload(album)
|
|
|
65
65
|
# last resort solution for accents and unrecognizable characters
|
|
66
66
|
# but then will need to remove extension, pass the filter, then add extension again.
|
|
67
67
|
# human_name = check_string_sanity(filename)
|
|
68
|
-
human_name = filename.
|
|
68
|
+
human_name = filename.dup
|
|
69
|
+
human_name = human_name.gsub!(/(.*)\.JPG|JPEG|PNG|GIF$/i,'\1')
|
|
69
70
|
|
|
70
71
|
somefound = search_image(image.signature)
|
|
71
72
|
if somefound
|
|
@@ -84,6 +85,12 @@ def upload(album)
|
|
|
84
85
|
post_body << "\r\n--#{BOUNDARY}--\r\n"
|
|
85
86
|
http = Net::HTTP.new(uri.host, uri.port)
|
|
86
87
|
headers = headers.merge({ "filename" => "#{image.signature}.#{image.type}", "album" => "#{album}", "name" => human_name })
|
|
88
|
+
if ! syn_name.nil?
|
|
89
|
+
headers = headers.merge({ "album_name" => syn_name })
|
|
90
|
+
end
|
|
91
|
+
if ! description.nil?
|
|
92
|
+
headers = headers.merge({ "description" => description })
|
|
93
|
+
end
|
|
87
94
|
request = Net::HTTP::Post.new(uri, headers)
|
|
88
95
|
request.body = post_body.join
|
|
89
96
|
request["Content-Type"] = "multipart/form-data, boundary=#{BOUNDARY}"
|
|
@@ -468,8 +475,27 @@ case options
|
|
|
468
475
|
exit 1
|
|
469
476
|
else
|
|
470
477
|
album_clean=check_string_sanity(options[:album])
|
|
471
|
-
|
|
472
|
-
|
|
478
|
+
usable_name= options[:name] ? options[:name].dup : ''
|
|
479
|
+
usable_desc= options[:description] ? options[:description].dup : ''
|
|
480
|
+
if usable_name.length > 255 || usable_desc.length > 255
|
|
481
|
+
if usable_name.length > 255
|
|
482
|
+
puts "Synthetic name has #{usable_name.length} characters!!".red
|
|
483
|
+
end
|
|
484
|
+
if usable_desc.length > 255
|
|
485
|
+
puts "SHORT Description has #{usable_desc.length} characters!!".red
|
|
486
|
+
end
|
|
487
|
+
puts "This is a huge-ass string mate, what are you doing?".red
|
|
488
|
+
puts "We should limit this to 255 chars. Keep it short. Aborting.".red
|
|
489
|
+
exit 1
|
|
490
|
+
end
|
|
491
|
+
if options[:name]
|
|
492
|
+
usable_name = clean_name(options[:name])
|
|
493
|
+
usable_desc = clean_name(options[:description])
|
|
494
|
+
puts "Using Album destination: #{album_clean} --> Named as '#{usable_name}'".light_blue if !$QUIET
|
|
495
|
+
else
|
|
496
|
+
puts "Using Album destination: #{album_clean}".light_blue if !$QUIET
|
|
497
|
+
end
|
|
498
|
+
upload(album_clean,usable_name,usable_desc)
|
|
473
499
|
end
|
|
474
500
|
when -> (l) { l[:login] }
|
|
475
501
|
puts "Start login process".green if !$QUIET
|
|
@@ -20,6 +20,10 @@ def option_parser(opts)
|
|
|
20
20
|
options[:delete] = d
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
+
opts.on("-D", "--description 'SHORTDESC'", "Add album description (up to 255 chars). Use with: [album-path]") do |ds|
|
|
24
|
+
options[:description] = ds
|
|
25
|
+
end
|
|
26
|
+
|
|
23
27
|
opts.on("-f", "--file-cfg FILENAME", "Use alternative configuration file") do |f|
|
|
24
28
|
options[:filecfg] = f
|
|
25
29
|
end
|
|
@@ -36,6 +40,10 @@ def option_parser(opts)
|
|
|
36
40
|
options[:multiple] = m
|
|
37
41
|
end
|
|
38
42
|
|
|
43
|
+
opts.on("-N", "--name 'REALNAME'", "Set Album's synthetic name. Use with: [album-path]") do |n|
|
|
44
|
+
options[:name] = n
|
|
45
|
+
end
|
|
46
|
+
|
|
39
47
|
opts.on("-v", "--verbose", "Run verbosely (DEBUG mode)") do |v|
|
|
40
48
|
options[:verbose] = v
|
|
41
49
|
end
|
|
@@ -149,6 +157,17 @@ def clean_html(msg)
|
|
|
149
157
|
return msg
|
|
150
158
|
end
|
|
151
159
|
|
|
160
|
+
def clean_name(nameval)
|
|
161
|
+
name_words = nameval.split(' ')
|
|
162
|
+
name = ''
|
|
163
|
+
name_words.each do |word|
|
|
164
|
+
cword = check_string_sanity(word)
|
|
165
|
+
name = name.nil? ? cword : [name,cword].join(' ')
|
|
166
|
+
end
|
|
167
|
+
name.gsub!(/^\ /,'')
|
|
168
|
+
return name
|
|
169
|
+
end
|
|
170
|
+
|
|
152
171
|
def check_image_exists(fpath)
|
|
153
172
|
flocal = fpath.split('/')
|
|
154
173
|
filename = flocal.last
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: phoseum-cli
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.13
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Julio C Hegedus
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2020-
|
|
11
|
+
date: 2020-10-01 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: yaml
|