Created
April 8, 2014 18:53
-
-
Save arashm/10170783 to your computer and use it in GitHub Desktop.
Simple script to downoad MP3 files from SoundCloud via WGet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'uri' | |
require 'httparty' | |
# Download mp3 files from SoundCloud | |
# Usage: | |
# ./soundcloud.rb https://soundcloud.com/tara-tiba/paeez_tara-tiba | |
class SoundCloud | |
include HTTParty | |
base_uri 'https://soundcloud.com' | |
def initialize(args = {}) | |
@uri = URI(args.fetch(:url)) | |
@link = '' | |
end | |
def get_name | |
@uri.path.split('/').last | |
end | |
def get_link_url | |
content = fetch_page | |
match = content.match /https?:\/\/media.soundcloud.com\/stream\/[^\"]*/ | |
@link = match[0] | |
end | |
def download | |
get_link_url | |
system("wget #{@link} -O #{get_name}.mp3") | |
end | |
private | |
def fetch_page | |
self.class.get @uri.path | |
end | |
end | |
sc = SoundCloud.new(url: ARGV[0]) | |
sc.download |
Nikolip; you need to install that gem.
./downmp3
./downmp3:23: unknown regexp options - artt
./downmp3:23: syntax error, unexpected $undefined, expecting keyword_end
...arshani-peiris-mp3-songs-3.php/stream/[^\"]*/
... ^
./downmp3:29: syntax error, unexpected tIDENTIFIER, expecting keyword_end
system("wget #{@link} -O #{get_name}.mp3")
^
hello i have no idea about scripting please help to resolved this
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
54:in
'require': cannot load such file -- httparty (LoadError) from /usr/local/Cellar/ruby/2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in
require'from ./soundcloud.rb:3:in `