jxl-muq 0.0.1 → 0.0.2
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/muq +9 -2
- data/lib/muq.rb +23 -11
- data/muq.gemspec +1 -1
- metadata +2 -2
data/bin/muq
CHANGED
@@ -105,8 +105,15 @@ Main do
|
|
105
105
|
total = get.size
|
106
106
|
count = 1
|
107
107
|
get.each do |song|
|
108
|
-
puts "[#{count}/#{total}] #{song[:
|
109
|
-
|
108
|
+
puts "[#{count}/#{total}] #{song[:artist]} - #{song[:title]}"
|
109
|
+
file = "#{@dir}/#{user}/#{song[:file]}"
|
110
|
+
m.download(song[:url], file)
|
111
|
+
m.retag(file,
|
112
|
+
{ :artist => song[:artist],
|
113
|
+
:title => song[:title],
|
114
|
+
:album => user,
|
115
|
+
:track=> count }
|
116
|
+
)
|
110
117
|
count += 1
|
111
118
|
end
|
112
119
|
end
|
data/lib/muq.rb
CHANGED
@@ -92,18 +92,22 @@ class Muq
|
|
92
92
|
def songs(user)
|
93
93
|
doc = Hpricot(get("#{user}.#{@host}"))
|
94
94
|
scripts = doc.search("//script[@type='text/javascript']").inner_text
|
95
|
-
kettle = scripts.match(/new Kettle\((
|
96
|
-
|
97
|
-
|
98
|
-
|
95
|
+
kettle = scripts.match(/new Kettle\(\[(.+?)\],\[(.+?)\]\)/)
|
96
|
+
hex, sig = [kettle[1], kettle[2]].map do |a|
|
97
|
+
a.gsub("'",'').split(",")
|
98
|
+
end
|
99
99
|
out = []
|
100
100
|
if hex.size == sig.size
|
101
101
|
total = hex.size
|
102
102
|
total.times do |i|
|
103
|
-
|
103
|
+
track = doc.search("//li[@id='song#{hex[i]}']/div[@class='name']").inner_text.strip
|
104
|
+
if track =~ /(.+)\s-\s(.+)/
|
105
|
+
artist, title = [$1, $2]
|
106
|
+
end
|
104
107
|
url = "http://muxtape.s3.amazonaws.com/songs/"
|
105
108
|
url += "#{hex[i]}?PLEASE=DO_NOT_STEAL_MUSIC&#{sig[i]}" # rly sry lulz
|
106
|
-
out << {:
|
109
|
+
out << { :artist => artist, :title => title,
|
110
|
+
:file => filename("#{artist} - #{title}", i+1), :url => url }
|
107
111
|
end
|
108
112
|
end
|
109
113
|
out
|
@@ -171,6 +175,17 @@ class Muq
|
|
171
175
|
"#{rnd_string(6, true, "a", "f")}"
|
172
176
|
end
|
173
177
|
|
178
|
+
def retag(file, tags)
|
179
|
+
tag = ID3Lib::Tag.new(file)
|
180
|
+
tag.delete_if {true}
|
181
|
+
tag.artist = tags[:artist] if tags[:artist]
|
182
|
+
tag.title = tags[:title] if tags[:title]
|
183
|
+
tag.album = tags[:album] if tags[:album]
|
184
|
+
tag.track = tags[:track] if tags[:track]
|
185
|
+
#tag.part_of_set = tags[:total] if tags[:total]
|
186
|
+
tag.update!(ID3Lib::V_ALL)
|
187
|
+
end
|
188
|
+
|
174
189
|
private
|
175
190
|
# http get
|
176
191
|
def get(url)
|
@@ -242,12 +257,9 @@ class Muq
|
|
242
257
|
# funky filename
|
243
258
|
def filename(name, nr)
|
244
259
|
file = name.downcase
|
245
|
-
file = file.gsub(" - ", "-")
|
246
|
-
file = file.gsub("/", "")
|
247
|
-
file = file.gsub(".", "")
|
248
|
-
file = file.gsub(",", "")
|
249
|
-
file = file.gsub(" ", " ")
|
250
260
|
file = file.gsub(" ", "_")
|
261
|
+
file = file.gsub("_-_", "-")
|
262
|
+
file = file.gsub(/[^a-zA-Z0-9\-\(\)\[\]_]/, "")
|
251
263
|
file = "#{"%02.0f" % nr}-#{file}-muq.mp3"
|
252
264
|
end
|
253
265
|
|
data/muq.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jxl-muq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ron Damen
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-04-
|
12
|
+
date: 2008-04-28 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|