nehm 1.5.3 → 1.5.4
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/CHANGELOG.md +7 -0
- data/README.md +10 -4
- data/lib/nehm.rb +2 -2
- data/lib/nehm/applescript.rb +1 -1
- data/lib/nehm/configure.rb +3 -3
- data/lib/nehm/get.rb +22 -11
- data/lib/nehm/help.rb +4 -1
- data/lib/nehm/track.rb +5 -1
- data/lib/nehm/user.rb +36 -8
- data/lib/nehm/version.rb +1 -1
- data/nehm.gemspec +4 -4
- metadata +15 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9da0b37e8738ecc87f3169744ac7bad706e04814
|
4
|
+
data.tar.gz: ccc01546551cd7f5836a59cb16d1323347917470
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a2405ccecfd65c5012471cc694caae4735c92a75e923c77e95f0bf9551309a7a2d5b350d2e7caf50b4cb5015113fe7bc6b3f5924ae3fffe4fff6b3abad0c97c
|
7
|
+
data.tar.gz: 1933d9e9b7430102a13a6b01e423109190fc5559a37c88eb651fe5a321899ad1ea8307d1c7e2a7455d91905718824162fe4b8b0b1b3881f9d6dec35f82869906
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# nehm change log
|
2
2
|
|
3
|
+
## 1.5.4
|
4
|
+
* Add availability to get/dl 300+ likes and posts
|
5
|
+
* More convenient CLI
|
6
|
+
* Fix: nehm fails if you try to get/dl playlist
|
7
|
+
* Fix: nehm fails if you try to get/dl unstreamable track
|
8
|
+
* Minor optimizations and bug fixes
|
9
|
+
|
3
10
|
## 1.5.3
|
4
11
|
* Fix bugs, associated with special characters in track's name
|
5
12
|
* Minor improvements
|
data/README.md
CHANGED
@@ -4,6 +4,10 @@
|
|
4
4
|
|
5
5
|
*nehm* is a console tool, which downloads, sets IDv3 tags and adds to your iTunes library your SoundCloud posts or likes in convenient way
|
6
6
|
|
7
|
+
[](http://badge.fury.io/rb/nehm)
|
8
|
+
[](https://gemnasium.com/bogem/nehm)
|
9
|
+
[](https://codeclimate.com/github/bogem/nehm)
|
10
|
+
|
7
11
|
## Installation
|
8
12
|
|
9
13
|
**1. Install `taglib` library**
|
@@ -51,6 +55,8 @@ Enter path to desirable download directory (press enter to set it to ...
|
|
51
55
|
|
52
56
|
`nehm get post`
|
53
57
|
|
58
|
+
***(nehm doesn't get and download playlists. It just skips them)***
|
59
|
+
|
54
60
|
* Get multiple last posts or likes
|
55
61
|
|
56
62
|
`nehm get 3 posts` or `nehm get 3 likes`
|
@@ -89,16 +95,16 @@ Enter path to desirable download directory (press enter to set it to ...
|
|
89
95
|
|
90
96
|
`nehm help`
|
91
97
|
|
98
|
+
## TODO
|
99
|
+
|
100
|
+
* Getting/downloading playlists from posts
|
101
|
+
|
92
102
|
##FAQ
|
93
103
|
|
94
104
|
**Q: What is permalink?**
|
95
105
|
|
96
106
|
A: Permalink is the last word in your profile url. **Example:** for profile url ***soundcloud.com/qwerty*** permalink is ***qwerty***
|
97
107
|
|
98
|
-
## Contributing
|
99
|
-
|
100
|
-
Bug reports and pull requests are welcome.
|
101
|
-
|
102
108
|
## License
|
103
109
|
|
104
110
|
MIT License
|
data/lib/nehm.rb
CHANGED
@@ -28,10 +28,10 @@ module App
|
|
28
28
|
Get[:dl, args]
|
29
29
|
when 'configure'
|
30
30
|
Configure.menu
|
31
|
-
when 'help'
|
31
|
+
when 'help', nil
|
32
32
|
Help.show(args.first)
|
33
33
|
else
|
34
|
-
puts Paint[
|
34
|
+
puts Paint["Invalid command '#{command}'", :red]
|
35
35
|
puts "Input #{Paint['nehm help', :yellow]} for all avalaible commands"
|
36
36
|
end
|
37
37
|
|
data/lib/nehm/applescript.rb
CHANGED
@@ -15,7 +15,7 @@ module AppleScript
|
|
15
15
|
module_function
|
16
16
|
|
17
17
|
def script_path(script_name)
|
18
|
-
applescripts_path = File.expand_path(File.join(File.dirname(__FILE__),
|
18
|
+
applescripts_path = File.expand_path(File.join(File.dirname(__FILE__), 'applescripts'))
|
19
19
|
File.join(applescripts_path, "#{script_name.to_s}.applescript")
|
20
20
|
end
|
21
21
|
end
|
data/lib/nehm/configure.rb
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
module Configure
|
3
3
|
def self.menu
|
4
4
|
loop do
|
5
|
-
puts
|
6
|
-
puts
|
7
|
-
puts
|
5
|
+
puts "Download path: #{Paint[Cfg[:dl_path], :magenta]}"
|
6
|
+
puts "Permalink: #{Paint[Cfg[:permalink], :cyan]}"
|
7
|
+
puts "iTunes playlist: #{Paint[PlaylistManager.playlist, :cyan]}" unless OS.linux?
|
8
8
|
puts "\n"
|
9
9
|
|
10
10
|
HighLine.new.choose do |menu|
|
data/lib/nehm/get.rb
CHANGED
@@ -4,9 +4,9 @@ require 'taglib'
|
|
4
4
|
module Get
|
5
5
|
def self.[](get_or_dl, args)
|
6
6
|
# Processing arguments
|
7
|
-
options = [{ name: 'to',
|
8
|
-
{ name: 'from',
|
9
|
-
{ name: 'playlist',
|
7
|
+
options = [{ name: 'to', method: PathManager.method(:temp_dl_path=) },
|
8
|
+
{ name: 'from', method: UserManager.method(:temp_user=) },
|
9
|
+
{ name: 'playlist', method: PlaylistManager.method(:temp_playlist=) }]
|
10
10
|
|
11
11
|
options.each do |option|
|
12
12
|
if args.include? option[:name]
|
@@ -15,10 +15,11 @@ module Get
|
|
15
15
|
args.delete_at(index + 1)
|
16
16
|
args.delete_at(index)
|
17
17
|
|
18
|
-
option[:
|
18
|
+
option[:method].call(value)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
+
puts 'Getting information about track(s)'
|
22
23
|
user = UserManager.user
|
23
24
|
tracks = []
|
24
25
|
tracks +=
|
@@ -35,19 +36,29 @@ module Get
|
|
35
36
|
user.posts(count)
|
36
37
|
when %r{https:\/\/soundcloud.com\/}
|
37
38
|
track_from_url(args.last)
|
39
|
+
when nil
|
40
|
+
puts Paint['You must provide option', :red]
|
41
|
+
puts "Input #{Paint['nehm help', :yellow]} for help"
|
42
|
+
exit
|
38
43
|
else
|
39
|
-
puts Paint[
|
44
|
+
puts Paint["Invalid argument(s) '#{args.last}'", :red]
|
40
45
|
puts "Input #{Paint['nehm help', :yellow]} for help"
|
41
46
|
exit
|
42
47
|
end
|
43
48
|
|
44
49
|
playlist = PlaylistManager.playlist
|
45
50
|
tracks.each do |track|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
+
if track.streamable?
|
52
|
+
dl(track)
|
53
|
+
dl(track.artwork)
|
54
|
+
tag(track)
|
55
|
+
track.artwork.suicide
|
56
|
+
playlist.add_track(track.file_path) if playlist && get_or_dl == :get && !OS.linux?
|
57
|
+
else
|
58
|
+
puts "#{Paint['Track', :yellow]} #{Paint[track.name, :cyan]} #{Paint['undownloadable', :yellow]}"
|
59
|
+
puts 'Skip it'
|
60
|
+
end
|
61
|
+
puts "\n"
|
51
62
|
end
|
52
63
|
puts Paint['Done!', :green]
|
53
64
|
end
|
@@ -63,7 +74,7 @@ module Get
|
|
63
74
|
puts 'Downloading ' + arg.name
|
64
75
|
path = arg.file_path
|
65
76
|
url = arg.url
|
66
|
-
command = "curl -# -o \"
|
77
|
+
command = "curl -# -o \"#{path}\" -L #{url}"
|
67
78
|
`#{command}`
|
68
79
|
end
|
69
80
|
|
data/lib/nehm/help.rb
CHANGED
@@ -2,10 +2,13 @@
|
|
2
2
|
module Help
|
3
3
|
def self.available_commands
|
4
4
|
puts <<-HELP.gsub(/^ {6}/, '')
|
5
|
+
#{Paint['nehm', :green]} is a console tool, which downloads, sets IDv3 tags and adds to your iTunes library your SoundCloud posts or likes in convenient way
|
6
|
+
|
5
7
|
#{Paint['Avalaible nehm commands:', :yellow]}
|
6
8
|
#{Paint['get', :green]} Downloading, setting tags and adding to your iTunes library last post or like from your profile
|
7
9
|
#{Paint['dl', :green]} Downloading and setting tags last post or like from your profile
|
8
10
|
#{Paint['configure', :green]} Configuring application
|
11
|
+
|
9
12
|
See #{Paint['nehm help [command]', :yellow]} to read about a specific subcommand
|
10
13
|
HELP
|
11
14
|
end
|
@@ -17,7 +20,7 @@ module Help
|
|
17
20
|
when nil
|
18
21
|
Help.available_commands
|
19
22
|
else
|
20
|
-
puts Paint["Command #{command} doesn't exist", :red]
|
23
|
+
puts Paint["Command '#{command}' doesn't exist", :red]
|
21
24
|
puts "\n"
|
22
25
|
Help.available_commands
|
23
26
|
end
|
data/lib/nehm/track.rb
CHANGED
@@ -19,7 +19,7 @@ class Track
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def file_name
|
22
|
-
"#{name}.mp3".tr(
|
22
|
+
"#{name}.mp3".tr("/'\"", '')
|
23
23
|
end
|
24
24
|
|
25
25
|
def file_path
|
@@ -35,6 +35,10 @@ class Track
|
|
35
35
|
artist + ' - ' + title
|
36
36
|
end
|
37
37
|
|
38
|
+
def streamable?
|
39
|
+
@hash['streamable']
|
40
|
+
end
|
41
|
+
|
38
42
|
def title
|
39
43
|
if @hash['title'].include?('-')
|
40
44
|
title = @hash['title'].split('-')
|
data/lib/nehm/user.rb
CHANGED
@@ -2,6 +2,8 @@ require 'json'
|
|
2
2
|
require 'faraday'
|
3
3
|
|
4
4
|
class User
|
5
|
+
SOUNDCLOUD_MAX_LIMIT = 180
|
6
|
+
|
5
7
|
def initialize(id)
|
6
8
|
@id = id
|
7
9
|
end
|
@@ -13,10 +15,20 @@ class User
|
|
13
15
|
exit
|
14
16
|
end
|
15
17
|
|
16
|
-
|
18
|
+
d = count / SOUNDCLOUD_MAX_LIMIT
|
19
|
+
m = count % SOUNDCLOUD_MAX_LIMIT
|
20
|
+
d = m == 0 ? d : d + 1
|
21
|
+
|
22
|
+
likes = []
|
23
|
+
d.times do |i|
|
24
|
+
limit = count > SOUNDCLOUD_MAX_LIMIT ? SOUNDCLOUD_MAX_LIMIT : count
|
25
|
+
count -= SOUNDCLOUD_MAX_LIMIT
|
26
|
+
|
27
|
+
likes += Client.get("/users/#{@id}/favorites?limit=#{limit}&offset=#{(i)*SOUNDCLOUD_MAX_LIMIT}")
|
28
|
+
end
|
17
29
|
|
18
30
|
if likes.empty?
|
19
|
-
puts Paint[
|
31
|
+
puts Paint['There are no likes yet :(', :red]
|
20
32
|
exit
|
21
33
|
end
|
22
34
|
|
@@ -31,20 +43,36 @@ class User
|
|
31
43
|
exit
|
32
44
|
end
|
33
45
|
|
34
|
-
|
46
|
+
d = count / SOUNDCLOUD_MAX_LIMIT
|
47
|
+
m = count % SOUNDCLOUD_MAX_LIMIT
|
48
|
+
d = m == 0 ? d : d + 1
|
49
|
+
|
50
|
+
# Official SC API wrapper doesn't support posts
|
35
51
|
# So I should get posts by HTTP requests
|
36
|
-
#TODO: Get more than 300 posts (max limit = 300)
|
37
52
|
conn = Faraday.new(url: 'https://api-v2.soundcloud.com/')
|
38
|
-
response = conn.get("/profile/soundcloud:users:#{@id}?limit=#{count}&offset=0")
|
39
53
|
|
40
|
-
|
41
|
-
|
54
|
+
posts = []
|
55
|
+
d.times do |i|
|
56
|
+
limit = count > SOUNDCLOUD_MAX_LIMIT ? SOUNDCLOUD_MAX_LIMIT : count
|
57
|
+
count -= SOUNDCLOUD_MAX_LIMIT
|
58
|
+
|
59
|
+
response = conn.get("/profile/soundcloud:users:#{@id}?limit=#{limit}&offset=#{i*SOUNDCLOUD_MAX_LIMIT}")
|
60
|
+
parsed = JSON.parse(response.body)
|
61
|
+
collection = parsed['collection']
|
62
|
+
|
63
|
+
break if collection.nil?
|
64
|
+
|
65
|
+
posts += collection
|
66
|
+
end
|
42
67
|
|
43
68
|
if posts.empty?
|
44
|
-
puts Paint[
|
69
|
+
puts Paint['There are no posts yet :(', :red]
|
45
70
|
exit
|
46
71
|
end
|
47
72
|
|
73
|
+
rejected = posts.reject! { |hash| hash['type'] == 'playlist' }
|
74
|
+
puts Paint["Was skipped #{rejected.count} playlist(s) (nehm doesn't download playlists)", :yellow] if rejected
|
75
|
+
|
48
76
|
posts.map { |hash| Track.new(hash['track']) }
|
49
77
|
end
|
50
78
|
end
|
data/lib/nehm/version.rb
CHANGED
data/nehm.gemspec
CHANGED
@@ -20,11 +20,11 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.require_paths = ['lib']
|
21
21
|
spec.required_ruby_version = '>= 1.9.3'
|
22
22
|
|
23
|
-
spec.add_dependency '
|
24
|
-
spec.add_dependency '
|
23
|
+
spec.add_dependency 'bogy', '>= 1.1'
|
24
|
+
spec.add_dependency 'certifi'
|
25
25
|
spec.add_dependency 'faraday', '>= 0.9.1'
|
26
26
|
spec.add_dependency 'highline', '>= 1.7.2'
|
27
|
-
spec.add_dependency 'certifi'
|
28
27
|
spec.add_dependency 'paint'
|
29
|
-
spec.add_dependency '
|
28
|
+
spec.add_dependency 'soundcloud', '>= 0.3.2'
|
29
|
+
spec.add_dependency 'taglib-ruby', '>= 0.7.0'
|
30
30
|
end
|
metadata
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nehm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Albert Nigmatzianov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08
|
11
|
+
date: 2015-09-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: bogy
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: '1.1'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: '1.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: certifi
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0
|
33
|
+
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: faraday
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -67,7 +67,7 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 1.7.2
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: paint
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
@@ -81,33 +81,33 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: soundcloud
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: 0.3.2
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
96
|
+
version: 0.3.2
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: taglib-ruby
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: 0.7.0
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
110
|
+
version: 0.7.0
|
111
111
|
description: " nehm is a console tool, which downloads, sets IDv3 tags and adds to
|
112
112
|
your iTunes library your SoundCloud posts or likes in convenient way. See homepage
|
113
113
|
for instructions "
|