ipod_db 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- data/TODO +0 -1
- data/bin/ipod +34 -15
- data/lib/ipod_db/version.rb +1 -1
- metadata +1 -1
data/TODO
CHANGED
data/bin/ipod
CHANGED
@@ -11,7 +11,23 @@ Main {
|
|
11
11
|
author 'artm <femistofel@gmail.com>'
|
12
12
|
|
13
13
|
name 'ipod_db'
|
14
|
-
config
|
14
|
+
config(
|
15
|
+
ipod_root: "/media/#{ENV['USER']}/IPOD",
|
16
|
+
group_together: [
|
17
|
+
# Just an example
|
18
|
+
[ "60-Second", "Science Talk", "This Week in Science" ],
|
19
|
+
[ "StarShipSofa", "Tales To Terrify" ],
|
20
|
+
])
|
21
|
+
option('books','b') {
|
22
|
+
argument_required
|
23
|
+
default 'books'
|
24
|
+
description 'subdirectory of ipod with bookmarkable media'
|
25
|
+
}
|
26
|
+
option('songs','s') {
|
27
|
+
argument_required
|
28
|
+
default 'songs'
|
29
|
+
description 'subdirectory of ipod with non-bookmarkable media'
|
30
|
+
}
|
15
31
|
option('version','v') {
|
16
32
|
description 'show package version and exit'
|
17
33
|
}
|
@@ -52,16 +68,6 @@ Main {
|
|
52
68
|
database on the device and it's ready for consumption.
|
53
69
|
__
|
54
70
|
|
55
|
-
option('books','b') {
|
56
|
-
argument_required
|
57
|
-
default 'books'
|
58
|
-
description 'subdirectory of ipod with bookmarkable media'
|
59
|
-
}
|
60
|
-
option('songs','s') {
|
61
|
-
argument_required
|
62
|
-
default 'songs'
|
63
|
-
description 'subdirectory of ipod with non-bookmarkable media'
|
64
|
-
}
|
65
71
|
def run
|
66
72
|
load_ipod_db
|
67
73
|
sync
|
@@ -100,7 +106,7 @@ Main {
|
|
100
106
|
books_path = params['books'].value
|
101
107
|
songs_path = params['songs'].value
|
102
108
|
books = collect_tracks books_path
|
103
|
-
books =
|
109
|
+
books = spread(books)
|
104
110
|
songs = collect_tracks songs_path
|
105
111
|
@ipod_db.update books: books, songs: songs
|
106
112
|
@ipod_db.save
|
@@ -221,11 +227,22 @@ Main {
|
|
221
227
|
tracks
|
222
228
|
end
|
223
229
|
|
224
|
-
def
|
225
|
-
bins = paths.group_by
|
226
|
-
|
230
|
+
def spread paths, group_lambda = lambda {|path| track_group(path)}
|
231
|
+
bins = paths.group_by &group_lambda
|
232
|
+
bins.each do |key, bin|
|
233
|
+
bins[key] = spread(bins[key], lambda{|path| File.dirname(path)}) if key.is_a? Integer
|
234
|
+
end
|
235
|
+
Spread.spread *bins.values
|
227
236
|
end
|
228
237
|
|
238
|
+
def track_group track
|
239
|
+
config['group_together'].each_with_index do |patterns,group|
|
240
|
+
patterns.each do |pattern|
|
241
|
+
return group if track.downcase.index pattern.downcase
|
242
|
+
end
|
243
|
+
end
|
244
|
+
File.dirname(track)
|
245
|
+
end
|
229
246
|
}
|
230
247
|
|
231
248
|
BEGIN {
|
@@ -237,6 +254,8 @@ BEGIN {
|
|
237
254
|
require 'taglib'
|
238
255
|
require 'ruby-progressbar'
|
239
256
|
require 'highline/import'
|
257
|
+
require 'fileutils'
|
258
|
+
require 'pp'
|
240
259
|
|
241
260
|
# our own
|
242
261
|
require 'ipod_db'
|
data/lib/ipod_db/version.rb
CHANGED