Skip to content

Commit

Permalink
Make work
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamie0 committed Mar 28, 2018
1 parent b1c38cf commit 477691a
Showing 1 changed file with 29 additions and 9 deletions.
38 changes: 29 additions & 9 deletions scripts/rebuild_preview.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,54 @@ class Processor < Nerve::Job::Process

def initialize; end

def at *args; end

def process_track track

# rebuild the track's preview and peaks
path = track.local_path
prev_path = $config["export"]["directory"] + "/" + path + ".ogg"
wave_path = $config["export"]["directory"] + "/" + path + ".dat"

exported_path = Object.const_get($config["export"]["mode"]).find_path(track)

# If we already have the preview, we probably
if File.exist?(prev_path) or !File.exist?(track)
if File.exist?(prev_path) or !File.exist?(exported_path)
_debug "Skipping for some reason"
return
end

exported_path = self.find_path(track)

_debug "Generating preview"
temp = []

begin

_debug "Generating preview"

temp << Tempfile.new(['nerve', '.wav'])
temp_path = temp[0].path
temp[0].close; temp[0].unlink

FileUtils::copy(exported_path, temp_path)

convert(temp_path, prev_path, "ogg", "-1")

convert(exported_path, prev_path, "ogg", "-1")
raise "Conversion failed!" unless File.exists? prev_path

raise "Conversion failed!" unless File.exists? prev_path
_debug "Generating waveform"

_debug "Generating waveform"
generate_waveform(temp_path, track.length.to_f, wave_path)

generate_waveform(prev_path, options["length"], wave_path)
raise "Generating waveform failed" unless File.exists? wave_path

raise "Generating waveform failed" unless File.exists?
_debug "Done!"

rescue

_debug "Done!"
temp.map { |t| File.unlink(t) }
raise $!

end

end

Expand Down

0 comments on commit 477691a

Please sign in to comment.