parent
cc6da7127a
commit
34b6887a79
|
|
@ -13,7 +13,7 @@ namespace :mobile do
|
||||||
end
|
end
|
||||||
|
|
||||||
unless File.exists?(tmp_fname)
|
unless File.exists?(tmp_fname)
|
||||||
puts "*** ERROR: download failed: `#{cmd}`"
|
$stderr.puts "*** ERROR: download failed: `#{cmd}`"
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -52,6 +52,8 @@ namespace :mobile do
|
||||||
artist: {},
|
artist: {},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
indices = jtx_json[:jtx_indices]
|
||||||
|
|
||||||
CSV.foreach(tmp_fname) do |row|
|
CSV.foreach(tmp_fname) do |row|
|
||||||
jtartist = row[0]
|
jtartist = row[0]
|
||||||
|
|
@ -66,12 +68,12 @@ namespace :mobile do
|
||||||
artist: jtartist,
|
artist: jtartist,
|
||||||
genre: jt.genres.map(&:description).join(', '),
|
genre: jt.genres.map(&:description).join(', '),
|
||||||
id: jt.id,
|
id: jt.id,
|
||||||
|
key: jt.id,
|
||||||
name: jtname,
|
name: jtname,
|
||||||
plan_code: jt.plan_code,
|
plan_code: jt.plan_code,
|
||||||
year: jt.year
|
year: jt.year
|
||||||
}
|
}
|
||||||
# jtx_json[:jtx_data] << jtdata
|
# jtx_json[:jtx_data] << jtdata
|
||||||
indices = jtx_json[:jtx_indices]
|
|
||||||
|
|
||||||
first_char = jtartist[0].upcase
|
first_char = jtartist[0].upcase
|
||||||
if (1..9) === first_char.to_i || '0' == first_char
|
if (1..9) === first_char.to_i || '0' == first_char
|
||||||
|
|
@ -90,6 +92,20 @@ namespace :mobile do
|
||||||
idx_artist << jtdata
|
idx_artist << jtdata
|
||||||
end
|
end
|
||||||
|
|
||||||
|
alphanum = indices[:alphanum]
|
||||||
|
songs = []
|
||||||
|
alphanum.keys.sort.each do |key|
|
||||||
|
songs << { key: key, data: alphanum[key] }
|
||||||
|
end
|
||||||
|
indices[:alphanum] = songs
|
||||||
|
|
||||||
|
artists = indices[:artist]
|
||||||
|
artists_new = []
|
||||||
|
artists.keys.sort.each do |key|
|
||||||
|
artists_new << { key: key, data: artists[key] }
|
||||||
|
end
|
||||||
|
indices[:artist] = artists_new
|
||||||
|
|
||||||
File.open("#{Rails.root}/tmp/jtx_indices.json", 'w') do |ff|
|
File.open("#{Rails.root}/tmp/jtx_indices.json", 'w') do |ff|
|
||||||
ff.write jtx_json.to_json
|
ff.write jtx_json.to_json
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue