piwigo-api 0.5.10 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/CHANGELOG.md +9 -4
- data/Gemfile.lock +1 -1
- data/examples/Different_Port.md +42 -0
- data/examples/Syncronize_Folder.md +3 -3
- data/examples/Upload_Image.md +6 -2
- data/lib/piwigo/image_uploader.rb +3 -1
- data/lib/piwigo/images.rb +4 -3
- data/lib/piwigo/session.rb +6 -5
- data/lib/piwigo/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7fc5b8141101c1b604876f7d5bf09effc43bbb016fc1a41b46541e8d3b743553
|
4
|
+
data.tar.gz: bde9f990a5d2dc96577094a89677fdc5d013edd75d77be152dd51e1cb8eeab82
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e073d758652e9f9bba60b7de66d1025b22c03cbf5b051692c4187b9ea9c3b88fe1c308d449bc2df047960604ec0e6d507f68a316024acc0fd7e9cf4fc0fe7e58
|
7
|
+
data.tar.gz: 3b0375000c48966b96d67a51b79f49e3958493390087854eaa1b629c6438c4587e1a3b08ba0d0d838e272a8d77f46d91a245de62487219467da3da8c0ced6b2e
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
5
5
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
+
0.6.0 - 2022-01-17
|
8
|
+
- Added support for specifying the port to connect to Piwigo on, and added an example
|
9
|
+
- Fixed a regression bug from updating EXITF gem
|
10
|
+
- Additional spelling fixes
|
11
|
+
|
7
12
|
0.5.10 - 2022-01-16
|
8
13
|
- Update Gemfile dependencies
|
9
14
|
- Code and documentation cleanups
|
@@ -24,8 +29,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
24
29
|
- Fix another encoding issue when synchronizing folder with accented characters.
|
25
30
|
|
26
31
|
0.5.4 - 2019-11-26
|
27
|
-
- Fix crash in sniff_attributes when the image
|
28
|
-
- Fix parent albums when
|
32
|
+
- Fix crash in sniff_attributes when the image doesn't contain a valid EXIF data
|
33
|
+
- Fix parent albums when synchronizing a folder-tree of albums into Piwigo
|
29
34
|
|
30
35
|
0.5.3 - 2019-11-25
|
31
36
|
- Fixed to coverage reports
|
@@ -38,10 +43,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
38
43
|
|
39
44
|
0.5.0 - 2019-11-23
|
40
45
|
- Added a directory of example scripts
|
41
|
-
- Added a folder-album
|
46
|
+
- Added a folder-album synchronization methods
|
42
47
|
|
43
48
|
0.4.0 - 2019-11-20
|
44
|
-
- Add methods to check for the
|
49
|
+
- Add methods to check for the existence of a specific image and to upload images
|
45
50
|
|
46
51
|
0.3.1 - 2019-11-20
|
47
52
|
- Add a codecov.yaml for coverage reports
|
data/Gemfile.lock
CHANGED
@@ -0,0 +1,42 @@
|
|
1
|
+
## Specify a URL with a port
|
2
|
+
|
3
|
+
If you are running Piwigo on a non-standard port in docker, you can specify the port when connecting:
|
4
|
+
|
5
|
+
```ruby
|
6
|
+
require 'piwigo/session'
|
7
|
+
require 'piwigo/images'
|
8
|
+
|
9
|
+
|
10
|
+
session = Piwigo::Session.login('localhost', 'root', 'piwigo', port: 8083, https: false)
|
11
|
+
unless session.nil?
|
12
|
+
require 'piwigo/session'
|
13
|
+
require 'piwigo/albums'
|
14
|
+
|
15
|
+
album = Piwigo::Albums::Album.new
|
16
|
+
album.name = "Chippy"
|
17
|
+
album = Piwigo::Albums.add(session, album)
|
18
|
+
|
19
|
+
filename = 'C:\Photos\chippy.jpg'
|
20
|
+
if Piwigo::Images.lookup(session, filename).nil?
|
21
|
+
Piwigo::Images.upload(session, filename, album, 'apple-pie-bars')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
```
|
25
|
+
|
26
|
+
Example output:
|
27
|
+
~~~
|
28
|
+
$ ruby main.rb
|
29
|
+
I, [2022-01-16T20:40:27.437987 #13428] INFO -- : Login succeeded: {"stat":"ok","result":true}
|
30
|
+
I, [2022-01-16T20:40:27.471733 #13428] INFO -- : Status succeeded
|
31
|
+
I, [2022-01-16T20:40:27.475731 #13428] INFO -- : Encoding: Chippy - UTF-8
|
32
|
+
I, [2022-01-16T20:40:27.534389 #13428] INFO -- : Album Add succeeded: Chippy(1) created.
|
33
|
+
I, [2022-01-16T20:40:27.589282 #13428] INFO -- : Image lookup succeeded: {"e49804192ae97cd09460e09fddb8187a"=>nil}
|
34
|
+
I, [2022-01-16T20:40:27.702908 #13428] INFO -- : Image AddChunk #0 succeeded: {"stat"=>"ok", "result"=>nil}
|
35
|
+
I, [2022-01-16T20:40:27.817544 #13428] INFO -- : Image AddChunk #1 succeeded: {"stat"=>"ok", "result"=>nil}
|
36
|
+
I, [2022-01-16T20:40:27.901301 #13428] INFO -- : Image AddChunk #2 succeeded: {"stat"=>"ok", "result"=>nil}
|
37
|
+
I, [2022-01-16T20:40:27.902947 #13428] INFO -- : --> GPS: 45.33110277777778, -75.79546111111111
|
38
|
+
I, [2022-01-16T20:40:27.903224 #13428] INFO -- : {:date_creation=>"2022-01-16", :categories=>1}
|
39
|
+
{"stat"=>"ok", "result"=>{"image_id"=>1, "url"=>"http://localhost:8083:8000/picture.php?/1/category/1"}}
|
40
|
+
I, [2022-01-16T20:40:27.980021 #13428] INFO -- : Image Add succeeded.
|
41
|
+
|
42
|
+
~~~
|
@@ -1,6 +1,6 @@
|
|
1
|
-
##
|
1
|
+
## Synchronize a Directory with Piwigo
|
2
2
|
|
3
|
-
To
|
3
|
+
To synchronize a folder-tree of im ages with Piwigo:
|
4
4
|
|
5
5
|
```ruby
|
6
6
|
require 'piwigo/session'
|
@@ -14,7 +14,7 @@ unless session.nil?
|
|
14
14
|
end
|
15
15
|
```
|
16
16
|
|
17
|
-
Call the script with the directory to
|
17
|
+
Call the script with the directory to synchronize. Eg:
|
18
18
|
|
19
19
|
```ruby
|
20
20
|
ruby main.rb //DISKSTATION/photos/
|
data/examples/Upload_Image.md
CHANGED
@@ -9,9 +9,13 @@ require 'piwigo/images'
|
|
9
9
|
|
10
10
|
session = Piwigo::Session.login('10.100.230.78', 'Adrian', 'mypassword', https: false)
|
11
11
|
unless session.nil?
|
12
|
+
album = Piwigo::Albums::Album.new
|
13
|
+
album.name = "Recipes"
|
14
|
+
album = Piwigo::Albums.add(session, album)
|
15
|
+
|
12
16
|
filename = 'C:\photos\apple-pie-bars-articleLarge.jpg'
|
13
|
-
if Piwigo::Images.
|
14
|
-
Piwigo::Images.
|
17
|
+
if Piwigo::Images.lookup(session, filename).nil?
|
18
|
+
Piwigo::Images.upload(session, filename, album, 'apple-pie-bars')
|
15
19
|
end
|
16
20
|
end
|
17
21
|
```
|
@@ -4,6 +4,7 @@ require 'json'
|
|
4
4
|
require 'logger'
|
5
5
|
require 'digest'
|
6
6
|
require 'base64'
|
7
|
+
require 'exifr/jpeg'
|
7
8
|
|
8
9
|
# Add a photo.
|
9
10
|
#
|
@@ -28,7 +29,7 @@ module Piwigo
|
|
28
29
|
# @param [<Type>] name of the image
|
29
30
|
#
|
30
31
|
# @return [Boolean] True if successful
|
31
|
-
def upload(session, filename, name, album:
|
32
|
+
def upload(session, filename, name, album: nil)
|
32
33
|
@session = session
|
33
34
|
raise 'Invalid session' if @session.uri.nil?
|
34
35
|
|
@@ -134,6 +135,7 @@ module Piwigo
|
|
134
135
|
@logger.info 'Image Add succeeded.'
|
135
136
|
true
|
136
137
|
else
|
138
|
+
@logger.error "Unexpected error: #{response.code}"
|
137
139
|
false
|
138
140
|
end
|
139
141
|
rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError => e
|
data/lib/piwigo/images.rb
CHANGED
@@ -131,11 +131,12 @@ module Piwigo
|
|
131
131
|
#
|
132
132
|
# @param [<Type>] session
|
133
133
|
# @param [<Type>] filename of the file to upload
|
134
|
-
# @param [
|
134
|
+
# @param [Album] album to place tge image in
|
135
|
+
# @param [String] name of the image
|
135
136
|
#
|
136
137
|
# @return [Boolean] True if successful
|
137
|
-
def self.upload(session, file, name)
|
138
|
-
ImageUploader.new(session, file, name)
|
138
|
+
def self.upload(session, file, album, name)
|
139
|
+
ImageUploader.new.upload(session, file, name, album: album)
|
139
140
|
end
|
140
141
|
|
141
142
|
# Checks existence of images
|
data/lib/piwigo/session.rb
CHANGED
@@ -78,9 +78,10 @@ module Piwigo
|
|
78
78
|
# @param [string] piwigo - host to connect to. Can be fqdn or ip.
|
79
79
|
# @param [string] username - user to connect as
|
80
80
|
# @param [string] password - password for user
|
81
|
-
# @param [boolean] https -
|
81
|
+
# @param [boolean] https -
|
82
|
+
# @param [port] Optional port. If not specified, then http connections will use 80, https 443
|
82
83
|
# @param [Logger] logger logger to output debug messages to (Optional)
|
83
|
-
def self.login(host, username, password, https: true, logger: nil)
|
84
|
+
def self.login(host, username, password, https: true, port: nil, logger: nil)
|
84
85
|
raise 'host should not be nil' if host.nil?
|
85
86
|
raise 'username should not be nil' if username.nil?
|
86
87
|
|
@@ -88,9 +89,9 @@ module Piwigo
|
|
88
89
|
|
89
90
|
begin
|
90
91
|
uri = if https
|
91
|
-
URI::HTTPS.build(host: host, path: '/ws.php', query: 'format=json')
|
92
|
+
URI::HTTPS.build(host: host, port: port.nil? ? 443 : port, path: '/ws.php', query: 'format=json')
|
92
93
|
else
|
93
|
-
URI::HTTP.build(host: host, path: '/ws.php', query: 'format=json')
|
94
|
+
URI::HTTP.build(host: host, port: port.nil? ? 80 : port, path: '/ws.php', query: 'format=json')
|
94
95
|
end
|
95
96
|
|
96
97
|
# Create the HTTP objects
|
@@ -108,7 +109,7 @@ module Piwigo
|
|
108
109
|
|
109
110
|
if response.code == '200'
|
110
111
|
logger.info "Login succeeded: #{response.body}"
|
111
|
-
pwg_id = response.response['set-cookie'].split(
|
112
|
+
pwg_id = response.response['set-cookie'].split(/[;,\,]/).select { |i| i.strip.start_with? 'pwg_id' }.first
|
112
113
|
return Session.new(pwg_id, uri)
|
113
114
|
else
|
114
115
|
logger.error "Login failed: #{response.body}"
|
data/lib/piwigo/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: piwigo-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adrian Gilbert
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-01-
|
11
|
+
date: 2022-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -160,6 +160,7 @@ files:
|
|
160
160
|
- bin/console
|
161
161
|
- bin/setup
|
162
162
|
- codecov.yml
|
163
|
+
- examples/Different_Port.md
|
163
164
|
- examples/Syncronize_Folder.md
|
164
165
|
- examples/Upload_Image.md
|
165
166
|
- lib/piwigo.rb
|