ampt 0.2.0 → 0.2.1
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/README.rdoc +1 -1
- data/ampt.gemspec +1 -1
- data/lib/ampt.rb +1 -1
- data/lib/ampt_api/acoustics.rb +12 -0
- data/lib/ampt_cfg/default.rb +55 -30
- metadata +1 -1
data/README.rdoc
CHANGED
data/ampt.gemspec
CHANGED
data/lib/ampt.rb
CHANGED
data/lib/ampt_api/acoustics.rb
CHANGED
@@ -80,6 +80,18 @@ module Ampt
|
|
80
80
|
song_list req 'random', 'amount' => amt || '20'
|
81
81
|
end
|
82
82
|
|
83
|
+
# Brings song to the top.
|
84
|
+
def vote_to_top id
|
85
|
+
auth
|
86
|
+
player_status req 'vote_to_top', 'song_id' => id
|
87
|
+
end
|
88
|
+
|
89
|
+
# Shuffles your votes. Great for bogosort.
|
90
|
+
def shuffle_votes
|
91
|
+
auth
|
92
|
+
player_status req 'shuffle_votes'
|
93
|
+
end
|
94
|
+
|
83
95
|
# Performs a request with given mode and params.
|
84
96
|
def req mode=nil, params = nil
|
85
97
|
c = Curl::Easy.new
|
data/lib/ampt_cfg/default.rb
CHANGED
@@ -91,6 +91,26 @@ def pp_time len
|
|
91
91
|
str << format(":%02d", len % 60)
|
92
92
|
end
|
93
93
|
|
94
|
+
def select_interactively l
|
95
|
+
s = []
|
96
|
+
Tempfile.open("ampt") do |tempfile|
|
97
|
+
songs_to_file(l, tempfile)
|
98
|
+
tempfile.fsync
|
99
|
+
tempfile.flush
|
100
|
+
path = tempfile.path
|
101
|
+
tempfile.close
|
102
|
+
system(ENV['EDITOR'], path)
|
103
|
+
File.open(path) do |f|
|
104
|
+
s = f.readlines
|
105
|
+
end
|
106
|
+
end
|
107
|
+
s.inject([]) do |a,line|
|
108
|
+
a + ((line.scan(/\s(\d+)\s/)[0] unless(line =~ /^\#/)) || [])
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
alias_cmd 'help' => '--help'
|
113
|
+
|
94
114
|
alias_cmd 'st' => 'status'
|
95
115
|
default 'status'
|
96
116
|
|
@@ -147,21 +167,9 @@ command 'remove' do
|
|
147
167
|
l = st.playlist.select do |s|
|
148
168
|
s.who.include? me
|
149
169
|
end
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
tempfile.fsync
|
154
|
-
tempfile.flush
|
155
|
-
path = tempfile.path
|
156
|
-
tempfile.close
|
157
|
-
system(ENV['EDITOR'], path)
|
158
|
-
File.open(path) do |f|
|
159
|
-
s = f.readlines
|
160
|
-
end
|
161
|
-
end
|
162
|
-
arr = s.inject([]) do |a,line|
|
163
|
-
a + ((line.scan(/\s(\d+)\s/)[0] unless(line =~ /^\#/)) || [])
|
164
|
-
end
|
170
|
+
|
171
|
+
arr = select_interactively(l)
|
172
|
+
|
165
173
|
unless arr.empty?
|
166
174
|
arr.each_slice(40) do |a|
|
167
175
|
unvote a
|
@@ -175,6 +183,7 @@ end
|
|
175
183
|
|
176
184
|
alias_cmd 'up' => 'add'
|
177
185
|
alias_cmd 'upvote' => 'add'
|
186
|
+
alias_cmd 'vote' => 'add'
|
178
187
|
command 'add' do
|
179
188
|
desc "Vote for a song. Provide a song id, or one of the flags."
|
180
189
|
arg 'song_id'
|
@@ -209,21 +218,8 @@ command 'add' do
|
|
209
218
|
end
|
210
219
|
end
|
211
220
|
l = l.flatten
|
212
|
-
|
213
|
-
|
214
|
-
songs_to_file(l, tempfile)
|
215
|
-
tempfile.fsync
|
216
|
-
tempfile.flush
|
217
|
-
path = tempfile.path
|
218
|
-
tempfile.close
|
219
|
-
system(ENV['EDITOR'], path)
|
220
|
-
File.open(path) do |f|
|
221
|
-
s = f.readlines
|
222
|
-
end
|
223
|
-
end
|
224
|
-
arr = s.inject([]) do |a,line|
|
225
|
-
a + ((line.scan(/\s(\d+)\s/)[0] unless(line =~ /^\#/)) || [])
|
226
|
-
end
|
221
|
+
|
222
|
+
arr = select_interactively(l)
|
227
223
|
|
228
224
|
unless arr.empty?
|
229
225
|
if randomize
|
@@ -400,3 +396,32 @@ command 'history' do
|
|
400
396
|
pp_songs_full history(args[0]), :show_all_voters => true
|
401
397
|
end
|
402
398
|
end
|
399
|
+
|
400
|
+
command 'shuffle' do
|
401
|
+
desc 'Shuffle your votes.'
|
402
|
+
on_run do |opts,args|
|
403
|
+
shuffle_votes
|
404
|
+
end
|
405
|
+
end
|
406
|
+
|
407
|
+
alias_cmd 'top' => 'votetotop'
|
408
|
+
command 'votetotop' do
|
409
|
+
desc 'Bring the song to the top of your list of voted songs'
|
410
|
+
opt :interactive, "Select interactively.", :short => '-i'
|
411
|
+
arg 'song_id'
|
412
|
+
on_run do |opts,args|
|
413
|
+
if opts[:interactive]
|
414
|
+
st = status
|
415
|
+
me = st.who
|
416
|
+
mine = st.playlist.select do |s|
|
417
|
+
s.who.include? me
|
418
|
+
end
|
419
|
+
arr = select_interactively mine
|
420
|
+
unless arr.empty?
|
421
|
+
vote_to_top arr
|
422
|
+
end
|
423
|
+
else
|
424
|
+
vote_to_top args
|
425
|
+
end
|
426
|
+
end
|
427
|
+
end
|