itunes-rm-dups 0.1.1-universal-darwin-9 → 0.2.0-universal-darwin-9
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.
- data/bin/itunes-rm-dups +23 -1
- data/lib/itunes_dup_handler.rb +34 -11
- metadata +3 -3
data/bin/itunes-rm-dups
CHANGED
@@ -1,4 +1,26 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'itunes_dup_handler'
|
4
|
-
|
4
|
+
options = {}
|
5
|
+
banner = "Usage: itunes-rm-dups [options]
|
6
|
+
|
7
|
+
iTunes Duplicate Remover is a simple interactive program that makes it easy to
|
8
|
+
remove exact duplicates from your iTunes Library. Without any options passed in,
|
9
|
+
the program looks for duplicates in the entire library. You can limit the
|
10
|
+
duplicate search by using one of the options flags."
|
11
|
+
|
12
|
+
OptionParser.new(banner, 32, ' ' * 4) do |opts|
|
13
|
+
opts.separator ""
|
14
|
+
opts.separator "Options:"
|
15
|
+
|
16
|
+
opts.on("-a", "--artist ARTIST NAME",
|
17
|
+
"Find and remove duplicate tracks only for a certain artist. Enclose in quotes if you need to use more than one word.") do |artist|
|
18
|
+
options[:artist] = artist
|
19
|
+
end
|
20
|
+
opts.on("-l", "--album ALBUM NAME",
|
21
|
+
"Find and remove duplicate tracks only for a certain album title. Enclose in quotes if you need to use more than one word.") do |artist|
|
22
|
+
options[:album] = artist
|
23
|
+
end
|
24
|
+
end.parse!
|
25
|
+
|
26
|
+
run(options)
|
data/lib/itunes_dup_handler.rb
CHANGED
@@ -16,6 +16,7 @@
|
|
16
16
|
require 'digest/md5'
|
17
17
|
require 'osx/cocoa'
|
18
18
|
require 'yaml'
|
19
|
+
require 'optparse'
|
19
20
|
require 'cgi'
|
20
21
|
include OSX
|
21
22
|
require 'fileutils'
|
@@ -153,13 +154,13 @@ def determine_duplicate( tracks )
|
|
153
154
|
return original, tracks
|
154
155
|
end
|
155
156
|
|
156
|
-
def run(
|
157
|
+
def run(options={})
|
157
158
|
# Load the iTunes instance
|
158
|
-
title = "itunes duplicate track
|
159
|
+
title = "itunes duplicate track remover"
|
159
160
|
width = 80
|
160
161
|
puts "-" * width
|
161
162
|
puts
|
162
|
-
puts
|
163
|
+
puts title.center(width)
|
163
164
|
puts
|
164
165
|
puts "by daniel choi".center(width)
|
165
166
|
puts "betahouse".center(width)
|
@@ -170,18 +171,16 @@ def run(pattern=nil, run_limit=nil)
|
|
170
171
|
puts "-" * width
|
171
172
|
|
172
173
|
puts
|
173
|
-
|
174
|
+
|
174
175
|
puts <<END
|
175
176
|
Running program. It may take several minutes to analyze all the tracks in your
|
176
177
|
iTunes library.
|
177
178
|
END
|
178
|
-
sleep 2
|
179
179
|
puts
|
180
180
|
puts <<END
|
181
181
|
To avoid any potential hangs and crashes, don't use iTunes while the program is
|
182
182
|
running.
|
183
183
|
END
|
184
|
-
sleep 2
|
185
184
|
puts
|
186
185
|
puts <<END
|
187
186
|
When this program is done analyzing your tracks, it will show you the duplicates
|
@@ -189,7 +188,7 @@ it has detected and ask for your confirmation before removing any files. So feel
|
|
189
188
|
free to go get some coffee and come back.
|
190
189
|
END
|
191
190
|
puts
|
192
|
-
|
191
|
+
|
193
192
|
puts "To make the program run faster, we can skip iTunes files that are very large."
|
194
193
|
puts "How many megabytes do you want to set as the maximum? "
|
195
194
|
print "(Default: 100mb. Type 'none' for no limit): "
|
@@ -212,14 +211,21 @@ END
|
|
212
211
|
puts "Using iTunes playlist: #{source.playlists.first.name}"
|
213
212
|
|
214
213
|
duplicate_tracks = []
|
215
|
-
|
216
|
-
|
217
|
-
fileTracks =
|
214
|
+
if options[:artist] # filter tracks by artist
|
215
|
+
category_code = 'kSrR'.unpack('H*').first.hex
|
216
|
+
fileTracks = source.libraryPlaylists[0].searchFor_only( options[:artist], category_code )
|
217
|
+
puts "Limiting analysis to tracks by artist '#{options[:artist]}'"
|
218
|
+
elsif options[:album]
|
219
|
+
category_code = 'kSrL'.unpack('H*').first.hex
|
220
|
+
fileTracks = source.libraryPlaylists[0].searchFor_only( options[:album], category_code )
|
221
|
+
puts "Limiting analysis to tracks in album '#{options[:album]}'"
|
222
|
+
else
|
223
|
+
fileTracks = source.libraryPlaylists[0].fileTracks
|
218
224
|
end
|
219
225
|
puts "Calculating MD5 digests for all tracks with files..."
|
220
226
|
sleep 2
|
221
227
|
puts
|
222
|
-
tracks_with_dups = find_duplicates( fileTracks, run_limit, mb_limit )
|
228
|
+
tracks_with_dups = find_duplicates( fileTracks, options[:run_limit], mb_limit )
|
223
229
|
puts "Finding duplicates..."
|
224
230
|
puts
|
225
231
|
sleep 2
|
@@ -297,3 +303,20 @@ def display_note
|
|
297
303
|
END
|
298
304
|
puts
|
299
305
|
end
|
306
|
+
|
307
|
+
if __FILE__ == $0
|
308
|
+
options = {}
|
309
|
+
OptionParser.new do |opts|
|
310
|
+
opts.banner = "Usage: ruby itunes_dup_handler.rb [options]"
|
311
|
+
|
312
|
+
opts.on("-a", "--artist ARTIST NAME", "Find and remove duplicate tracks only for a certain artist. Enclose in quotes if you need to use more than one word.") do |artist|
|
313
|
+
options[:artist] = artist
|
314
|
+
end
|
315
|
+
opts.on("-l", "--album ALBUM NAME", "Find and remove duplicate tracks only for a certain album title. Enclose in quotes if you need to use more than one word.") do |artist|
|
316
|
+
options[:album] = artist
|
317
|
+
end
|
318
|
+
end.parse!
|
319
|
+
|
320
|
+
run(options)
|
321
|
+
end
|
322
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: itunes-rm-dups
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: universal-darwin-9
|
6
6
|
authors:
|
7
7
|
- Daniel Choi
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-05-
|
12
|
+
date: 2008-05-22 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -25,7 +25,7 @@ files:
|
|
25
25
|
- lib/itunes_dup_handler.rb
|
26
26
|
- README
|
27
27
|
has_rdoc: true
|
28
|
-
homepage: http://
|
28
|
+
homepage: http://danielchoi.com/software/itunes-rm-dups.html
|
29
29
|
post_install_message:
|
30
30
|
rdoc_options: []
|
31
31
|
|