rjl-itunes 0.1.1 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/Rakefile +2 -2
- data/bin/{fix_genres.rb → fix_genres} +15 -3
- data/lib/rjl/itunes.rb +5 -1
- data/lib/rjl/metadata.rb +4 -2
- data/lib/rjl/utils.rb +11 -0
- data/lib/rjl/version.rb +1 -1
- data/rjl-itunes.gemspec +4 -1
- data/tasks/rspec.rake +3 -0
- metadata +57 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b51f6db257d91c3da935e318c1023569e9f6a4c
|
4
|
+
data.tar.gz: d7e51904c214d5d5d48e10e9e8fcc43e79dceb20
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74fb04c7e769fea3550fcecac0285f31acfc9ae0a94dce4aba2ce77ec5e0bd60218c52ef0fd24cd0d6222553579f2ec349c74337ad70c115a44e5c97f6c4de86
|
7
|
+
data.tar.gz: 2e78d219f048f10fae412016e85067348f07f2f442ecff65a95452d49fd162914f5123ce6a5b03d2ef6c2c37a50dc4473d9814a67b29957b2ae2f514c2c57a27
|
data/.gitignore
CHANGED
data/Rakefile
CHANGED
@@ -9,11 +9,15 @@
|
|
9
9
|
# (c) Richard Lyon 15 March, 2016
|
10
10
|
|
11
11
|
$: << File.join(File.dirname(__FILE__), '..', 'lib')
|
12
|
-
require 'rjl
|
12
|
+
require 'rjl'
|
13
|
+
|
14
|
+
logger = get_logger
|
15
|
+
logger.info "fix_genres: " "#{"="*80}"
|
13
16
|
|
14
17
|
# require 'metadata'
|
15
18
|
require 'ruby-progressbar' # https://github.com/jfelchner/ruby-progressbar/wiki
|
16
19
|
|
20
|
+
puts "\n> Updating iTunes library genres from Allmusic.com...\n\n"
|
17
21
|
itunes = RJL::Itunes.new
|
18
22
|
|
19
23
|
progressbar = ProgressBar.create(
|
@@ -22,14 +26,22 @@ progressbar = ProgressBar.create(
|
|
22
26
|
:total => itunes.albums.count)
|
23
27
|
|
24
28
|
# main loop - fix album genre unless tagged 'proteected'
|
29
|
+
count = 0
|
25
30
|
itunes.albums.each do |album|
|
26
31
|
metadata = RJL::Metadata.new( album: album )
|
27
|
-
progressbar.increment
|
28
32
|
unless album.protected?
|
33
|
+
current_genre = album.genre
|
29
34
|
new_genre = metadata.genre( album )
|
30
|
-
|
35
|
+
|
36
|
+
unless new_genre == "" || (current_genre == new_genre )
|
31
37
|
album.genre = metadata.genre( album )
|
32
38
|
progressbar.log "#{album.album_artist}, '#{album.title}' -> #{new_genre}"
|
39
|
+
logger.info "fix_genres: " "#{album.album_artist}, '#{album.title}' -> #{new_genre}"
|
40
|
+
count += 1
|
33
41
|
end
|
34
42
|
end
|
43
|
+
progressbar.increment
|
35
44
|
end
|
45
|
+
|
46
|
+
puts "\n> Attempted to updated genres for #{count} tracks (iCloud tracks not modified)"
|
47
|
+
puts "> See '/lib/logs/log.log' for details"
|
data/lib/rjl/itunes.rb
CHANGED
@@ -4,8 +4,12 @@ include Appscript
|
|
4
4
|
|
5
5
|
module RJL
|
6
6
|
# RJL_itunes::Itunes contains the public api for Itunes.
|
7
|
+
# @example
|
8
|
+
# require 'rjl/itunes'
|
9
|
+
#
|
10
|
+
# itunes = RJL::Itunes.new
|
11
|
+
# albums = itunes.albums
|
7
12
|
# @api public
|
8
|
-
# @example itunes = Itunes.new
|
9
13
|
|
10
14
|
class Itunes
|
11
15
|
|
data/lib/rjl/metadata.rb
CHANGED
@@ -5,7 +5,7 @@ module RJL
|
|
5
5
|
# Gets metadata for an album from allmusic.com, caching the results. See
|
6
6
|
# [rjl-music](https://github.com/richardjlyon/allmusic) for details. Computes
|
7
7
|
# a simplified genre by selecting the highest frequency genre and style in the
|
8
|
-
# library and combining them in a string.
|
8
|
+
# library and combining them in a string. Creates a cache file `lib/cache/cache.db`
|
9
9
|
class Metadata
|
10
10
|
|
11
11
|
attr_reader :genres
|
@@ -17,7 +17,9 @@ module RJL
|
|
17
17
|
# closes it on exit.
|
18
18
|
# @param [Itunes] itunes the itunes client to generate metadata for
|
19
19
|
def initialize( itunes )
|
20
|
-
|
20
|
+
|
21
|
+
cache_path = File.join((File.dirname __dir__), 'cache/cache.db')
|
22
|
+
@db = Daybreak::DB.new cache_path, :default => {}
|
21
23
|
@itunes = itunes
|
22
24
|
at_exit { @db.close }
|
23
25
|
end
|
data/lib/rjl/utils.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'logger'
|
2
|
+
|
1
3
|
# return true if tracks have only one value for 'parameter_name'
|
2
4
|
def unique?( tracks, parameter_name )
|
3
5
|
values = []
|
@@ -6,3 +8,12 @@ def unique?( tracks, parameter_name )
|
|
6
8
|
end
|
7
9
|
return values.uniq.length == 1
|
8
10
|
end
|
11
|
+
|
12
|
+
|
13
|
+
# a logger
|
14
|
+
def get_logger
|
15
|
+
log_path = File.join((File.dirname __dir__), 'logs/log.log')
|
16
|
+
logger = Logger.new(log_path, 'daily')
|
17
|
+
logger.datetime_format = "%Y-%m-%d"
|
18
|
+
return logger
|
19
|
+
end
|
data/lib/rjl/version.rb
CHANGED
data/rjl-itunes.gemspec
CHANGED
@@ -17,10 +17,13 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.version = RJL::VERSION
|
18
18
|
spec.license = 'MIT'
|
19
19
|
|
20
|
-
spec.add_development_dependency 'rake'
|
20
|
+
spec.add_development_dependency 'rake'
|
21
|
+
spec.add_development_dependency 'rspec'
|
22
|
+
spec.add_runtime_dependency 'nokogiri', '~> 1.6', '>= 1.6.7.2'
|
21
23
|
spec.add_runtime_dependency 'rjl-allmusic', '~> 0.5', '>= 0.5'
|
22
24
|
spec.add_runtime_dependency 'rb-scpt', '~> 1.0', '>= 1.0.1'
|
23
25
|
spec.add_runtime_dependency 'ruby-progressbar', '~> 1.7', '>= 1.7.5'
|
24
26
|
spec.add_runtime_dependency 'daybreak', '~> 0.3', '>= 0.3.0'
|
27
|
+
spec.add_runtime_dependency 'fuzzy-string-match', '~> 0.9', '>= 0.9.7'
|
25
28
|
|
26
29
|
end
|
data/tasks/rspec.rake
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rjl-itunes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.2'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Lyon
|
@@ -14,22 +14,50 @@ dependencies:
|
|
14
14
|
name: rake
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
18
25
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
20
31
|
- - ">="
|
21
32
|
- !ruby/object:Gem::Version
|
22
|
-
version:
|
33
|
+
version: '0'
|
23
34
|
type: :development
|
24
35
|
prerelease: false
|
25
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: nokogiri
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
26
44
|
requirements:
|
27
45
|
- - "~>"
|
28
46
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
47
|
+
version: '1.6'
|
30
48
|
- - ">="
|
31
49
|
- !ruby/object:Gem::Version
|
32
|
-
version:
|
50
|
+
version: 1.6.7.2
|
51
|
+
type: :runtime
|
52
|
+
prerelease: false
|
53
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - "~>"
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '1.6'
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 1.6.7.2
|
33
61
|
- !ruby/object:Gem::Dependency
|
34
62
|
name: rjl-allmusic
|
35
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -110,11 +138,31 @@ dependencies:
|
|
110
138
|
- - ">="
|
111
139
|
- !ruby/object:Gem::Version
|
112
140
|
version: 0.3.0
|
141
|
+
- !ruby/object:Gem::Dependency
|
142
|
+
name: fuzzy-string-match
|
143
|
+
requirement: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - "~>"
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '0.9'
|
148
|
+
- - ">="
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: 0.9.7
|
151
|
+
type: :runtime
|
152
|
+
prerelease: false
|
153
|
+
version_requirements: !ruby/object:Gem::Requirement
|
154
|
+
requirements:
|
155
|
+
- - "~>"
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0.9'
|
158
|
+
- - ">="
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: 0.9.7
|
113
161
|
description: Manage album track genre in the library using data from allmusic.com
|
114
162
|
email: richard@richardlyon.net
|
115
163
|
executables:
|
116
164
|
- console
|
117
|
-
- fix_genres
|
165
|
+
- fix_genres
|
118
166
|
- setup
|
119
167
|
extensions: []
|
120
168
|
extra_rdoc_files: []
|
@@ -128,7 +176,7 @@ files:
|
|
128
176
|
- README.md
|
129
177
|
- Rakefile
|
130
178
|
- bin/console
|
131
|
-
- bin/fix_genres
|
179
|
+
- bin/fix_genres
|
132
180
|
- bin/setup
|
133
181
|
- lib/rjl.rb
|
134
182
|
- lib/rjl/album.rb
|
@@ -144,6 +192,7 @@ files:
|
|
144
192
|
- spec/playlist.rb
|
145
193
|
- spec/spec_helper.rb
|
146
194
|
- spec/track_spec.rb
|
195
|
+
- tasks/rspec.rake
|
147
196
|
homepage: https://github.com/richardjlyon/rjl-itunes
|
148
197
|
licenses:
|
149
198
|
- MIT
|
@@ -174,4 +223,3 @@ test_files:
|
|
174
223
|
- spec/playlist.rb
|
175
224
|
- spec/spec_helper.rb
|
176
225
|
- spec/track_spec.rb
|
177
|
-
has_rdoc:
|