coverart 0.0.4 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/LICENSE +2 -2
- data/README.md +60 -38
- data/lib/coverart/client.rb +20 -15
- data/lib/coverart/version.rb +4 -2
- data/lib/coverart.rb +9 -3
- metadata +163 -12
- data/Gemfile +0 -5
- data/coverart.gemspec +0 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7482832207a739151da57cf58a4aea094663db2f926c6eb3e02656d5ca323564
|
4
|
+
data.tar.gz: ac62f312553eb8513837665ad318b0daf9c45113205e91cf9868fac036169f3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70560e663fd9f5955ee18d64fcd20a4b48ad3dd756e8126d407e0b2f0d26950159a62a9f3333f16b8c7637b862302dafe59d98d140be696c87a3c10874a31a38
|
7
|
+
data.tar.gz: 24ced50a671e4b86562d29d69419699bdc2430180c9a5a10489515547c4bf42f47421c09c33fb49f567788e157e5993f3db1ce949641deb2b56a58152fb9922d
|
data/LICENSE
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c)
|
1
|
+
Copyright (c) 2022 Savater Sebastien
|
2
2
|
|
3
3
|
MIT License
|
4
4
|
|
@@ -19,4 +19,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
19
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
20
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
21
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,67 +1,89 @@
|
|
1
|
-
#
|
1
|
+
# Coverart
|
2
2
|
|
3
3
|
A tiny client for the [Cover Art Archive](http://coverartarchive.org) web service.
|
4
4
|
|
5
|
-
It works great with the [Musicbrainz
|
5
|
+
It works great with the [Musicbrainz client](http://github.com/inkstak/musicbrainz).
|
6
6
|
|
7
|
-
[![
|
8
|
-
[![
|
7
|
+
[![Gem Version](https://badge.fury.io/rb/coverart.svg)](https://rubygems.org/gems/coverart)
|
8
|
+
[![CI Status](https://github.com/inkstak/coverart/actions/workflows/ci.yml/badge.svg)](https://github.com/inkstak/coverart/actions/workflows/ci.yml)
|
9
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/9bb8b75ea8c66b1a9c94/maintainability)](https://codeclimate.com/github/inkstak/coverart/maintainability)
|
9
10
|
|
10
|
-
### Ruby Version
|
11
|
-
|
12
|
-
Ruby version 1.9.0+ required.
|
13
11
|
|
14
12
|
### Installation
|
15
13
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
14
|
+
```bash
|
15
|
+
bundle add coverart
|
16
|
+
```
|
20
17
|
|
21
18
|
### Usage
|
22
19
|
|
23
|
-
|
20
|
+
You should first read the [JSON API manual](http://wiki.musicbrainz.org/Cover_Art_Archive/API) by Musicbrainz.
|
24
21
|
|
25
|
-
|
26
|
-
|
27
|
-
api.get '/release/76df3287-6cda-33eb-8e9a-044b5e15ffdd'
|
22
|
+
```ruby
|
23
|
+
require "coverart"
|
28
24
|
|
25
|
+
client = Coverart::Client.new
|
26
|
+
client.get("/release/76df3287-6cda-33eb-8e9a-044b5e15ffdd")
|
27
|
+
```
|
29
28
|
|
30
29
|
You can also use shortcuts :
|
31
30
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
# Get the back image URL
|
36
|
-
api.back '99b09d02-9cc9-3fed-8431-f162165a9371'
|
31
|
+
```ruby
|
32
|
+
# Get the front image URL
|
33
|
+
client.front("76df3287-6cda-33eb-8e9a-044b5e15ffdd")
|
37
34
|
|
38
|
-
|
39
|
-
|
35
|
+
# Get the back image URL
|
36
|
+
client.back("99b09d02-9cc9-3fed-8431-f162165a9371")
|
40
37
|
|
38
|
+
# Get the front image URL for a release group
|
39
|
+
client.group("76df3287-6cda-33eb-8e9a-044b5e15ffdd")
|
40
|
+
```
|
41
41
|
|
42
42
|
### Caching & middlewares
|
43
43
|
|
44
44
|
In order to perform caching, you can use [faraday_middleware](http://github.com/lostisland/faraday_middleware)
|
45
45
|
or your own middlewares:
|
46
46
|
|
47
|
-
|
48
|
-
|
47
|
+
```ruby
|
48
|
+
# FYI: faraday_middleware and active_support are not present in dependencies.
|
49
|
+
# Add them to your bundle.
|
49
50
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
api = CoverArt::Client.new do |f|
|
55
|
-
f.response :caching do
|
56
|
-
ActiveSupport::Cache.lookup_store :file_store, './tmp/cache', namespace: 'covertart', expires_in: 3600
|
57
|
-
end
|
58
|
-
end
|
51
|
+
require "coverart"
|
52
|
+
require "faraday_middleware"
|
53
|
+
require "active_support"
|
59
54
|
|
55
|
+
client = Coverart::Client.new do |connection|
|
56
|
+
connection.response :caching do
|
57
|
+
ActiveSupport::Cache.lookup_store(:file_store, "./tmp/cache", namespace: "covertart", expires_in: 3600)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
```
|
60
61
|
|
61
62
|
## Contributing
|
62
63
|
|
63
|
-
1.
|
64
|
-
2.
|
65
|
-
3.
|
66
|
-
4.
|
67
|
-
|
64
|
+
1. Don't hesitate to submit your feature/idea/fix in [issues](https://github.com/inkstak/coverart)
|
65
|
+
2. Fork the [repository](https://github.com/inkstak/coverart)
|
66
|
+
3. Create your feature branch
|
67
|
+
4. Ensure RSpec & Rubocop are passing
|
68
|
+
4. Create a pull request
|
69
|
+
|
70
|
+
### Tests & lint
|
71
|
+
|
72
|
+
```bash
|
73
|
+
bundle exec rspec
|
74
|
+
bundle exec rubocop
|
75
|
+
```
|
76
|
+
|
77
|
+
Both can be run with:
|
78
|
+
|
79
|
+
```bash
|
80
|
+
bundle exec rake
|
81
|
+
```
|
82
|
+
|
83
|
+
Rubocop uses [Standard](https://github.com/testdouble/standard) cops
|
84
|
+
|
85
|
+
## License & credits
|
86
|
+
|
87
|
+
Please see [LICENSE](https://github.com/inkstak/coverart/blob/main/LICENSE) for further details.
|
88
|
+
|
89
|
+
Contributors: [./graphs/contributors](https://github.com/inkstak/coverart/graphs/contributors)
|
data/lib/coverart/client.rb
CHANGED
@@ -1,43 +1,48 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "faraday"
|
4
|
+
require "json"
|
5
|
+
|
6
|
+
module Coverart
|
2
7
|
class Client
|
3
|
-
ENDPOINT =
|
8
|
+
ENDPOINT = "http://coverartarchive.org"
|
4
9
|
|
5
10
|
attr_reader :http
|
6
11
|
|
7
|
-
def initialize
|
8
|
-
@http ||= Faraday.new
|
9
|
-
|
10
|
-
|
12
|
+
def initialize(&block)
|
13
|
+
@http ||= Faraday.new(url: ENDPOINT) do |connection|
|
14
|
+
connection.adapter Faraday.default_adapter
|
15
|
+
yield connection if block
|
11
16
|
end
|
12
17
|
end
|
13
18
|
|
14
|
-
def get
|
15
|
-
response = http.get
|
19
|
+
def get(url)
|
20
|
+
response = http.get(url)
|
16
21
|
|
17
22
|
case response.status
|
18
|
-
when 404
|
19
|
-
when 200
|
23
|
+
when 404 then nil
|
24
|
+
when 200 then JSON.parse response.body
|
20
25
|
when 300..310
|
21
|
-
if response.headers[:location].match
|
26
|
+
if response.headers[:location].match?(/\.(jpg|jpeg|png|gif)/)
|
22
27
|
response.headers[:location]
|
23
28
|
else
|
24
29
|
get response.headers[:location]
|
25
30
|
end
|
26
31
|
else
|
27
|
-
raise "Unexpected response (#{
|
32
|
+
raise "Unexpected response (#{response.status}) at #{url}"
|
28
33
|
end
|
29
34
|
end
|
30
35
|
|
31
36
|
def front mbid
|
32
|
-
get
|
37
|
+
get("/release/#{mbid}/front")
|
33
38
|
end
|
34
39
|
|
35
40
|
def back mbid
|
36
|
-
get
|
41
|
+
get("/release/#{mbid}/back")
|
37
42
|
end
|
38
43
|
|
39
44
|
def group mbid
|
40
|
-
get
|
45
|
+
get("/release-group/#{mbid}/front")
|
41
46
|
end
|
42
47
|
end
|
43
48
|
end
|
data/lib/coverart/version.rb
CHANGED
data/lib/coverart.rb
CHANGED
metadata
CHANGED
@@ -1,39 +1,191 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coverart
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Savater Sebastien
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-08-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.5'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
16
30
|
requirements:
|
17
31
|
- - ">="
|
18
32
|
- !ruby/object:Gem::Version
|
19
33
|
version: '0'
|
20
|
-
type: :
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: gem-release
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop-rake
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
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: rubocop-rspec
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rubocop-performance
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: standard
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: webmock
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: zeitwerk
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :development
|
21
175
|
prerelease: false
|
22
176
|
version_requirements: !ruby/object:Gem::Requirement
|
23
177
|
requirements:
|
24
178
|
- - ">="
|
25
179
|
- !ruby/object:Gem::Version
|
26
180
|
version: '0'
|
27
|
-
description:
|
28
|
-
email:
|
181
|
+
description:
|
182
|
+
email: github.60k5k@simplelogin.co
|
29
183
|
executables: []
|
30
184
|
extensions: []
|
31
185
|
extra_rdoc_files: []
|
32
186
|
files:
|
33
|
-
- Gemfile
|
34
187
|
- LICENSE
|
35
188
|
- README.md
|
36
|
-
- coverart.gemspec
|
37
189
|
- lib/coverart.rb
|
38
190
|
- lib/coverart/client.rb
|
39
191
|
- lib/coverart/version.rb
|
@@ -41,7 +193,7 @@ homepage: http://github.com/inkstak/coverart
|
|
41
193
|
licenses:
|
42
194
|
- MIT
|
43
195
|
metadata: {}
|
44
|
-
post_install_message:
|
196
|
+
post_install_message:
|
45
197
|
rdoc_options: []
|
46
198
|
require_paths:
|
47
199
|
- lib
|
@@ -56,9 +208,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
56
208
|
- !ruby/object:Gem::Version
|
57
209
|
version: '0'
|
58
210
|
requirements: []
|
59
|
-
|
60
|
-
|
61
|
-
signing_key:
|
211
|
+
rubygems_version: 3.3.7
|
212
|
+
signing_key:
|
62
213
|
specification_version: 4
|
63
214
|
summary: A tiny client for the Cover Art Archive web service
|
64
215
|
test_files: []
|
data/Gemfile
DELETED
data/coverart.gemspec
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
require File.expand_path('../lib/coverart/version', __FILE__)
|
2
|
-
|
3
|
-
Gem::Specification.new do |s|
|
4
|
-
s.name = 'coverart'
|
5
|
-
s.version = CoverArt::VERSION
|
6
|
-
|
7
|
-
s.authors = ['Savater Sebastien']
|
8
|
-
s.email = 'savater.sebastien@gmail.com'
|
9
|
-
|
10
|
-
s.homepage = 'http://github.com/inkstak/coverart'
|
11
|
-
s.summary = 'A tiny client for the Cover Art Archive web service'
|
12
|
-
s.license = 'MIT'
|
13
|
-
|
14
|
-
s.files = %w(Gemfile LICENSE README.md coverart.gemspec)
|
15
|
-
s.files += Dir.glob('lib/**/*')
|
16
|
-
|
17
|
-
s.add_dependency 'faraday'
|
18
|
-
end
|