soundcloud_downloader 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +23 -23
- data/Gemfile +4 -4
- data/LICENSE.txt +22 -22
- data/README.md +26 -24
- data/Rakefile +2 -2
- data/bin/soundcloud-downloader +27 -28
- data/lib/soundcloud_downloader/song.rb +27 -17
- data/lib/soundcloud_downloader/version.rb +3 -3
- data/lib/soundcloud_downloader.rb +9 -9
- data/soundcloud_downloader.gemspec +27 -26
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e463e0ae3702a0b02f3917b106c64354e42920f2
|
4
|
+
data.tar.gz: d65c7c79d922960c05a42b74a40f78ea5934f5f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e11d7757806c0018243f916b7f54e95429d1649c6f85ef53dd780bd08ac6d11a313234bd99046cb679297026e83554ad6b3bcbb7e923a89c7790fd5042cf9f8
|
7
|
+
data.tar.gz: b4f00c07ec43794ec3f03b3f7b5f1d206e68d4dc2034750af0d10b5d5e10a41e69f74ac5f79c0d5921afe3a23309cdfc1d61395be64412542ed5d6aeb2753a31
|
data/.gitignore
CHANGED
@@ -1,23 +1,23 @@
|
|
1
|
-
*.gem
|
2
|
-
*.rbc
|
3
|
-
.bundle
|
4
|
-
.config
|
5
|
-
.yardoc
|
6
|
-
Gemfile.lock
|
7
|
-
InstalledFiles
|
8
|
-
_yardoc
|
9
|
-
coverage
|
10
|
-
doc/
|
11
|
-
lib/bundler/man
|
12
|
-
pkg
|
13
|
-
rdoc
|
14
|
-
spec/reports
|
15
|
-
test/tmp
|
16
|
-
test/version_tmp
|
17
|
-
tmp
|
18
|
-
*.bundle
|
19
|
-
*.so
|
20
|
-
*.o
|
21
|
-
*.a
|
22
|
-
mkmf.log
|
23
|
-
*.mp3
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
23
|
+
*.mp3
|
data/Gemfile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
# Specify your gem's dependencies in scdownloader.gemspec
|
4
|
-
gemspec
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in scdownloader.gemspec
|
4
|
+
gemspec
|
data/LICENSE.txt
CHANGED
@@ -1,22 +1,22 @@
|
|
1
|
-
Copyright (c) 2014 TODO: Write your name
|
2
|
-
|
3
|
-
MIT License
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
-
a copy of this software and associated documentation files (the
|
7
|
-
"Software"), to deal in the Software without restriction, including
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
11
|
-
the following conditions:
|
12
|
-
|
13
|
-
The above copyright notice and this permission notice shall be
|
14
|
-
included in all copies or substantial portions of the Software.
|
15
|
-
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
1
|
+
Copyright (c) 2014 TODO: Write your name
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,24 +1,26 @@
|
|
1
|
-
# SoundcloudDownloader
|
2
|
-
|
3
|
-
SoundcloudDownloader is a tool used to download songs from SoundCloud to your computer as MP3.
|
4
|
-
|
5
|
-
## Installation
|
6
|
-
|
7
|
-
$ gem install soundcloud_downloader
|
8
|
-
|
9
|
-
## Usage
|
10
|
-
|
11
|
-
CLI:
|
12
|
-
|
13
|
-
$
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
song
|
22
|
-
song.
|
23
|
-
song.
|
24
|
-
song.
|
1
|
+
# SoundcloudDownloader
|
2
|
+
|
3
|
+
SoundcloudDownloader is a tool used to download songs from SoundCloud to your computer as MP3.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
$ gem install soundcloud_downloader
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
CLI:
|
12
|
+
|
13
|
+
$ soundcloud-downloader <URL> [OPTIONS]
|
14
|
+
-O, --output-file [filename] Filename for the MP3, optional (Default: parse from URL)
|
15
|
+
-v, --version Show version
|
16
|
+
|
17
|
+
In your own Ruby applications:
|
18
|
+
|
19
|
+
require 'soundcloud_downloader'
|
20
|
+
|
21
|
+
song = Song.new("https://soundcloud.com/example/example-song-name")
|
22
|
+
song.id # => 123456
|
23
|
+
song.stream_url # => https://soundcloud.hs.llnwd.net/Example.128.mp3?AWSAccessKeyId=Example&Expires=Example&Signature=Example%3D&e=Example&h=Example
|
24
|
+
song.name # => example-song-name
|
25
|
+
song.url # => https://soundcloud.com/example/example-song-name
|
26
|
+
song.download(file, folder) # This will download the song as mp3 (File and folder arguments are optional)
|
data/Rakefile
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
require "bundler/gem_tasks"
|
2
|
-
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
|
data/bin/soundcloud-downloader
CHANGED
@@ -1,28 +1,27 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'soundcloud_downloader'
|
4
|
-
require 'optparse'
|
5
|
-
|
6
|
-
options = {}
|
7
|
-
OptionParser.new do |opts|
|
8
|
-
opts.banner = "Usage: soundcloud-downloader <URL> [OPTIONS]"
|
9
|
-
|
10
|
-
opts.on("-
|
11
|
-
"Filename for the MP3, optional") do |t|
|
12
|
-
options[:filename] = t
|
13
|
-
end
|
14
|
-
opts.
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
song
|
28
|
-
song.download(options[:filename], options[:folder])
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'soundcloud_downloader'
|
4
|
+
require 'optparse'
|
5
|
+
|
6
|
+
options = {}
|
7
|
+
OptionParser.new do |opts|
|
8
|
+
opts.banner = "Usage: soundcloud-downloader <URL> [OPTIONS]"
|
9
|
+
|
10
|
+
opts.on("-O", "--output-file [filename]",
|
11
|
+
"Filename for the MP3, optional (Default: parse from URL)") do |t|
|
12
|
+
options[:filename] = t
|
13
|
+
end
|
14
|
+
opts.on_tail("-v", "--version", "Show version") do
|
15
|
+
puts "Version: #{SoundcloudDownloader::VERSION}"
|
16
|
+
exit
|
17
|
+
end
|
18
|
+
|
19
|
+
end.parse!
|
20
|
+
|
21
|
+
url = ARGV[0]
|
22
|
+
|
23
|
+
song = Song.new(url)
|
24
|
+
dl_options = []
|
25
|
+
dl_options << options[:filename] unless options[:filename].nil?
|
26
|
+
dl_options << options[:folder] unless options[:folder].nil?
|
27
|
+
song.send('download', *dl_options)
|
@@ -1,51 +1,61 @@
|
|
1
1
|
require "excon"
|
2
2
|
require "json"
|
3
3
|
require "uri"
|
4
|
+
require "mp3info"
|
4
5
|
|
5
6
|
class Song
|
6
|
-
attr_reader :
|
7
|
+
attr_reader :metadata, :name, :url, :resolved_url
|
8
|
+
|
7
9
|
def initialize(url)
|
8
10
|
raise ArgumentError, "Invalid url" if url !~ URI::regexp
|
9
11
|
@url = url
|
10
12
|
@name = url.split("/").last
|
11
|
-
@
|
13
|
+
@resolved_url ||= resolve_url
|
14
|
+
@metadata ||= get_metadata
|
12
15
|
@stream_url ||= get_stream_url
|
13
16
|
end
|
14
17
|
|
15
|
-
def download (
|
16
|
-
|
17
|
-
|
18
|
-
raise ArgumentError, "File must have .mp3 extension" if File.extname(file) != ".mp3"
|
18
|
+
def download (filename = "#{@metadata['title']}.mp3")
|
19
|
+
file = File.open(filename, 'wb')
|
20
|
+
|
19
21
|
streamer = lambda do |chunk, remaining_bytes, total_bytes|
|
20
22
|
file.write(chunk)
|
21
23
|
remaining = ((remaining_bytes.to_f / total_bytes) * 100).to_i
|
22
24
|
STDOUT.flush
|
23
25
|
print "\rRemaining: #{remaining}%"
|
24
26
|
end
|
25
|
-
|
26
|
-
file = open(path, 'wb')
|
27
|
+
|
27
28
|
Excon.get(@stream_url, :response_block => streamer)
|
28
|
-
puts "\r\nSaved to #{File.realpath(path)}!"
|
29
29
|
file.close
|
30
|
+
puts "\r\nSaved to #{File.realpath(filename)}!"
|
31
|
+
Mp3Info.open(File.realpath(filename)) do |mp3|
|
32
|
+
mp3.tag.title = @metadata["title"]
|
33
|
+
end
|
34
|
+
|
30
35
|
end
|
31
36
|
|
32
37
|
private
|
33
38
|
|
34
39
|
def get_stream_url
|
35
|
-
response = Excon.get("https://api.sndcdn.com/i1/tracks/#{@id}/streams", :query => { :client_id => $client_id })
|
40
|
+
response = Excon.get("https://api.sndcdn.com/i1/tracks/#{@metadata['id']}/streams", :query => { :client_id => $client_id })
|
36
41
|
JSON.parse(response.body)["http_mp3_128_url"]
|
37
42
|
end
|
38
43
|
|
39
|
-
def
|
40
|
-
response = Excon.get("
|
41
|
-
:headers => { "Accept" => "application/json" },
|
44
|
+
def resolve_url
|
45
|
+
response = Excon.get("http://api.soundcloud.com/resolve.json",
|
42
46
|
:query => {
|
43
47
|
:url => @url,
|
44
|
-
:_status_format => 'json',
|
45
48
|
:client_id => $client_id
|
46
49
|
})
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
+
JSON.parse(response.body)["location"]
|
51
|
+
end
|
52
|
+
|
53
|
+
def get_metadata
|
54
|
+
response = Excon.get(@resolved_url,
|
55
|
+
:query => {
|
56
|
+
:client_id => $client_id
|
57
|
+
})
|
58
|
+
JSON.parse(response.body)
|
50
59
|
end
|
60
|
+
|
51
61
|
end
|
@@ -1,3 +1,3 @@
|
|
1
|
-
module SoundcloudDownloader
|
2
|
-
VERSION = "0.1.
|
3
|
-
end
|
1
|
+
module SoundcloudDownloader
|
2
|
+
VERSION = "0.1.1"
|
3
|
+
end
|
@@ -1,9 +1,9 @@
|
|
1
|
-
require "soundcloud_downloader/version"
|
2
|
-
require "soundcloud_downloader/song"
|
3
|
-
|
4
|
-
$client_id = "2de556d4242efcdb9efb51480a1e59e9"
|
5
|
-
|
6
|
-
module SoundcloudDownloader
|
7
|
-
|
8
|
-
end
|
9
|
-
|
1
|
+
require "soundcloud_downloader/version"
|
2
|
+
require "soundcloud_downloader/song"
|
3
|
+
|
4
|
+
$client_id = "2de556d4242efcdb9efb51480a1e59e9"
|
5
|
+
|
6
|
+
module SoundcloudDownloader
|
7
|
+
|
8
|
+
end
|
9
|
+
|
@@ -1,26 +1,27 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'soundcloud_downloader/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = "soundcloud_downloader"
|
8
|
-
spec.version = SoundcloudDownloader::VERSION
|
9
|
-
spec.authors = ["Mico Piira"]
|
10
|
-
spec.email = ["mico.piira@yahoo.com"]
|
11
|
-
spec.summary = %q{SoundCloud downloader}
|
12
|
-
spec.description = %q{Downloads songs from SoundCloud to your
|
13
|
-
computer as MP3 files}
|
14
|
-
spec.homepage = "https://gitlab.com/mixu/soundcloud-downloader"
|
15
|
-
spec.license = "MIT"
|
16
|
-
|
17
|
-
spec.files = `git ls-files -z`.split("\x0")
|
18
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
|
-
spec.require_paths = ["lib"]
|
21
|
-
|
22
|
-
spec.add_runtime_dependency 'excon', '~> 0.38.0'
|
23
|
-
spec.add_runtime_dependency 'json', '~> 1.8.1'
|
24
|
-
spec.
|
25
|
-
spec.add_development_dependency "
|
26
|
-
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'soundcloud_downloader/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "soundcloud_downloader"
|
8
|
+
spec.version = SoundcloudDownloader::VERSION
|
9
|
+
spec.authors = ["Mico Piira"]
|
10
|
+
spec.email = ["mico.piira@yahoo.com"]
|
11
|
+
spec.summary = %q{SoundCloud downloader}
|
12
|
+
spec.description = %q{Downloads songs from SoundCloud to your
|
13
|
+
computer as MP3 files}
|
14
|
+
spec.homepage = "https://gitlab.com/mixu/soundcloud-downloader"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0")
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_runtime_dependency 'excon', '~> 0.38.0'
|
23
|
+
spec.add_runtime_dependency 'json', '~> 1.8.1'
|
24
|
+
spec.add_runtime_dependency 'ruby-mp3info', '~> 0.8.4'
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
26
|
+
spec.add_development_dependency "rake"
|
27
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: soundcloud_downloader
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mico Piira
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: excon
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 1.8.1
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: ruby-mp3info
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.8.4
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.8.4
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: bundler
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -104,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
118
|
version: '0'
|
105
119
|
requirements: []
|
106
120
|
rubyforge_project:
|
107
|
-
rubygems_version: 2.
|
121
|
+
rubygems_version: 2.4.1
|
108
122
|
signing_key:
|
109
123
|
specification_version: 4
|
110
124
|
summary: SoundCloud downloader
|