soundcloud_downloader 0.0.9 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/soundcloud-downloader +24 -2
- data/lib/soundcloud_downloader/song.rb +7 -3
- data/lib/soundcloud_downloader/version.rb +1 -1
- data/soundcloud_downloader.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 583a92d287b6ab514855671337e83b7bf5b1961b
|
4
|
+
data.tar.gz: acca92e3fdf28abeb911e30519d5a4cb4eb3d438
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 04f243309166576e7af0057eecb4e9bda372e2707ed9ac93cf9a4e207b196f4fcaac5521719a7737e8bc63e8f720909b00de18203ffe7f6ecf8dafe32c701f93
|
7
|
+
data.tar.gz: 2bc3b860d01555ac5f2f34a45a5d43db6cc44426f8e639e68dbe723c5b7d8310c13337c5ba00b819d830a94c9569a03eb1c2b2a396578c4cc9e86d9f45a418d9
|
data/bin/soundcloud-downloader
CHANGED
@@ -1,6 +1,28 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'soundcloud_downloader'
|
4
|
+
require 'optparse'
|
4
5
|
|
5
|
-
|
6
|
-
|
6
|
+
options = {}
|
7
|
+
OptionParser.new do |opts|
|
8
|
+
opts.banner = "Usage: soundcloud-downloader <URL> [OPTIONS]"
|
9
|
+
|
10
|
+
opts.on("-o", "--out [filename]",
|
11
|
+
"Filename for the MP3, optional") do |t|
|
12
|
+
options[:filename] = t
|
13
|
+
end
|
14
|
+
opts.on("-f", "--folder [folder]",
|
15
|
+
"Folder to save the MP3 to, optional") do |t|
|
16
|
+
options[:folder] = t
|
17
|
+
end
|
18
|
+
opts.on_tail("-v", "--version", "Show version") do
|
19
|
+
puts "Version: #{SoundcloudDownloader::VERSION}"
|
20
|
+
exit
|
21
|
+
end
|
22
|
+
|
23
|
+
end.parse!
|
24
|
+
|
25
|
+
url = ARGV[0]
|
26
|
+
|
27
|
+
song = Song.new(url)
|
28
|
+
song.download(options[:filename], options[:folder])
|
@@ -12,16 +12,20 @@ class Song
|
|
12
12
|
@stream_url ||= get_stream_url
|
13
13
|
end
|
14
14
|
|
15
|
-
def download (file = "#{@name}.mp3")
|
15
|
+
def download (file = "#{@name}.mp3", folder = "./")
|
16
|
+
raise ArgumentError, "Invalid folder" if not File.directory?(folder)
|
17
|
+
raise ArgumentError, "Cannot write to this folder" if not File.writable?(folder)
|
18
|
+
raise ArgumentError, "File must have .mp3 extension" if File.extname(file) != ".mp3"
|
16
19
|
streamer = lambda do |chunk, remaining_bytes, total_bytes|
|
17
20
|
file.write(chunk)
|
18
21
|
remaining = ((remaining_bytes.to_f / total_bytes) * 100).to_i
|
19
22
|
STDOUT.flush
|
20
23
|
print "\rRemaining: #{remaining}%"
|
21
24
|
end
|
22
|
-
|
25
|
+
path = File.join(folder,File.basename(file))
|
26
|
+
file = open(path, 'wb')
|
23
27
|
Excon.get(@stream_url, :response_block => streamer)
|
24
|
-
puts "\r\
|
28
|
+
puts "\r\nSaved to #{File.realpath(path)}!"
|
25
29
|
file.close
|
26
30
|
end
|
27
31
|
|
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
11
11
|
spec.summary = %q{SoundCloud downloader}
|
12
12
|
spec.description = %q{Downloads songs from SoundCloud to your
|
13
13
|
computer as MP3 files}
|
14
|
-
spec.homepage = "https://gitlab.com/
|
14
|
+
spec.homepage = "https://gitlab.com/mixu/soundcloud-downloader"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
17
17
|
spec.files = `git ls-files -z`.split("\x0")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: soundcloud_downloader
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mico Piira
|
@@ -84,7 +84,7 @@ files:
|
|
84
84
|
- lib/soundcloud_downloader/song.rb
|
85
85
|
- lib/soundcloud_downloader/version.rb
|
86
86
|
- soundcloud_downloader.gemspec
|
87
|
-
homepage: https://gitlab.com/
|
87
|
+
homepage: https://gitlab.com/mixu/soundcloud-downloader
|
88
88
|
licenses:
|
89
89
|
- MIT
|
90
90
|
metadata: {}
|