the_little_streamer 0.1.1 → 0.2.0
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/the_little_streamer +94 -14
- metadata +12 -7
data/bin/the_little_streamer
CHANGED
@@ -47,6 +47,19 @@ def css
|
|
47
47
|
span#album {
|
48
48
|
font-style: italic;
|
49
49
|
}
|
50
|
+
|
51
|
+
div#playlist {
|
52
|
+
float: left;
|
53
|
+
margin-top: 15px;
|
54
|
+
height: 80%;
|
55
|
+
overflow: auto;
|
56
|
+
text-align: left;
|
57
|
+
}
|
58
|
+
|
59
|
+
div#playerbox {
|
60
|
+
float: left;
|
61
|
+
text-align: center;
|
62
|
+
}
|
50
63
|
CSS
|
51
64
|
end
|
52
65
|
|
@@ -69,8 +82,26 @@ def audio path
|
|
69
82
|
HTML
|
70
83
|
end
|
71
84
|
|
85
|
+
#HTML for displaying playlist
|
86
|
+
def playlist_html songs
|
87
|
+
list = []
|
88
|
+
|
89
|
+
songs.each_with_index do |song, i|
|
90
|
+
list << "<li><a href=\"javascript:play_index(#{i})\">#{song.artist} - #{song.title}</a></li>"
|
91
|
+
end
|
92
|
+
|
93
|
+
<<-HTML
|
94
|
+
<div style="clear:both"> </div>
|
95
|
+
<div id="playlist">
|
96
|
+
<ol>
|
97
|
+
#{list.join}
|
98
|
+
</ol>
|
99
|
+
</div>
|
100
|
+
HTML
|
101
|
+
end
|
102
|
+
|
72
103
|
#Javascript for playlist
|
73
|
-
def
|
104
|
+
def playlist_js songs
|
74
105
|
<<-JAVASCRIPT
|
75
106
|
<script type="text/javascript">
|
76
107
|
var player = document.getElementById('player');
|
@@ -88,6 +119,10 @@ def playlist songs
|
|
88
119
|
else
|
89
120
|
return;
|
90
121
|
|
122
|
+
play_current();
|
123
|
+
}
|
124
|
+
|
125
|
+
play_current = function() {
|
91
126
|
var song = playlist[current_song];
|
92
127
|
player.src = song.path;
|
93
128
|
artist.innerHTML = song.artist
|
@@ -95,6 +130,11 @@ def playlist songs
|
|
95
130
|
title.innerHTML = song.title
|
96
131
|
player.play();
|
97
132
|
}
|
133
|
+
|
134
|
+
play_index = function(index) {
|
135
|
+
current_song = index;
|
136
|
+
play_current();
|
137
|
+
}
|
98
138
|
</script>
|
99
139
|
JAVASCRIPT
|
100
140
|
end
|
@@ -114,6 +154,46 @@ def prev_and_next
|
|
114
154
|
"<a href='javascript:play_next(true)'>Prev</a> <a href='javascript:play_next()'>Next</a>"
|
115
155
|
end
|
116
156
|
|
157
|
+
#Output HTML for player
|
158
|
+
def player_html songs
|
159
|
+
html <<-HTML
|
160
|
+
<div id="playerbox">
|
161
|
+
#{song_info songs.first}<br/>
|
162
|
+
#{audio songs.first.path}<br/>
|
163
|
+
#{prev_and_next if songs.length > 1}
|
164
|
+
#{playlist_js songs}
|
165
|
+
#{playlist_html songs if songs.length > 1}
|
166
|
+
</div>
|
167
|
+
HTML
|
168
|
+
end
|
169
|
+
|
170
|
+
def play_all limit = 100, order = "normal"
|
171
|
+
songs = []
|
172
|
+
|
173
|
+
case order
|
174
|
+
when "random"
|
175
|
+
Music.values.each do |artist|
|
176
|
+
artist.values.each do |album|
|
177
|
+
album.values.each do |song|
|
178
|
+
songs << song
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
songs.shuffle!
|
184
|
+
else
|
185
|
+
Music.values.each do |artist|
|
186
|
+
artist.values.each do |album|
|
187
|
+
album.values.sort_by { |s| s.track }.each do |song|
|
188
|
+
songs << song
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
player_html songs[0..limit.to_i]
|
195
|
+
end
|
196
|
+
|
117
197
|
#HTML for playing all songs by artist
|
118
198
|
def play_artist artist, order = "normal"
|
119
199
|
songs = []
|
@@ -135,12 +215,7 @@ def play_artist artist, order = "normal"
|
|
135
215
|
end
|
136
216
|
end
|
137
217
|
|
138
|
-
|
139
|
-
#{song_info songs.first}<br/>
|
140
|
-
#{audio songs.first.path}<br/>
|
141
|
-
#{prev_and_next if songs.length > 1}
|
142
|
-
#{playlist songs}
|
143
|
-
HTML
|
218
|
+
player_html songs
|
144
219
|
end
|
145
220
|
|
146
221
|
#HTML for playing all songs on an album
|
@@ -153,12 +228,7 @@ def play_album artist, album, order = "normal"
|
|
153
228
|
songs = Music[artist][album].values.sort_by { |s| s.track }
|
154
229
|
end
|
155
230
|
|
156
|
-
|
157
|
-
#{song_info songs.first}<br/>
|
158
|
-
#{audio songs.first.path}<br/>
|
159
|
-
#{prev_and_next if songs.length > 1}
|
160
|
-
#{playlist songs}
|
161
|
-
HTML
|
231
|
+
player_html songs
|
162
232
|
end
|
163
233
|
|
164
234
|
#HTML for song information header
|
@@ -209,7 +279,17 @@ GC.start #Clean up after TagLib2
|
|
209
279
|
#List artists
|
210
280
|
get '/' do
|
211
281
|
path = '/artist/'
|
212
|
-
html
|
282
|
+
html <<-HTML
|
283
|
+
#{Music.keys.sort.map { |a| link path, a }.join "<br/>"}<br/><br/>
|
284
|
+
Random
|
285
|
+
#{link("/", "all", "10", :limit => 10, :order => :random)}
|
286
|
+
#{link("/", "all", "50", :limit => 50, :order => :random) }
|
287
|
+
#{link("/", "all", "100", :limit => 100, :order => :random) }
|
288
|
+
HTML
|
289
|
+
end
|
290
|
+
|
291
|
+
get '/all' do
|
292
|
+
play_all params["limit"], params["order"]
|
213
293
|
end
|
214
294
|
|
215
295
|
#List albums by given artist
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: the_little_streamer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 23
|
5
|
+
prerelease:
|
5
6
|
segments:
|
6
7
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
8
|
+
- 2
|
9
|
+
- 0
|
10
|
+
version: 0.2.0
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Justin Collins
|
@@ -14,7 +15,7 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2011-
|
18
|
+
date: 2011-08-12 00:00:00 -07:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
@@ -25,6 +26,7 @@ dependencies:
|
|
25
26
|
requirements:
|
26
27
|
- - ~>
|
27
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 15
|
28
30
|
segments:
|
29
31
|
- 1
|
30
32
|
- 0
|
@@ -39,6 +41,7 @@ dependencies:
|
|
39
41
|
requirements:
|
40
42
|
- - ~>
|
41
43
|
- !ruby/object:Gem::Version
|
44
|
+
hash: 11
|
42
45
|
segments:
|
43
46
|
- 1
|
44
47
|
- 2
|
@@ -70,6 +73,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
70
73
|
requirements:
|
71
74
|
- - ">="
|
72
75
|
- !ruby/object:Gem::Version
|
76
|
+
hash: 3
|
73
77
|
segments:
|
74
78
|
- 0
|
75
79
|
version: "0"
|
@@ -78,15 +82,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
78
82
|
requirements:
|
79
83
|
- - ">="
|
80
84
|
- !ruby/object:Gem::Version
|
85
|
+
hash: 3
|
81
86
|
segments:
|
82
87
|
- 0
|
83
88
|
version: "0"
|
84
89
|
requirements: []
|
85
90
|
|
86
91
|
rubyforge_project:
|
87
|
-
rubygems_version: 1.
|
92
|
+
rubygems_version: 1.6.2
|
88
93
|
signing_key:
|
89
94
|
specification_version: 3
|
90
|
-
summary: Sinatra application for streaming music.
|
95
|
+
summary: Simple Sinatra application for streaming music.
|
91
96
|
test_files: []
|
92
97
|
|