soundcloud_downloader 0.0.7
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 +7 -0
- data/.gitignore +23 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +24 -0
- data/Rakefile +2 -0
- data/bin/soundcloud_downloader +6 -0
- data/lib/soundcloud_downloader.rb +9 -0
- data/lib/soundcloud_downloader/song.rb +51 -0
- data/lib/soundcloud_downloader/version.rb +3 -0
- data/soundcloud_downloader.gemspec +25 -0
- metadata +97 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: dfb8409f92f89cbac0b64e44c99daa11d1b8d9c4
|
4
|
+
data.tar.gz: 8c5eddfb8bdbe343ee2dc9f8b81b8b4c32fcc8d4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f486e3463b0f02ca24ff396c16a7bdeed05347fa1aaeee85c137df73dd6bc77e69942c1690ad47cf29fd3103eb2690527e701c45e72632a2038de9be020335e7
|
7
|
+
data.tar.gz: e122123f636cc9f26297076fdfa905d9a94e1c72654408d8d9589fe75facd17171d17814eecdbb8c047859329ee4f84445278b920f86ebece9d2088dec7daa4f
|
data/.gitignore
ADDED
@@ -0,0 +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
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +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.
|
data/README.md
ADDED
@@ -0,0 +1,24 @@
|
|
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
|
+
Stand alone:
|
12
|
+
|
13
|
+
$ soundcloud_downloader URL
|
14
|
+
|
15
|
+
In your own Ruby applications:
|
16
|
+
|
17
|
+
require 'soundcloud_downloader'
|
18
|
+
|
19
|
+
song = Song.new("https://soundcloud.com/example/example-song-name")
|
20
|
+
song.id # => 123456
|
21
|
+
song.stream_url # => https://soundcloud.hs.llnwd.net/Example.128.mp3?AWSAccessKeyId=Example&Expires=Example&Signature=Example%3D&e=Example&h=Example
|
22
|
+
song.name # => example-song-name
|
23
|
+
song.url # => https://soundcloud.com/example/example-song-name
|
24
|
+
song.download # This will download the song as mp3
|
data/Rakefile
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
require "unirest"
|
2
|
+
|
3
|
+
class Song
|
4
|
+
attr_reader :id, :stream_url, :name, :url
|
5
|
+
def initialize(url)
|
6
|
+
@url = url
|
7
|
+
@name = url.split("/").last
|
8
|
+
@id ||= get_id
|
9
|
+
@stream_url ||= get_stream_url
|
10
|
+
end
|
11
|
+
|
12
|
+
def download (file = "#{@name}.mp3")
|
13
|
+
uri = URI(@stream_url)
|
14
|
+
Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
|
15
|
+
begin
|
16
|
+
file = open("#{file}", 'wb')
|
17
|
+
http.request_get uri.request_uri do |response|
|
18
|
+
downloaded = 0
|
19
|
+
total_length = response['Content-Length'].to_f
|
20
|
+
response.read_body do |segment|
|
21
|
+
downloaded += (segment.length).to_f
|
22
|
+
print "\rDownloaded " + (((downloaded/total_length)*100).to_i).to_s + "%"
|
23
|
+
STDOUT.flush
|
24
|
+
file.write(segment)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
ensure
|
28
|
+
file.close
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def get_stream_url
|
36
|
+
response = Unirest.get "https://api.sndcdn.com/i1/tracks/#{@id}/streams", headers: {}, parameters: { :client_id => $client_id }
|
37
|
+
response.body["http_mp3_128_url"]
|
38
|
+
end
|
39
|
+
|
40
|
+
def get_id
|
41
|
+
response = Unirest.get "https://api.sndcdn.com/resolve?_status_code_map%5B302%5D=200",
|
42
|
+
headers: { "Accept" => "application/json" },
|
43
|
+
parameters: {
|
44
|
+
:url => @url,
|
45
|
+
:_status_format => 'json',
|
46
|
+
:client_id => $client_id
|
47
|
+
}
|
48
|
+
uri = URI.parse(response.body["location"]).path.to_s
|
49
|
+
uri.split('/').last
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,25 @@
|
|
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/u/mixu"
|
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 "unirest", '~> 1.1'
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: soundcloud_downloader
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.7
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mico Piira
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-07-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: unirest
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.6'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.6'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: "Downloads songs from SoundCloud to your \ncomputer as MP3 files"
|
56
|
+
email:
|
57
|
+
- mico.piira@yahoo.com
|
58
|
+
executables:
|
59
|
+
- soundcloud_downloader
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE.txt
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- bin/soundcloud_downloader
|
69
|
+
- lib/soundcloud_downloader.rb
|
70
|
+
- lib/soundcloud_downloader/song.rb
|
71
|
+
- lib/soundcloud_downloader/version.rb
|
72
|
+
- soundcloud_downloader.gemspec
|
73
|
+
homepage: https://gitlab.com/u/mixu
|
74
|
+
licenses:
|
75
|
+
- MIT
|
76
|
+
metadata: {}
|
77
|
+
post_install_message:
|
78
|
+
rdoc_options: []
|
79
|
+
require_paths:
|
80
|
+
- lib
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
requirements: []
|
92
|
+
rubyforge_project:
|
93
|
+
rubygems_version: 2.2.2
|
94
|
+
signing_key:
|
95
|
+
specification_version: 4
|
96
|
+
summary: SoundCloud downloader
|
97
|
+
test_files: []
|