itch 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README.txt +106 -5
  2. data/lib/itch.rb +49 -43
  3. data/test/test_itch.rb +9 -1
  4. metadata +2 -2
data/README.txt CHANGED
@@ -5,7 +5,93 @@ itch - Control Helper for ITunes - Perform operations on iTunes tracks.
5
5
 
6
6
  == Usage
7
7
 
8
- itch [--help] [--library] [--current-playlist] [--playlist name] [--all-playlists] [--create-playlist [name]] [--delete-playlist [name]] [--current-track] [--selected-tracks] [--all-tracks] [--find string] [--visible-find string] [--find-artist string] [--find-album string] [--find-composer string] [--find-track-name string] [--print-info format] [--play-found] [--set-artist string] [--set-album string] [--set-bpm number] [--set-comment string] [--set-composer string] [--set-disc-count number] [--set-disc-number number] [--set-enabled] [--set-disabled] [--set-eq string] [--set-genre string] [--set-grouping string] [--set-name string] [--set-play-count number] [--set-rating number] [--set-skip-count number] [--set-track-count number] [--set-track-number number] [--set-volume-adjustment string] [--set-year number] [--volume number] [--volume-down [number]] [--volume-up [number]] [--mute] [--unmute] [--scan-to number] [--scan-backwards [number]] [--scan-forwards [number]] [--next-track] [--pause] [--play] [--play-file name] [--play-pause] [--previous-track] [--stop] [--add-file name] [--open-url url] [--goto-store-home-page] [--update-ipod] [--quit]
8
+ Program help:
9
+ -h, --help Display program help.
10
+ Playback controls:
11
+ -p, --play-pause If currently paused, begin playing. If currently playing, pause playback.
12
+ --pause Pause playback.
13
+ --play Play the current track.
14
+ -s, --stop Stop playback.
15
+ -n, --next-track Go to the next track.
16
+ -N, --previous-track Go to the previous track.
17
+ -m, --mute Mute the audio.
18
+ -M, --unmute Unmute the audio.
19
+ -v, --volume number Set the volume to X percentage points.
20
+ --volume-down [number] Decrease the volume by X percentage points (default 10).
21
+ --volume-up [number] Increase the volume by X percentage points (default 10).
22
+ --scan-to seconds Scan to an offset X seconds within the current track.
23
+ --scan-backwards [seconds] Scan backwards X seconds within the current track (default 10).
24
+ --scan-forwards [seconds] Scan forwards X seconds within the current track (default 10).
25
+ --play-file name Play the specified file or folder.
26
+ Info on selected tracks:
27
+ -i, --print-info format For each track, print information in the given format. If the following strings appear in the given format, they will be replaced with the corresponding track information:
28
+ "%a": artist
29
+ "%e": encoding
30
+ "%A": album
31
+ "%b": BPM (beats per minute)
32
+ "%c": composer
33
+ "%C": comment
34
+ "%d": disc number
35
+ "%D": disc count
36
+ "%E": Enabled status ("enabled" or "disabled")
37
+ "%l": location (file name/URL)
38
+ "%p": play count
39
+ "%q": equalizer
40
+ "%g": genre
41
+ "%G": grouping
42
+ "%n": name (title)
43
+ "%r": rating
44
+ "%s": skip count
45
+ "%t": track number
46
+ "%T": track count
47
+ "%v": volume adjustment
48
+ "%y": year
49
+ "%%": percent sign
50
+ General iTunes controls:
51
+ -a, --add-file name Add the specified file or folder to the library.
52
+ -q, --quit Exit iTunes.
53
+ --open-url url Open the given URL.
54
+ --goto-store-home-page Go to the Store.
55
+ --update-ipod Update the iPod.
56
+ Playlist selection:
57
+ --library Operation will include the entire iTunes library. Used by default unless other libraries are selected.
58
+ --current-playlist Operation will include the current playlist.
59
+ --playlist name Operation will include the named playlist. (This option can occur more than once.)
60
+ --all-playlists Operation will include all playlists.
61
+ --create-playlist name Create a playlist with the specified name and include it in the operation. (This option can occur more than once.)
62
+ --delete-playlist name Delete the playlist with the specified name. (This option can occur more than once.)
63
+ Track selection:
64
+ -f, --find string Operation will include all tracks in the specified playlist(s) where any field matches the specified string. (This option can occur more than once.)
65
+ -c, --current-track Operation will inclue the current track.
66
+ --selected-tracks Operation will include the selected tracks.
67
+ --all-tracks Operation will include all tracks in the specified playlist(s).
68
+ --visible-find string Operation will include all tracks in the specified playlist(s) where any visible field matches the specified string. (This option can occur more than once.)
69
+ --find-artist string Operation will include all tracks in the specified playlist(s) where the artist matches the specified string. (This option can occur more than once.)
70
+ --find-album string Operation will include all tracks in the specified playlist(s) where the album matches the specified string. (This option can occur more than once.)
71
+ --find-composer string Operation will include all tracks in the specified playlist(s) where the composer matches the specified string. (This option can occur more than once.)
72
+ --find-track-name string Operation will include all tracks in the specified playlist(s) where the track name matches the specified string. (This option can occur more than once.)
73
+ -F, --play-found Play the first of the selected tracks.
74
+ Set track info:
75
+ --set-artist name Set the artist for each track.
76
+ --set-album name Set the album for each track.
77
+ --set-bpm number Set the beats per minute for each track.
78
+ --set-comment string Set the comment for each track.
79
+ --set-composer string Set the composer for each track.
80
+ --set-disc-number number For each track, set the disc number. (Used with multi-disc albums.)
81
+ --set-disc-count number For each track, set the number of discs in the album. (Used with multi-disc albums.)
82
+ --set-enabled Enable the check box for each track.
83
+ --set-disabled Disable the check box for each track.
84
+ --set-eq name Set the equalizer to the named preset. Use 'None' to disable.
85
+ --set-genre name Set the genre for each track.
86
+ --set-grouping string Set the grouping for each track.
87
+ --set-name name Set the name (title) for each track.
88
+ --set-play-count number Set the play count for each track.
89
+ --set-rating number Set the rating for each track. Valid values are 0 through 5.
90
+ --set-skip-count number Set the skip count for each track.
91
+ --set-track-number number For each track, set its album track number.
92
+ --set-track-count number For each track, set the number of tracks on its album.
93
+ --set-track-volume percent Set the volume adjustment percentage for each track, from -100 to 100. Negative numbers decrease the volume, positive numbers increase it. 0 means no adjustment.
94
+ --set-year number Set the year of publication for each track.
9
95
 
10
96
 
11
97
  == Description
@@ -20,21 +106,32 @@ You can also add tracks to the library, sync your iPod, and perform a variety of
20
106
 
21
107
  Get help:
22
108
 
23
- itch --help
109
+ itch -h
24
110
 
25
- Start up iTunes [if necessary] and begin playing:
111
+ Start up iTunes (if necessary) and begin playing:
26
112
 
27
- itch --play
113
+ itch -p
28
114
 
29
115
  Find and play a song:
30
116
 
31
- itch --find "mookid" --play-found
117
+ itch -f "mookid" -F
32
118
 
33
119
  Find all songs from an artist, show basic info on them, and play the first found:
34
120
 
121
+ itch -f "aphex twin" -i "%a - %A - %t - %n" -F
122
+
123
+ You can improve readability in batch files by specifying options in long form:
124
+
35
125
  itch --find "aphex twin" --print-info "%a - %A - %t - %n" --play-found
36
126
 
37
127
 
128
+ == Installation
129
+
130
+ * Windows (without Ruby): Visit the project site (see below), download and run the Windows installer.
131
+
132
+ * With Ruby: {{{gem install itch}}}
133
+
134
+
38
135
  == Building from Source
39
136
 
40
137
  The setup should be fairly standard for anyone familiar with Rake. There are a few external dependencies; see below for links.
@@ -59,6 +156,10 @@ iTunes: http://www.apple.com/itunes/
59
156
 
60
157
  Thanks to Eden Li and Gary Wright for various Ruby advice and assistance.
61
158
 
159
+ NullSoft Scriptable Install System is used to make the Windows installer; thanks to its authors.
160
+
161
+ RubyScript2Exe is used to make the Windows executable; thanks to Erik Veenstra for pulling off this seemingly impossible feat!
162
+
62
163
 
63
164
  == Author
64
165
 
data/lib/itch.rb CHANGED
@@ -33,26 +33,29 @@ class Itch
33
33
 
34
34
  #Define valid options with descriptions.
35
35
  options = OptionParser.new
36
- options.on("--help", TrueClass, "Display program help.") {
37
- puts options.to_s
36
+ options.separator("Program help:")
37
+ options.on("-h", "--help", TrueClass, "Display program help.") {
38
+ puts options.help
38
39
  exit
39
40
  }
40
- options.on("--library", TrueClass, "Operation will include the entire iTunes library. Used by default unless other libraries are selected.") {|value| config['library'] = value}
41
- options.on("--current-playlist", TrueClass, "Operation will include the current playlist.") {|value| config['current-playlist'] = value}
42
- options.on("--playlist name", Object, "Operation will include the named playlist. (This option can occur more than once.)") {|value| (config['playlist'] ||= []) << value}
43
- options.on("--all-playlists", TrueClass, "Operation will include all playlists.") {|value| config['all-playlists'] = value}
44
- options.on("--create-playlist name", Object, "Create a playlist with the specified name and include it in the operation. (This option can occur more than once.)") {|value| (config['create-playlist'] ||= []) << value}
45
- options.on("--delete-playlist name", Object, "Delete the playlist with the specified name. (This option can occur more than once.)") {|value| (config['delete-playlist'] ||= []) << value}
46
- options.on("--current-track", TrueClass, "Operation will inclue the current track.") {|value| config['current-track'] = value}
47
- options.on("--selected-tracks", TrueClass, "Operation will include the selected tracks.") {|value| config['selected-tracks'] = value}
48
- options.on("--all-tracks", TrueClass, "Operation will include all tracks in the specified playlist(s).") {|value| config['all-tracks'] = value}
49
- options.on("--find string", Object, "Operation will include all tracks in the specified playlist(s) where any field matches the specified string. (This option can occur more than once.)") {|value| (config['find'] ||= []) << value}
50
- options.on("--visible-find string", Object, "Operation will include all tracks in the specified playlist(s) where any visible field matches the specified string. (This option can occur more than once.)") {|value| (config['visible-find'] ||= []) << value}
51
- options.on("--find-artist string", Object, "Operation will include all tracks in the specified playlist(s) where the artist matches the specified string. (This option can occur more than once.)") {|value| (config['find-artist'] ||= []) << value}
52
- options.on("--find-album string", Object, "Operation will include all tracks in the specified playlist(s) where the album matches the specified string. (This option can occur more than once.)") {|value| (config['find-album'] ||= []) << value}
53
- options.on("--find-composer string", Object, "Operation will include all tracks in the specified playlist(s) where the composer matches the specified string. (This option can occur more than once.)") {|value| (config['find-composer'] ||= []) << value}
54
- options.on("--find-track-name string", Object, "Operation will include all tracks in the specified playlist(s) where the track name matches the specified string. (This option can occur more than once.)") {|value| (config['find-track-name'] ||= []) << value}
55
- options.on("--print-info format", Object, "For each track, print information in the given format. If the following strings appear in the given format, they will be replaced with the corresponding track information:",
41
+ options.separator("Playback controls:")
42
+ options.on("-p", "--play-pause", TrueClass, "If currently paused, begin playing. If currently playing, pause playback.") {|value| config['play-pause'] = value}
43
+ options.on("--pause", TrueClass, "Pause playback.") {|value| config['pause'] = value}
44
+ options.on("--play", TrueClass, "Play the current track.") {|value| config['play'] = value}
45
+ options.on("-s", "--stop", TrueClass, "Stop playback.") {|value| config['stop'] = value}
46
+ options.on("-n", "--next-track", TrueClass, "Go to the next track.") {|value| config['next-track'] = value}
47
+ options.on("-N", "--previous-track", TrueClass, "Go to the previous track.") {|value| config['previous-track'] = value}
48
+ options.on("-m", "--mute", TrueClass, "Mute the audio.") {|value| config['mute'] = value}
49
+ options.on("-M", "--unmute", TrueClass, "Unmute the audio.") {|value| config['unmute'] = value}
50
+ options.on("-v", "--volume number", Integer, "Set the volume to X percentage points.") {|value| config['volume'] = value}
51
+ options.on("--volume-down [number]", Integer, "Decrease the volume by X percentage points (default 10).") {|value| config['volume-down'] = value || 10}
52
+ options.on("--volume-up [number]", Integer, "Increase the volume by X percentage points (default 10).") {|value| config['volume-up'] = value || 10}
53
+ options.on("--scan-to seconds", Integer, "Scan to an offset X seconds within the current track.") {|value| config['scan-to'] = value}
54
+ options.on("--scan-backwards [seconds]", Integer, "Scan backwards X seconds within the current track (default 10).") {|value| config['scan-backwards'] = value || 10}
55
+ options.on("--scan-forwards [seconds]", Integer, "Scan forwards X seconds within the current track (default 10).") {|value| config['scan-forwards'] = value || 10}
56
+ options.on("--play-file name", Object, "Play the specified file or folder.") {|value| config['play-file'] = value}
57
+ options.separator("Info on selected tracks:")
58
+ options.on("-i", "--print-info format", Object, "For each track, print information in the given format. If the following strings appear in the given format, they will be replaced with the corresponding track information:",
56
59
  %q#"%a": artist#,
57
60
  %q#"%e": encoding#,
58
61
  %q#"%A": album#,
@@ -76,7 +79,31 @@ class Itch
76
79
  %q#"%y": year#,
77
80
  %q#"%%": percent sign#
78
81
  ) {|value| config['print-info'] = value}
79
- options.on("--play-found", TrueClass, "Play the first of the selected tracks.") {|value| config['play-found'] = value}
82
+ options.separator("General iTunes controls:")
83
+ options.on("-a", "--add-file name", Object, "Add the specified file or folder to the library.") {|value| (config['add-file'] ||= []) << value}
84
+ options.on("-q", "--quit", TrueClass, "Exit iTunes.") {|value| config['quit'] = value}
85
+ options.on("--open-url url", Object, "Open the given URL.") {|value| config['open-url'] = value}
86
+ options.on("--goto-store-home-page", TrueClass, "Go to the Store.") {|value| config['goto-store-home-page'] = value}
87
+ options.on("--update-ipod", TrueClass, "Update the iPod.") {|value| config['update-ipod'] = value}
88
+ options.separator("Playlist selection:")
89
+ options.on("--library", TrueClass, "Operation will include the entire iTunes library. Used by default unless other libraries are selected.") {|value| config['library'] = value}
90
+ options.on("--current-playlist", TrueClass, "Operation will include the current playlist.") {|value| config['current-playlist'] = value}
91
+ options.on("--playlist name", Object, "Operation will include the named playlist. (This option can occur more than once.)") {|value| (config['playlist'] ||= []) << value}
92
+ options.on("--all-playlists", TrueClass, "Operation will include all playlists.") {|value| config['all-playlists'] = value}
93
+ options.on("--create-playlist name", Object, "Create a playlist with the specified name and include it in the operation. (This option can occur more than once.)") {|value| (config['create-playlist'] ||= []) << value}
94
+ options.on("--delete-playlist name", Object, "Delete the playlist with the specified name. (This option can occur more than once.)") {|value| (config['delete-playlist'] ||= []) << value}
95
+ options.separator("Track selection:")
96
+ options.on("-f", "--find string", Object, "Operation will include all tracks in the specified playlist(s) where any field matches the specified string. (This option can occur more than once.)") {|value| (config['find'] ||= []) << value}
97
+ options.on("-c", "--current-track", TrueClass, "Operation will inclue the current track.") {|value| config['current-track'] = value}
98
+ options.on("--selected-tracks", TrueClass, "Operation will include the selected tracks.") {|value| config['selected-tracks'] = value}
99
+ options.on("--all-tracks", TrueClass, "Operation will include all tracks in the specified playlist(s).") {|value| config['all-tracks'] = value}
100
+ options.on("--visible-find string", Object, "Operation will include all tracks in the specified playlist(s) where any visible field matches the specified string. (This option can occur more than once.)") {|value| (config['visible-find'] ||= []) << value}
101
+ options.on("--find-artist string", Object, "Operation will include all tracks in the specified playlist(s) where the artist matches the specified string. (This option can occur more than once.)") {|value| (config['find-artist'] ||= []) << value}
102
+ options.on("--find-album string", Object, "Operation will include all tracks in the specified playlist(s) where the album matches the specified string. (This option can occur more than once.)") {|value| (config['find-album'] ||= []) << value}
103
+ options.on("--find-composer string", Object, "Operation will include all tracks in the specified playlist(s) where the composer matches the specified string. (This option can occur more than once.)") {|value| (config['find-composer'] ||= []) << value}
104
+ options.on("--find-track-name string", Object, "Operation will include all tracks in the specified playlist(s) where the track name matches the specified string. (This option can occur more than once.)") {|value| (config['find-track-name'] ||= []) << value}
105
+ options.on("-F", "--play-found", TrueClass, "Play the first of the selected tracks.") {|value| config['play-found'] = value}
106
+ options.separator("Set track info:")
80
107
  options.on("--set-artist name", Object, "Set the artist for each track.") {|value| config['set-artist'] = value}
81
108
  options.on("--set-album name", Object, "Set the album for each track.") {|value| config['set-album'] = value}
82
109
  options.on("--set-bpm number", Integer, "Set the beats per minute for each track.") {|value| config['set-bpm'] = value}
@@ -95,28 +122,8 @@ class Itch
95
122
  options.on("--set-skip-count number", Integer, "Set the skip count for each track.") {|value| config['set-skip-count'] = value}
96
123
  options.on("--set-track-number number", Integer, "For each track, set its album track number.") {|value| config['set-track-number'] = value}
97
124
  options.on("--set-track-count number", Integer, "For each track, set the number of tracks on its album.") {|value| config['set-track-count'] = value}
98
- options.on("--set-volume-adjustment percent", Integer, "Set the volume adjustment percentage for each track, from -100 to 100. Negative numbers decrease the volume, positive numbers increase it. 0 means no adjustment.") {|value| config['set-volume-adjustment'] = value}
125
+ options.on("--set-track-volume percent", Integer, "Set the volume adjustment percentage for each track, from -100 to 100. Negative numbers decrease the volume, positive numbers increase it. 0 means no adjustment.") {|value| config['set-track-volume'] = value}
99
126
  options.on("--set-year number", Integer, "Set the year of publication for each track.") {|value| config['set-year'] = value}
100
- options.on("--volume number", Integer, "Set the volume to X percentage points.") {|value| config['volume'] = value}
101
- options.on("--volume-down [number]", Integer, "Decrease the volume by X percentage points (default 10).") {|value| config['volume-down'] = value || 10}
102
- options.on("--volume-up [number]", Integer, "Increase the volume by X percentage points (default 10).") {|value| config['volume-up'] = value || 10}
103
- options.on("--mute", TrueClass, "Mute the audio.") {|value| config['mute'] = value}
104
- options.on("--unmute", TrueClass, "Unmute the audio.") {|value| config['unmute'] = value}
105
- options.on("--scan-to seconds", Integer, "Scan to an offset X seconds within the current track.") {|value| config['scan-to'] = value}
106
- options.on("--scan-backwards [seconds]", Integer, "Scan backwards X seconds within the current track (default 10).") {|value| config['scan-backwards'] = value || 10}
107
- options.on("--scan-forwards [seconds]", Integer, "Scan forwards X seconds within the current track (default 10).") {|value| config['scan-forwards'] = value || 10}
108
- options.on("--next-track", TrueClass, "Go to the next track.") {|value| config['next-track'] = value}
109
- options.on("--pause", TrueClass, "Pause playback.") {|value| config['pause'] = value}
110
- options.on("--play", TrueClass, "Play the current track.") {|value| config['play'] = value}
111
- options.on("--play-file name", Object, "Play the specified file or folder.") {|value| config['play-file'] = value}
112
- options.on("--play-pause", TrueClass, "If currently paused, begin playing. If currently playing, pause playback.") {|value| config['play-pause'] = value}
113
- options.on("--previous-track", TrueClass, "Go to the previous track.") {|value| config['previous-track'] = value}
114
- options.on("--stop", TrueClass, "Stop playback.") {|value| config['stop'] = value}
115
- options.on("--add-file name", Object, "Add the specified file or folder to the library.") {|value| (config['add-file'] ||= []) << value}
116
- options.on("--open-url url", Object, "Open the given URL.") {|value| config['open-url'] = value}
117
- options.on("--goto-store-home-page", TrueClass, "Go to the Store.") {|value| config['goto-store-home-page'] = value}
118
- options.on("--update-ipod", TrueClass, "Update the iPod.") {|value| config['update-ipod'] = value}
119
- options.on("--quit", TrueClass, "Exit iTunes.") {|value| config['quit'] = value}
120
127
 
121
128
  #Parse the options, printing usage if parsing fails.
122
129
  options.parse(arguments) rescue puts "#{$!}\nType '#{$0} --help' for valid options."
@@ -281,7 +288,7 @@ class Itch
281
288
  specified?(config, 'set-skip-count') {|v| track.SkippedCount = v}
282
289
  specified?(config, 'set-track-count') {|v| track.TrackCount = v}
283
290
  specified?(config, 'set-track-number') {|v| track.TrackNumber = v}
284
- specified?(config, 'set-volume-adjustment') {|v| track.VolumeAdjustment = v}
291
+ specified?(config, 'set-track-volume') {|v| track.VolumeAdjustment = v}
285
292
  specified?(config, 'set-year') {|v| track.Year = v}
286
293
  specified?(config, 'print-info') {|v| puts track_info(track, v)}
287
294
  specified?(config, 'set-artist') {|v| track.Artist = v}
@@ -364,6 +371,5 @@ class Itch
364
371
  def specified? (config, key)
365
372
  yield config[key] if config.has_key?(key)
366
373
  end
367
-
368
-
374
+
369
375
  end
data/test/test_itch.rb CHANGED
@@ -81,6 +81,14 @@ class TestItch < Test::Unit::TestCase
81
81
  assert(config['find'].include?('baz'))
82
82
  assert(config['find'].include?('eep'))
83
83
 
84
+ #Test short options.
85
+ config = @helper.parse_options [
86
+ '-p',
87
+ '-v', '100',
88
+ ]
89
+ assert_not_nil(config['play-pause'])
90
+ assert_equal(100, config['volume'])
91
+
84
92
  end
85
93
 
86
94
 
@@ -220,7 +228,7 @@ class TestItch < Test::Unit::TestCase
220
228
  test('set-skip-count', track, 'SkippedCount=')
221
229
  test('set-track-count', track, 'TrackCount=')
222
230
  test('set-track-number', track, 'TrackNumber=')
223
- test('set-volume-adjustment', track, 'VolumeAdjustment=')
231
+ test('set-track-volume', track, 'VolumeAdjustment=')
224
232
  test('set-year', track, 'Year=')
225
233
  #Test specialized attribute setting.
226
234
  @helper.perform_track_operations({'set-enabled' => true}, [track])
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: itch
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.0.2
7
- date: 2007-04-26 00:00:00 -07:00
6
+ version: 1.0.3
7
+ date: 2007-05-07 00:00:00 -07:00
8
8
  summary: Allows control of iTunes for Windows via a command line.
9
9
  require_paths:
10
10
  - lib