album_credits 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/album_credits +1 -6
- data/lib/album_credits/display.rb +36 -34
- data/lib/album_credits/exceptions.rb +2 -2
- data/lib/album_credits/finder.rb +5 -32
- data/lib/album_credits/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac07de44a12fbd6a53ce480b1104a52ff0d78115
|
4
|
+
data.tar.gz: 15c6c24b1dc5e5dfafa84996525a9e5fd82f8e2e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41ab815a49130b66bc8c89617b188b3c7a4849878ce1d11938403e8f79457ab3d4e504ae23066f534b113b4b14a64c3f46045ea6aa14f5d735c129f00c54e5d7
|
7
|
+
data.tar.gz: 65d4224ad5b9d3cbbeb4f5d1b0efe1a92f4a08071e859757e1b8957a3eb208545b6de80682828d7659a0345c8a3c3967604e757ace8dd48f48e1955dce3b1c98
|
data/bin/album_credits
CHANGED
@@ -23,12 +23,7 @@ sorted_releases = releases.inject([]) do |rel_array, release|
|
|
23
23
|
rel_array
|
24
24
|
end.sort_by{|arr| arr.last.size}.reverse
|
25
25
|
|
26
|
-
raise "No engineering data
|
26
|
+
raise "No engineering data found." if sorted_releases.empty?
|
27
27
|
|
28
28
|
best_guess = sorted_releases.shift
|
29
29
|
ac.display_release(best_guess.first, best_guess.last, :color => :green, :show_discography => true)
|
30
|
-
|
31
|
-
|
32
|
-
# sorted_releases.each do |release, engineers|
|
33
|
-
# ac.display_release(release, engineers)
|
34
|
-
# end
|
@@ -13,8 +13,14 @@ module AlbumCredits
|
|
13
13
|
:blue => "\e[34m"
|
14
14
|
}
|
15
15
|
|
16
|
-
|
17
|
-
|
16
|
+
|
17
|
+
def default_color
|
18
|
+
:white
|
19
|
+
end
|
20
|
+
|
21
|
+
def engineer_discog_max
|
22
|
+
100
|
23
|
+
end
|
18
24
|
|
19
25
|
# Prints the text in color
|
20
26
|
#
|
@@ -24,7 +30,7 @@ module AlbumCredits
|
|
24
30
|
# @options opts [Symbol] :color (default is .default_color)
|
25
31
|
def cp(text, opts={})
|
26
32
|
embolden = opts[:bold] ? COLORS[:bold] : ''
|
27
|
-
color = opts[:color] ||
|
33
|
+
color = opts[:color] || default_color
|
28
34
|
puts "#{embolden}#{COLORS[color]}#{text}#{COLORS[:clear]}"
|
29
35
|
end
|
30
36
|
|
@@ -36,27 +42,23 @@ module AlbumCredits
|
|
36
42
|
end
|
37
43
|
|
38
44
|
def display_release(release, engineers, opts={})
|
39
|
-
@default_color = opts.delete(:color) || :white
|
40
|
-
|
41
45
|
cp "="*40
|
42
|
-
cp
|
46
|
+
cp release.title
|
47
|
+
cp "#{release.tracklist.size} songs, released: #{release.released}"
|
43
48
|
cp release.uri
|
44
|
-
cp "#{release.tracklist.size} songs"
|
45
|
-
cp image_uri_for_release(release)
|
46
49
|
cp release.notes
|
47
|
-
|
50
|
+
cp ""
|
48
51
|
display_engineer_data(engineers, opts)
|
49
52
|
end
|
50
53
|
|
51
54
|
def get_artist_discog(artist)
|
52
55
|
begin
|
53
|
-
discogs.get_artists_releases(artist.id, per_page:
|
56
|
+
discogs.get_artists_releases(artist.id, per_page: engineer_discog_max, page: 1)
|
54
57
|
rescue Exception => e
|
55
58
|
puts e
|
56
59
|
end
|
57
60
|
end
|
58
61
|
|
59
|
-
# TODO: Put logical engineer sorting
|
60
62
|
# IDEA: show a cross-section of their work.
|
61
63
|
# maybe start with around the year that current album was released if there are many.
|
62
64
|
# ALSO: could filter their discog. output by x-ref w/ the role they
|
@@ -68,36 +70,36 @@ module AlbumCredits
|
|
68
70
|
cp "Engineers:", :color => :yellow
|
69
71
|
engineers.each do |engineer|
|
70
72
|
next if displayed.include? engineer.name
|
71
|
-
cp "#{engineer.
|
73
|
+
cp "#{engineer.name}: #{engineer.role}", :bold => true, :color => :red
|
72
74
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
aka = engineer.namevariations || []
|
78
|
-
aka << engineer.aliases.map(&:name) unless engineer.aliases.nil?
|
75
|
+
engineer_details = discogs.get_artist(engineer.id)
|
76
|
+
if (!engineer_details.nil?)
|
77
|
+
aka = engineer_details.namevariations || []
|
78
|
+
aka << engineer_details.aliases.map(&:name) unless engineer_details.aliases.nil?
|
79
79
|
if !(aliases = aka.flatten.uniq.sort).empty?
|
80
|
-
cp "AKA: #{aliases.join(', ')}"
|
80
|
+
cp "AKA: #{aliases.first(10).join(', ')}"
|
81
81
|
end
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
82
|
+
end
|
83
|
+
|
84
|
+
# Print the engineer's discography
|
85
|
+
engineer_discog = get_artist_discog(engineer_details)
|
86
|
+
|
87
|
+
if show_discography && !engineer_discog.nil? && engineer.role.match(/assisted|assistant|additional/i).nil?
|
88
|
+
discog_cnt = engineer_discog.releases.size == engineer_discog_max ? "#{engineer_discog_max}+" : engineer_discog.releases.size
|
89
|
+
cp "#{discog_cnt} releases in discography", :color => :yellow
|
90
|
+
|
91
|
+
cp engineer_details.uri
|
92
|
+
|
93
|
+
engineer_discog.releases.group_by{ |disk| disk.year }.sort_by{ |year, _| year || 0 }.reverse.each do |year, albums|
|
94
|
+
cp year, :bold => true, :color => :blue
|
95
|
+
albums.each do |a|
|
96
|
+
cp " * #{a.artist} - \"#{a.title}\", [#{a.role}]"
|
95
97
|
end
|
96
98
|
end
|
97
99
|
|
98
|
-
displayed <<
|
99
|
-
puts
|
100
|
+
displayed << engineer_details.name
|
100
101
|
end
|
102
|
+
puts
|
101
103
|
end
|
102
104
|
end
|
103
105
|
end
|
@@ -2,8 +2,8 @@ module AlbumCredits
|
|
2
2
|
|
3
3
|
class NoReleasesFound < StandardError
|
4
4
|
|
5
|
-
def initialize(artist, album
|
6
|
-
msg = "No releases found for Artist: #{artist} Album: #{album}"
|
5
|
+
def initialize(artist, album)
|
6
|
+
msg = "No releases found for Artist: #{artist} Album: #{album}"
|
7
7
|
super(msg)
|
8
8
|
end
|
9
9
|
|
data/lib/album_credits/finder.rb
CHANGED
@@ -13,31 +13,9 @@ module AlbumCredits
|
|
13
13
|
search_result.uri.split('/').last
|
14
14
|
end
|
15
15
|
|
16
|
-
# @param [String] the main string to search for
|
17
|
-
# @param [Hash,Optional] params
|
18
|
-
# @option params [String] :format CD, HDCD, vinyl, etc.
|
19
|
-
# @option params [String] :artist
|
20
|
-
# @option params [Fixnum] :year
|
21
|
-
def search(target, params={})
|
22
|
-
sections = []
|
23
|
-
params.each_pair do |key, val|
|
24
|
-
sections << "#{key}:#{val}" if val
|
25
|
-
end
|
26
|
-
|
27
|
-
search_string = "#{target} AND " << sections.join(" AND ")
|
28
|
-
debug "Searching for #{CGI.escape(search_string)}"
|
29
|
-
|
30
|
-
begin
|
31
|
-
discogs.search(CGI.escape(search_string), :type => 'releases')
|
32
|
-
rescue Discogs::UnknownResource => e
|
33
|
-
debug "Nothing found for #{search_string} #{e}"
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
16
|
def find_releases(artist, album)
|
38
|
-
|
39
17
|
releases = []
|
40
|
-
possibilities = discogs.search(album, type: 'release', artist: artist
|
18
|
+
possibilities = discogs.search(album, type: 'release', artist: artist)
|
41
19
|
|
42
20
|
if possibilities.pagination.items > 0
|
43
21
|
possibilities.results.each do |found_album|
|
@@ -55,10 +33,10 @@ module AlbumCredits
|
|
55
33
|
end
|
56
34
|
end
|
57
35
|
else
|
58
|
-
debug "no results for #{artist} #{album}
|
36
|
+
debug "no results for #{artist} #{album}"
|
59
37
|
end
|
60
38
|
|
61
|
-
raise AlbumCredits::NoReleasesFound.new(artist, album
|
39
|
+
raise AlbumCredits::NoReleasesFound.new(artist, album) if releases.empty?
|
62
40
|
|
63
41
|
# Sometimes Discogs returns duplicate releases so
|
64
42
|
# filter out any duplicates based on id.
|
@@ -76,14 +54,9 @@ module AlbumCredits
|
|
76
54
|
pristine_releases.size < uniq_releases.size ? pristine_releases : uniq_releases
|
77
55
|
end
|
78
56
|
|
57
|
+
# TODO: Look into filtering.
|
79
58
|
def engineers_for_release(release)
|
80
|
-
|
81
|
-
return engineers
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
def discography_for_artist(artist)
|
86
|
-
discogs.get_artist(CGI.escape(artist)) rescue []
|
59
|
+
release.extraartists
|
87
60
|
end
|
88
61
|
|
89
62
|
private
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: album_credits
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bassnode
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: discogs-wrapper
|