-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathupload.rb
More file actions
20 lines (17 loc) · 727 Bytes
/
upload.rb
File metadata and controls
20 lines (17 loc) · 727 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
require('soundcloud')
client = Soundcloud.new(:client_id => ENV['SOUNDCLOUD_CLIENT_ID'],
:client_secret => ENV['SOUNDCLOUD_CLIENT_SECRET'],
:username => ENV['SOUNDCLOUD_USERNAME'],
:password => ENV['SOUNDCLOUD_PASSWORD'])
if client.get('/me/tracks').map{ |x| x.title }.include? ARGV[0]
puts "Track is already on this SoundCloud profile"
else
puts "Message recieved, attempting upload"
# upload an audio file
track = client.post('/tracks', :track => {
:title => ARGV[0],
:asset_data => File.new("data/#{ARGV[0]}", 'rb')
})
# print track link
puts track.permalink_url
end