eivu_fingerprinter_acoustid 1.0.0
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 +7 -0
- data/.circleci/config.yml +26 -0
- data/.rspec +3 -0
- data/.rubocop.yml +51 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/LICENSE.txt +21 -0
- data/README.md +7 -0
- data/Rakefile +12 -0
- data/config/environment.rb +7 -0
- data/lib/eivu_fingerprinter_acoustid/engine.rb +58 -0
- data/lib/eivu_fingerprinter_acoustid/objects/artist.rb +17 -0
- data/lib/eivu_fingerprinter_acoustid/objects/base_class.rb +42 -0
- data/lib/eivu_fingerprinter_acoustid/objects/match.rb +76 -0
- data/lib/eivu_fingerprinter_acoustid/objects/recording.rb +39 -0
- data/lib/eivu_fingerprinter_acoustid/objects/release_group.rb +21 -0
- data/lib/eivu_fingerprinter_acoustid/objects/result.rb +85 -0
- data/lib/eivu_fingerprinter_acoustid/objects/result_set.rb +30 -0
- data/lib/eivu_fingerprinter_acoustid/objects.rb +9 -0
- data/lib/eivu_fingerprinter_acoustid/version.rb +5 -0
- data/lib/eivu_fingerprinter_acoustid.rb +11 -0
- data/sig/eivu_fingerprinter_acoustid.rbs +4 -0
- metadata +299 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a961431893e46c761c95b32ce36733758c16090b9185a40704af619877e74acc
|
4
|
+
data.tar.gz: f5863b630bc5c0e73d75b128a7ea76b5eac4034ed8107610da0285aa661bd8ea
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 70f2780026b2a5e7a0d8185c6aa575d1834381a7fdfad68b3269d5b12ae8fb2db012898462c0b42fe9f63bb3d461c0dd4cbd555b0750c191f1726bdcc2648267
|
7
|
+
data.tar.gz: 8bdbdb9e82b6f8dab873cad44d970b7ea3775eab45af1e52581baad4835f7572c9fc33afea764d49df6b80e1237426af62fd8ae42a716bbcc7da6dcfc8690f95
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# Use the latest 2.1 version of CircleCI pipeline process engine.
|
2
|
+
# See: https://circleci.com/docs/2.0/configuration-reference
|
3
|
+
version: 2.1
|
4
|
+
|
5
|
+
# Define a job to be invoked later in a workflow.
|
6
|
+
# See: https://circleci.com/docs/2.0/configuration-reference/#jobs
|
7
|
+
jobs:
|
8
|
+
say-hello:
|
9
|
+
# Specify the execution environment. You can specify an image from Dockerhub or use one of our Convenience Images from CircleCI's Developer Hub.
|
10
|
+
# See: https://circleci.com/docs/2.0/configuration-reference/#docker-machine-macos-windows-executor
|
11
|
+
docker:
|
12
|
+
- image: cimg/base:stable
|
13
|
+
# Add steps to the job
|
14
|
+
# See: https://circleci.com/docs/2.0/configuration-reference/#steps
|
15
|
+
steps:
|
16
|
+
- checkout
|
17
|
+
- run:
|
18
|
+
name: "Say hello"
|
19
|
+
command: "echo Hello, World!"
|
20
|
+
|
21
|
+
# Invoke jobs via workflows
|
22
|
+
# See: https://circleci.com/docs/2.0/configuration-reference/#workflows
|
23
|
+
workflows:
|
24
|
+
say-hello-workflow:
|
25
|
+
jobs:
|
26
|
+
- say-hello
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 3.2.5
|
3
|
+
|
4
|
+
NewCops: enable
|
5
|
+
SuggestExtensions: false
|
6
|
+
Exclude:
|
7
|
+
- notes/**/*
|
8
|
+
- spec/support/vcr_helper.rb
|
9
|
+
- spec/spec_helper.rb
|
10
|
+
Style/StringLiterals:
|
11
|
+
EnforcedStyle: double_quotes
|
12
|
+
|
13
|
+
Style/StringLiteralsInInterpolation:
|
14
|
+
EnforcedStyle: double_quotes
|
15
|
+
|
16
|
+
# We want some defaults merged instead of overwriting them.
|
17
|
+
inherit_mode:
|
18
|
+
merge:
|
19
|
+
- Exclude # for all cops
|
20
|
+
- AllowedNames # for Naming/Uncommunicative* cops
|
21
|
+
- IgnoredMethods # for Style/SymbolProc
|
22
|
+
|
23
|
+
|
24
|
+
Style/Documentation:
|
25
|
+
Enabled: false
|
26
|
+
|
27
|
+
Metrics/BlockLength:
|
28
|
+
Exclude:
|
29
|
+
- spec/**/*.rb
|
30
|
+
|
31
|
+
# No need to keep chasing and fixing autogenerated files, as well as splitting
|
32
|
+
# urls in route configs.
|
33
|
+
Layout/LineLength:
|
34
|
+
Max: 120
|
35
|
+
Exclude:
|
36
|
+
- eivu-client-ruby.gemspec
|
37
|
+
- Gemfile
|
38
|
+
- spec/spec_helper.rb
|
39
|
+
- spec/support/vcr_helper.rb
|
40
|
+
|
41
|
+
|
42
|
+
Metrics/ClassLength:
|
43
|
+
Enabled: false
|
44
|
+
|
45
|
+
Metrics/MethodLength:
|
46
|
+
Max: 30
|
47
|
+
Exclude:
|
48
|
+
- spec/**/*.rb
|
49
|
+
|
50
|
+
Metrics/AbcSize:
|
51
|
+
Enabled: false
|
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
6
|
+
|
7
|
+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
8
|
+
|
9
|
+
## Our Standards
|
10
|
+
|
11
|
+
Examples of behavior that contributes to a positive environment for our community include:
|
12
|
+
|
13
|
+
- Demonstrating empathy and kindness toward other people
|
14
|
+
- Being respectful of differing opinions, viewpoints, and experiences
|
15
|
+
- Giving and gracefully accepting constructive feedback
|
16
|
+
- Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
17
|
+
- Focusing on what is best not just for us as individuals, but for the overall community
|
18
|
+
|
19
|
+
Examples of unacceptable behavior include:
|
20
|
+
|
21
|
+
- The use of sexualized language or imagery, and sexual attention or
|
22
|
+
advances of any kind
|
23
|
+
- Trolling, insulting or derogatory comments, and personal or political attacks
|
24
|
+
- Public or private harassment
|
25
|
+
- Publishing others' private information, such as a physical or email
|
26
|
+
address, without their explicit permission
|
27
|
+
- Other conduct which could reasonably be considered inappropriate in a
|
28
|
+
professional setting
|
29
|
+
|
30
|
+
## Enforcement Responsibilities
|
31
|
+
|
32
|
+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
33
|
+
|
34
|
+
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
35
|
+
|
36
|
+
## Scope
|
37
|
+
|
38
|
+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
39
|
+
|
40
|
+
## Enforcement
|
41
|
+
|
42
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at 384403+dabobert@users.noreply.github.com. All complaints will be reviewed and investigated promptly and fairly.
|
43
|
+
|
44
|
+
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
45
|
+
|
46
|
+
## Enforcement Guidelines
|
47
|
+
|
48
|
+
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
49
|
+
|
50
|
+
### 1. Correction
|
51
|
+
|
52
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
53
|
+
|
54
|
+
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
55
|
+
|
56
|
+
### 2. Warning
|
57
|
+
|
58
|
+
**Community Impact**: A violation through a single incident or series of actions.
|
59
|
+
|
60
|
+
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
61
|
+
|
62
|
+
### 3. Temporary Ban
|
63
|
+
|
64
|
+
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
65
|
+
|
66
|
+
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
67
|
+
|
68
|
+
### 4. Permanent Ban
|
69
|
+
|
70
|
+
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
71
|
+
|
72
|
+
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
73
|
+
|
74
|
+
## Attribution
|
75
|
+
|
76
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
|
77
|
+
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
78
|
+
|
79
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
80
|
+
|
81
|
+
[homepage]: https://www.contributor-covenant.org
|
82
|
+
|
83
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
84
|
+
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2025 Rob Jenkins
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rest_client"
|
4
|
+
require "pry"
|
5
|
+
require "oj"
|
6
|
+
require "active_support/all"
|
7
|
+
|
8
|
+
module EivuFingerprinterAcoustid
|
9
|
+
class Engine
|
10
|
+
SERVICE_LOOKUP_URL = "https://api.acoustid.org/v2/lookup"
|
11
|
+
SETTINGS = "recordings+releasegroups+compress"
|
12
|
+
|
13
|
+
attr_reader :fingerprint, :duration, :raw_response, :response, :calc_output
|
14
|
+
|
15
|
+
def self.identify(path_to_file = nil)
|
16
|
+
instance = new
|
17
|
+
instance.generate(path_to_file)
|
18
|
+
instance.submit
|
19
|
+
end
|
20
|
+
|
21
|
+
def initialize
|
22
|
+
@client_id = ENV.fetch("ACOUSTID_CLIENT_ID", nil)
|
23
|
+
end
|
24
|
+
|
25
|
+
def generate(path_to_file)
|
26
|
+
# call fingerprint calculator
|
27
|
+
@calc_output = execute_binary(path_to_file)
|
28
|
+
# output is in the format of:
|
29
|
+
# DURATION=267
|
30
|
+
# FINGERPRINT=AQADtHKTZFJG7LSwHxeJuGmhj4i6Bj
|
31
|
+
info = @calc_output.split("\n").each_with_object({}) do |line, hash|
|
32
|
+
key, value = line.strip.split("=")
|
33
|
+
hash[key.downcase.to_sym] = value
|
34
|
+
end
|
35
|
+
@fingerprint = info[:fingerprint]
|
36
|
+
@duration = info[:duration]&.to_i
|
37
|
+
end
|
38
|
+
|
39
|
+
def submit
|
40
|
+
@raw_response = RestClient.get(fingerprint_url)
|
41
|
+
@response = Oj.load(@raw_response)&.deep_symbolize_keys
|
42
|
+
end
|
43
|
+
|
44
|
+
def fingerprint_url
|
45
|
+
"#{SERVICE_LOOKUP_URL}?client=#{@client_id}&duration=#{@duration}&fingerprint=#{@fingerprint}&meta=#{SETTINGS}"
|
46
|
+
end
|
47
|
+
|
48
|
+
def cleansed_fingerprint_url
|
49
|
+
fingerprint_url.gsub(@client_id, "<ACOUSTID_CLIENT_ID>")
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def execute_binary(path_to_file)
|
55
|
+
`fpcalc "#{path_to_file}"`
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'base_class'
|
4
|
+
|
5
|
+
module EivuFingerprinterAcoustid
|
6
|
+
module Objects
|
7
|
+
class Artist < BaseClass
|
8
|
+
attr_reader :id, :name, :joinphrase
|
9
|
+
|
10
|
+
def initialize(id:, name:, joinphrase: nil)
|
11
|
+
@id = id
|
12
|
+
@name = name
|
13
|
+
@joinphrase = joinphrase
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EivuFingerprinterAcoustid
|
4
|
+
module Objects
|
5
|
+
class BaseClass
|
6
|
+
|
7
|
+
def ==(other)
|
8
|
+
other.class == self.class && other&.id == id
|
9
|
+
end
|
10
|
+
|
11
|
+
def hash
|
12
|
+
state.hash
|
13
|
+
end
|
14
|
+
|
15
|
+
def state
|
16
|
+
instance_variables.map { |variable| instance_variable_get variable }
|
17
|
+
end
|
18
|
+
|
19
|
+
# def ==(other)
|
20
|
+
# other.class == self.class && other.state == self.state
|
21
|
+
# end
|
22
|
+
|
23
|
+
alias eql? ==
|
24
|
+
alias equal? ==
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def instantiate_artists(artists)
|
29
|
+
artists.collect do |a|
|
30
|
+
case a.class.name
|
31
|
+
when 'Hash'
|
32
|
+
EivuFingerprinterAcoustid::Objects::Artist.new(**a)
|
33
|
+
when 'EivuFingerprinterAcoustid::Objects::Artist'
|
34
|
+
a
|
35
|
+
else
|
36
|
+
raise ArgumentError, "Mismatched Type: #{a.class} passed to create artist"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../objects'
|
4
|
+
require 'active_support/all'
|
5
|
+
require "damerau-levenshtein"
|
6
|
+
|
7
|
+
module EivuFingerprinterAcoustid
|
8
|
+
module Objects
|
9
|
+
class Match
|
10
|
+
include Comparable
|
11
|
+
|
12
|
+
THRESHOLD_MIN = 12
|
13
|
+
OFFSET_IN_STRING = 1
|
14
|
+
OFFSET_REORDERED = 5
|
15
|
+
THRESHOLD_REORDERED = 0.85
|
16
|
+
|
17
|
+
attr_reader :release_group, :recording, :result_score,
|
18
|
+
:original_release_group_name, :matched_release_group_name,
|
19
|
+
:result_id
|
20
|
+
|
21
|
+
delegate :duration, to: :recording
|
22
|
+
delegate :title, to: :recording
|
23
|
+
delegate :type, to: :release_group
|
24
|
+
delegate :secondarytypes, to: :release_group
|
25
|
+
delegate :secondary_types, to: :release_group
|
26
|
+
|
27
|
+
def initialize(recording:, result_score:, release_group:, original_release_group_name:, matched_release_group_name:, result_id:)
|
28
|
+
@release_group = release_group
|
29
|
+
@recording = recording
|
30
|
+
@result_score = result_score
|
31
|
+
@original_release_group_name = original_release_group_name
|
32
|
+
@matched_release_group_name = matched_release_group_name
|
33
|
+
@result_id = result_id
|
34
|
+
end
|
35
|
+
|
36
|
+
# returns 1 if self > other
|
37
|
+
# returns 0 if self == other
|
38
|
+
# returns -1 if self < other
|
39
|
+
def <=> (other)
|
40
|
+
result_score <=> other.result_score
|
41
|
+
end
|
42
|
+
|
43
|
+
def distance
|
44
|
+
@distance ||=
|
45
|
+
begin
|
46
|
+
orig_album = original_release_group_name&.downcase
|
47
|
+
matched_album = release_group.title&.downcase
|
48
|
+
l_distance = DamerauLevenshtein.distance(orig_album, matched_album)
|
49
|
+
if l_distance <= THRESHOLD_MIN
|
50
|
+
l_distance
|
51
|
+
else
|
52
|
+
shorter, longer = [orig_album, matched_album].sort{|x,y| x.length <=> y .length}
|
53
|
+
return THRESHOLD_MIN + OFFSET_IN_STRING if longer.include?(shorter)
|
54
|
+
|
55
|
+
shorter_cleansed = shorter.gsub(/[^0-9a-z ]/i, '')
|
56
|
+
longer_cleansed = longer.gsub(/[^0-9a-z ]/i, '')
|
57
|
+
find_count = shorter_cleansed.split.count do |word|
|
58
|
+
longer_cleansed.include?(word)
|
59
|
+
end
|
60
|
+
reordered_percentage = find_count / shorter_cleansed.split.count.to_f
|
61
|
+
return THRESHOLD_MIN + OFFSET_REORDERED if reordered_percentage >= THRESHOLD_REORDERED
|
62
|
+
|
63
|
+
raise "fix this: distance is #{l_distance}"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def print_artists
|
69
|
+
puts "release_group: #{release_group.artists.collect(&:name).join(', ')}"
|
70
|
+
puts "recording: #{recording.artists.collect(&:name).join(', ')}"
|
71
|
+
end
|
72
|
+
|
73
|
+
alias releasegroup release_group
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../objects'
|
4
|
+
|
5
|
+
module EivuFingerprinterAcoustid
|
6
|
+
module Objects
|
7
|
+
class Recording < BaseClass
|
8
|
+
attr_reader :id, :duration, :releasegroups, :title, :artists
|
9
|
+
|
10
|
+
def initialize(id:, title: nil, artists: [], release_groups: [], releasegroups: [], duration: nil)
|
11
|
+
if release_groups.present? && releasegroups.present?
|
12
|
+
raise ArgumentError, 'can not pass in both release_groups AND releasegroups to constructor'
|
13
|
+
end
|
14
|
+
|
15
|
+
@id = id
|
16
|
+
@duration = duration
|
17
|
+
@title = title
|
18
|
+
@artists = instantiate_artists(artists)
|
19
|
+
@releasegroups = releasegroups.collect do |rg|
|
20
|
+
case rg.class.name
|
21
|
+
when 'Hash'
|
22
|
+
EivuFingerprinterAcoustid::Objects::ReleaseGroup.new(**rg)
|
23
|
+
when 'EivuFingerprinterAcoustid::Objects::ReleaseGroup'
|
24
|
+
rg
|
25
|
+
else
|
26
|
+
raise ArgumentError, "Mismatched Type: #{rg.class} passed to create release group"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# will delete before completion
|
32
|
+
def shallow_clone
|
33
|
+
EivuFingerprinterAcoustid::Objects::Recording.new(id: id, title: title, artists: artists, releasegroups: [], duration: duration)
|
34
|
+
end
|
35
|
+
|
36
|
+
alias release_groups releasegroups
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../objects'
|
4
|
+
|
5
|
+
module EivuFingerprinterAcoustid
|
6
|
+
module Objects
|
7
|
+
class ReleaseGroup < BaseClass
|
8
|
+
attr_reader :id, :type, :title, :artists, :secondarytypes
|
9
|
+
|
10
|
+
def initialize(id:, title: ,type: nil, artists: [], secondarytypes: nil)
|
11
|
+
@id = id
|
12
|
+
@type = type
|
13
|
+
@title = title
|
14
|
+
@artists = instantiate_artists(artists)
|
15
|
+
@secondarytypes = secondarytypes
|
16
|
+
end
|
17
|
+
|
18
|
+
alias secondary_types secondarytypes
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../objects"
|
4
|
+
|
5
|
+
module EivuFingerprinterAcoustid
|
6
|
+
module Objects
|
7
|
+
class Result < BaseClass
|
8
|
+
DURATION_ACCEPTANCE_RANGE = 15
|
9
|
+
attr_reader :id, :recordings, :score
|
10
|
+
|
11
|
+
def initialize(id:, recordings: [], score: nil)
|
12
|
+
@id = id
|
13
|
+
@recordings = recordings.collect { |r| EivuFingerprinterAcoustid::Objects::Recording.new(**r) }
|
14
|
+
@score = score
|
15
|
+
end
|
16
|
+
|
17
|
+
def generate_match(duration:, release_group_name: nil)
|
18
|
+
filtered_recordings = filter_empty_recordings(recordings)
|
19
|
+
|
20
|
+
if release_group_name.present?
|
21
|
+
filter_recordings_via_release_group_name(filtered_recordings, release_group_name)
|
22
|
+
elsif duration.present?
|
23
|
+
filter_recordings_via_duration(filtered_recordings, duration)
|
24
|
+
else
|
25
|
+
nil
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def recordings?
|
30
|
+
@has_recordings ||= recordings.present?
|
31
|
+
end
|
32
|
+
|
33
|
+
def no_recordings?
|
34
|
+
@no_recordings ||= !recordings?
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def filter_recordings_via_duration(tmp_recordings, duration)
|
40
|
+
tmp_recordings.filter do |r|
|
41
|
+
r.duration.present? && (r.duration.to_i - duration) <= DURATION_ACCEPTANCE_RANGE
|
42
|
+
end.first
|
43
|
+
# data = tmp_recordings.filter do |r|
|
44
|
+
# r.duration.present? && (r.duration.to_i - duration) <= DURATION_ACCEPTANCE_RANGE
|
45
|
+
# end
|
46
|
+
# rg = data.sort do |a, b|
|
47
|
+
# (a.duration.to_i - duration).abs <=> (b.duration.to_i - duration).abs
|
48
|
+
# end.last
|
49
|
+
end
|
50
|
+
|
51
|
+
def filter_recordings_via_release_group_name(tmp_recordings, release_group_name)
|
52
|
+
filtered_albums = tmp_recordings.flat_map do |r|
|
53
|
+
r.release_groups.collect(&:title)
|
54
|
+
end
|
55
|
+
|
56
|
+
# match album via fuzzy match
|
57
|
+
matcher = FuzzyMatch.new(filtered_albums)
|
58
|
+
match = matcher.find(release_group_name)
|
59
|
+
|
60
|
+
# return recording that matched the album found via fuzzy match
|
61
|
+
tmp_recordings.each do |rec|
|
62
|
+
rec.release_groups.each do |rg|
|
63
|
+
if rg.title == match
|
64
|
+
return EivuFingerprinterAcoustid::Objects::Match.new(release_group: rg,
|
65
|
+
recording: rec.shallow_clone,
|
66
|
+
result_score: score,
|
67
|
+
original_release_group_name: release_group_name,
|
68
|
+
matched_release_group_name: match,
|
69
|
+
result_id: id)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
nil
|
74
|
+
end
|
75
|
+
|
76
|
+
def filter_empty_recordings(tmp_recordings)
|
77
|
+
tmp_recordings.select { |r| r.title.present? }
|
78
|
+
end
|
79
|
+
|
80
|
+
def prune_bracketed_string(string)
|
81
|
+
string.split("]").collect { |x| x.split("[")[0] }.join
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_relative '../objects'
|
3
|
+
|
4
|
+
module EivuFingerprinterAcoustid
|
5
|
+
module Objects
|
6
|
+
class ResultSet
|
7
|
+
attr_reader :results, :status
|
8
|
+
|
9
|
+
OK_STATUS = 'ok'
|
10
|
+
|
11
|
+
def initialize(results:, status:)
|
12
|
+
@results = results.collect { |r| EivuFingerprinterAcoustid::Objects::Result.new(**r) }
|
13
|
+
@status = status
|
14
|
+
end
|
15
|
+
|
16
|
+
def best_match(duration:, release_group_name: nil)
|
17
|
+
raise(ArgumentError, 'ResultSet did not return OK') unless ok?
|
18
|
+
|
19
|
+
# generate array of matches
|
20
|
+
matches = results.collect {|r| r.generate_match(duration: duration, release_group_name: release_group_name) }
|
21
|
+
# prune nil results and return highest scoring match
|
22
|
+
matches.compact.max
|
23
|
+
end
|
24
|
+
|
25
|
+
def ok?
|
26
|
+
@status == OK_STATUS
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative './objects/artist'
|
4
|
+
require_relative './objects/base_class'
|
5
|
+
require_relative './objects/release_group'
|
6
|
+
require_relative './objects/recording'
|
7
|
+
require_relative './objects/result'
|
8
|
+
require_relative './objects/result_set'
|
9
|
+
require_relative './objects/match'
|
metadata
ADDED
@@ -0,0 +1,299 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: eivu_fingerprinter_acoustid
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Rob Jenkins
|
8
|
+
bindir: exe
|
9
|
+
cert_chain: []
|
10
|
+
date: 2025-04-05 00:00:00.000000000 Z
|
11
|
+
dependencies:
|
12
|
+
- !ruby/object:Gem::Dependency
|
13
|
+
name: activesupport
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - ">="
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: 6.1.4
|
19
|
+
- - "<"
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '8.0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: 6.1.4
|
29
|
+
- - "<"
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: '8.0'
|
32
|
+
- !ruby/object:Gem::Dependency
|
33
|
+
name: amatch
|
34
|
+
requirement: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - "~>"
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: 0.4.0
|
39
|
+
type: :runtime
|
40
|
+
prerelease: false
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
requirements:
|
43
|
+
- - "~>"
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 0.4.0
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: colorize
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - "~>"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 0.8.1
|
53
|
+
type: :runtime
|
54
|
+
prerelease: false
|
55
|
+
version_requirements: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - "~>"
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: 0.8.1
|
60
|
+
- !ruby/object:Gem::Dependency
|
61
|
+
name: damerau-levenshtein
|
62
|
+
requirement: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - "~>"
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '1.3'
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 1.3.3
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '1.3'
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: 1.3.3
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: factory_bot
|
82
|
+
requirement: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - "~>"
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '6.5'
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 6.5.1
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '6.5'
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: 6.5.1
|
100
|
+
- !ruby/object:Gem::Dependency
|
101
|
+
name: faker
|
102
|
+
requirement: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - "~>"
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '2.18'
|
107
|
+
type: :runtime
|
108
|
+
prerelease: false
|
109
|
+
version_requirements: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - "~>"
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '2.18'
|
114
|
+
- !ruby/object:Gem::Dependency
|
115
|
+
name: fuzzy_match
|
116
|
+
requirement: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - "~>"
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '2.1'
|
121
|
+
type: :runtime
|
122
|
+
prerelease: false
|
123
|
+
version_requirements: !ruby/object:Gem::Requirement
|
124
|
+
requirements:
|
125
|
+
- - "~>"
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '2.1'
|
128
|
+
- !ruby/object:Gem::Dependency
|
129
|
+
name: id3tag
|
130
|
+
requirement: !ruby/object:Gem::Requirement
|
131
|
+
requirements:
|
132
|
+
- - "~>"
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: '1.1'
|
135
|
+
type: :runtime
|
136
|
+
prerelease: false
|
137
|
+
version_requirements: !ruby/object:Gem::Requirement
|
138
|
+
requirements:
|
139
|
+
- - "~>"
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '1.1'
|
142
|
+
- !ruby/object:Gem::Dependency
|
143
|
+
name: oj
|
144
|
+
requirement: !ruby/object:Gem::Requirement
|
145
|
+
requirements:
|
146
|
+
- - "~>"
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: '3.3'
|
149
|
+
- - ">="
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: 3.3.5
|
152
|
+
type: :runtime
|
153
|
+
prerelease: false
|
154
|
+
version_requirements: !ruby/object:Gem::Requirement
|
155
|
+
requirements:
|
156
|
+
- - "~>"
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: '3.3'
|
159
|
+
- - ">="
|
160
|
+
- !ruby/object:Gem::Version
|
161
|
+
version: 3.3.5
|
162
|
+
- !ruby/object:Gem::Dependency
|
163
|
+
name: pry
|
164
|
+
requirement: !ruby/object:Gem::Requirement
|
165
|
+
requirements:
|
166
|
+
- - "~>"
|
167
|
+
- !ruby/object:Gem::Version
|
168
|
+
version: 0.14.1
|
169
|
+
type: :runtime
|
170
|
+
prerelease: false
|
171
|
+
version_requirements: !ruby/object:Gem::Requirement
|
172
|
+
requirements:
|
173
|
+
- - "~>"
|
174
|
+
- !ruby/object:Gem::Version
|
175
|
+
version: 0.14.1
|
176
|
+
- !ruby/object:Gem::Dependency
|
177
|
+
name: rest-client
|
178
|
+
requirement: !ruby/object:Gem::Requirement
|
179
|
+
requirements:
|
180
|
+
- - "~>"
|
181
|
+
- !ruby/object:Gem::Version
|
182
|
+
version: '2.1'
|
183
|
+
type: :runtime
|
184
|
+
prerelease: false
|
185
|
+
version_requirements: !ruby/object:Gem::Requirement
|
186
|
+
requirements:
|
187
|
+
- - "~>"
|
188
|
+
- !ruby/object:Gem::Version
|
189
|
+
version: '2.1'
|
190
|
+
- !ruby/object:Gem::Dependency
|
191
|
+
name: rspec
|
192
|
+
requirement: !ruby/object:Gem::Requirement
|
193
|
+
requirements:
|
194
|
+
- - "~>"
|
195
|
+
- !ruby/object:Gem::Version
|
196
|
+
version: '3.10'
|
197
|
+
type: :runtime
|
198
|
+
prerelease: false
|
199
|
+
version_requirements: !ruby/object:Gem::Requirement
|
200
|
+
requirements:
|
201
|
+
- - "~>"
|
202
|
+
- !ruby/object:Gem::Version
|
203
|
+
version: '3.10'
|
204
|
+
- !ruby/object:Gem::Dependency
|
205
|
+
name: rubocop
|
206
|
+
requirement: !ruby/object:Gem::Requirement
|
207
|
+
requirements:
|
208
|
+
- - "~>"
|
209
|
+
- !ruby/object:Gem::Version
|
210
|
+
version: '1.17'
|
211
|
+
type: :runtime
|
212
|
+
prerelease: false
|
213
|
+
version_requirements: !ruby/object:Gem::Requirement
|
214
|
+
requirements:
|
215
|
+
- - "~>"
|
216
|
+
- !ruby/object:Gem::Version
|
217
|
+
version: '1.17'
|
218
|
+
- !ruby/object:Gem::Dependency
|
219
|
+
name: vcr
|
220
|
+
requirement: !ruby/object:Gem::Requirement
|
221
|
+
requirements:
|
222
|
+
- - "~>"
|
223
|
+
- !ruby/object:Gem::Version
|
224
|
+
version: '6.0'
|
225
|
+
type: :runtime
|
226
|
+
prerelease: false
|
227
|
+
version_requirements: !ruby/object:Gem::Requirement
|
228
|
+
requirements:
|
229
|
+
- - "~>"
|
230
|
+
- !ruby/object:Gem::Version
|
231
|
+
version: '6.0'
|
232
|
+
- !ruby/object:Gem::Dependency
|
233
|
+
name: webmock
|
234
|
+
requirement: !ruby/object:Gem::Requirement
|
235
|
+
requirements:
|
236
|
+
- - "~>"
|
237
|
+
- !ruby/object:Gem::Version
|
238
|
+
version: '3.13'
|
239
|
+
type: :runtime
|
240
|
+
prerelease: false
|
241
|
+
version_requirements: !ruby/object:Gem::Requirement
|
242
|
+
requirements:
|
243
|
+
- - "~>"
|
244
|
+
- !ruby/object:Gem::Version
|
245
|
+
version: '3.13'
|
246
|
+
description: " ruby wrapper for the [AcoustID](https://acoustid.org/) service\n"
|
247
|
+
email:
|
248
|
+
- 384403+dabobert@users.noreply.github.com
|
249
|
+
executables: []
|
250
|
+
extensions: []
|
251
|
+
extra_rdoc_files: []
|
252
|
+
files:
|
253
|
+
- ".circleci/config.yml"
|
254
|
+
- ".rspec"
|
255
|
+
- ".rubocop.yml"
|
256
|
+
- CHANGELOG.md
|
257
|
+
- CODE_OF_CONDUCT.md
|
258
|
+
- LICENSE.txt
|
259
|
+
- README.md
|
260
|
+
- Rakefile
|
261
|
+
- config/environment.rb
|
262
|
+
- lib/eivu_fingerprinter_acoustid.rb
|
263
|
+
- lib/eivu_fingerprinter_acoustid/engine.rb
|
264
|
+
- lib/eivu_fingerprinter_acoustid/objects.rb
|
265
|
+
- lib/eivu_fingerprinter_acoustid/objects/artist.rb
|
266
|
+
- lib/eivu_fingerprinter_acoustid/objects/base_class.rb
|
267
|
+
- lib/eivu_fingerprinter_acoustid/objects/match.rb
|
268
|
+
- lib/eivu_fingerprinter_acoustid/objects/recording.rb
|
269
|
+
- lib/eivu_fingerprinter_acoustid/objects/release_group.rb
|
270
|
+
- lib/eivu_fingerprinter_acoustid/objects/result.rb
|
271
|
+
- lib/eivu_fingerprinter_acoustid/objects/result_set.rb
|
272
|
+
- lib/eivu_fingerprinter_acoustid/version.rb
|
273
|
+
- sig/eivu_fingerprinter_acoustid.rbs
|
274
|
+
homepage: https://github.com/eivu/eivu-fingerprinter-acoustid-ruby
|
275
|
+
licenses:
|
276
|
+
- MIT
|
277
|
+
metadata:
|
278
|
+
homepage_uri: https://github.com/eivu/eivu-fingerprinter-acoustid-ruby
|
279
|
+
source_code_uri: https://github.com/eivu/eivu-fingerprinter-acoustid-ruby
|
280
|
+
changelog_uri: https://github.com/eivu/eivu-fingerprinter-acoustid-ruby/blob/main/CHANGELOG.md
|
281
|
+
rubygems_mfa_required: 'true'
|
282
|
+
rdoc_options: []
|
283
|
+
require_paths:
|
284
|
+
- lib
|
285
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
286
|
+
requirements:
|
287
|
+
- - ">="
|
288
|
+
- !ruby/object:Gem::Version
|
289
|
+
version: 3.2.5
|
290
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
291
|
+
requirements:
|
292
|
+
- - ">="
|
293
|
+
- !ruby/object:Gem::Version
|
294
|
+
version: '0'
|
295
|
+
requirements: []
|
296
|
+
rubygems_version: 3.6.6
|
297
|
+
specification_version: 4
|
298
|
+
summary: Ruby wrapper for the AcoustID service
|
299
|
+
test_files: []
|