soundcloud_streamer 0.0.1 → 0.0.2
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/README.md +3 -3
- data/lib/soundcloud_streamer/cli.rb +19 -5
- data/lib/soundcloud_streamer/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d9f17867544bc5f60639e9e4adc21a431d09855
|
4
|
+
data.tar.gz: a14b1342c5fadc88c88adb2565e8ad438e26936e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6865ecb3a4c13fd56b4c0eb5b289ce07d0856ab10c8a4fe9b902ac166f0c2841e87bd4c8169926a600b47dc5d479f00c0189d5f7e5d554e72d8f1ab67d941736
|
7
|
+
data.tar.gz: 9d8bafdb8a589913c36cf9eb01a45d68ed2dd12b9bbeb655fe40e09842a9dd6dd70c115e76d3f3dd2f8200148cee8cd8092b7cef726641dcd09c1ad36a27caa8
|
data/README.md
CHANGED
@@ -18,13 +18,13 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
-
$
|
21
|
+
$ soundcloud_streamer help
|
22
22
|
|
23
|
-
$
|
23
|
+
$ soundcloud_streamer help playlist
|
24
24
|
|
25
25
|
### Example
|
26
26
|
|
27
|
-
$
|
27
|
+
$ soundcloud_streamer playlist https://soundcloud.com/mathew-steven-klein/sets/her-soundtrack --client-id=07b516960d652769d2a00c9a6a26f27d --target-dir="Her Soundtrack by Arcade Fire"
|
28
28
|
|
29
29
|
## Contributing
|
30
30
|
|
@@ -3,9 +3,9 @@ module SoundcloudStreamer
|
|
3
3
|
package_name "Soundcloud Streamer v#{SoundcloudStreamer::VERSION}"
|
4
4
|
|
5
5
|
desc "playlist <URL>", "streams and saves all tracks from the playlist"
|
6
|
-
method_options client_id: :string, target_dir: :string
|
6
|
+
method_options client_id: :string, target_dir: :string, overwrite: :boolean
|
7
7
|
def playlist(url)
|
8
|
-
response = playlist = client.get('/resolve', url: url)
|
8
|
+
response = playlist = client.get('/resolve', url: url, limit: 100)
|
9
9
|
|
10
10
|
if response.kind == 'playlist'
|
11
11
|
instant_print "Going to Stream all #{playlist.tracks.count} Tracks from Playlist ...\r\n"
|
@@ -14,17 +14,27 @@ module SoundcloudStreamer
|
|
14
14
|
exit(-8)
|
15
15
|
end
|
16
16
|
|
17
|
-
track_num_justr =
|
17
|
+
track_num_justr = playlist.tracks.count.to_s.length
|
18
18
|
playlist.tracks.each_with_index do |track, track_idx|
|
19
19
|
track_num = track_idx + 1
|
20
20
|
track_num_str = track_num.to_s.rjust(track_num_justr, '0')
|
21
21
|
|
22
|
-
|
23
|
-
|
22
|
+
unless track.streamable?
|
23
|
+
instant_print "Unstreamable-#{track_num}.\r\n"
|
24
|
+
next
|
25
|
+
end
|
24
26
|
|
25
27
|
download_name = File.join(target_dir, [ track_num_str, ' ', track.title, '.mp3' ].join.gsub('/',' - ') )
|
26
28
|
download_file = nil
|
27
29
|
|
30
|
+
if File.exist?(download_name) && !overwrite?
|
31
|
+
instant_print "Exisiting-#{track_num}.\r\n"
|
32
|
+
next
|
33
|
+
end
|
34
|
+
|
35
|
+
uri = URI.parse(track.stream_url)
|
36
|
+
uri.query = URI.encode_www_form(client_id: client_id)
|
37
|
+
|
28
38
|
request = Typhoeus::Request.new(uri, followlocation: true)
|
29
39
|
request.on_headers do |response|
|
30
40
|
if response.code == 200
|
@@ -126,6 +136,10 @@ module SoundcloudStreamer
|
|
126
136
|
target_dir
|
127
137
|
end
|
128
138
|
|
139
|
+
def overwrite?
|
140
|
+
options[:overwrite] || false
|
141
|
+
end
|
142
|
+
|
129
143
|
def instant_print(*params)
|
130
144
|
print(*params) { STDOUT.flush }
|
131
145
|
end
|