module Play
  # API endpoints to support broader, systems-level functions.
  class App < Sinatra::Base

    get "/images/art/:id.png" do
      content_type 'image/png'

      if art = Song.find(params[:id]).album_art_data
        response['Cache-Control'] = 'public, max-age=2500000'
        etag params[:id]
        art
      else
        dir = File.dirname(File.expand_path(__FILE__))
        send_file "#{dir}/../frontend/public/images/art-placeholder.png",
          :disposition => 'inline'
      end
    end

    get "/stream_url" do
      Play.config.stream_url
    end

    post '/upload' do
      params[:files].each do |file|
        tmpfile = file[:tempfile]
        name    = file[:filename]

        sane_path = File.join(File.dirname(tmpfile), name)
        system "mv", tmpfile.path, sane_path
        system "./script/add-to-itunes", sane_path
      end

      true
    end

  end
end

module Play
  # API endpoints to support broader, systems-level functions.
  class App < Sinatra::Base

    get "/images/art/:id.png" do
      content_type 'image/png'

      if art = Song.find(params[:id]).album_art_data
        response['Cache-Control'] = 'public, max-age=2500000'
        etag params[:id]
        art
      else
        dir = File.dirname(File.expand_path(__FILE__))
        send_file "#{dir}/../frontend/public/images/art-placeholder.png",
          :disposition => 'inline'
      end
    end

    get "/stream_url" do
      Play.config.stream_url
    end

    post '/upload' do
      params[:files].each do |file|
        tmpfile = file[:tempfile]
        name    = file[:filename]

        # iTunes needs a filetype it likes, so fuck it, .mp3 it.
        system "mv", tmpfile.path, tmpfile.path + '.mp3'
        system "./script/add-to-itunes", tmpfile.path + '.mp3'
      end

      true
    end

  end
end

Revert "Update uploader to support more extensions"
Revert "Update uploader to support more extensions"

This reverts commit caaf29a10ee5310c5d7824978c318515d8e67a46.

This also just doesn't work.
