nehm 1.6.1 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/README.md +52 -35
- data/Rakefile +63 -13
- data/bin/nehm +0 -1
- data/lib/nehm.rb +33 -11
- data/lib/nehm/cfg.rb +19 -6
- data/lib/nehm/client.rb +30 -33
- data/lib/nehm/command.rb +19 -34
- data/lib/nehm/command_manager.rb +8 -18
- data/lib/nehm/commands/configure_command.rb +17 -14
- data/lib/nehm/commands/dl_command.rb +13 -11
- data/lib/nehm/commands/get_command.rb +36 -12
- data/lib/nehm/commands/help_command.rb +5 -5
- data/lib/nehm/commands/search_command.rb +41 -0
- data/lib/nehm/commands/select_command.rb +56 -0
- data/lib/nehm/http_client.rb +66 -0
- data/lib/nehm/menu.rb +96 -0
- data/lib/nehm/option_parser.rb +0 -2
- data/lib/nehm/os.rb +2 -2
- data/lib/nehm/path_manager.rb +5 -24
- data/lib/nehm/playlist.rb +2 -2
- data/lib/nehm/playlist_manager.rb +3 -5
- data/lib/nehm/track.rb +4 -2
- data/lib/nehm/track_manager.rb +135 -0
- data/lib/nehm/tracks_view_command.rb +123 -0
- data/lib/nehm/ui.rb +18 -2
- data/lib/nehm/user_manager.rb +5 -4
- data/lib/nehm/version.rb +1 -1
- data/nehm.gemspec +4 -7
- metadata +13 -64
- data/lib/nehm/tracks.rb +0 -153
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 642f53e571f554b780f52a641af8fdfe81f0a05c
|
4
|
+
data.tar.gz: d7eef194b669c2915a4ee53ddf7e8049b3e46058
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d5926b9ad5deabd35d73a8caff482596e37a2083ad048dc203fc6171c8758e0b3cb769f6a838e919938598cd25f650d97606df580de9764f590600ef232f870e
|
7
|
+
data.tar.gz: 8097e9ef27791c75a04fa6841c1fea3d537426fda0551808702aba9fcc0376e4d2791e67aa0cd095462c38c554aef350188147038c99165ca6ddaf46063edfd7
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# nehm change log
|
2
2
|
|
3
|
+
## 2.0.1
|
4
|
+
* Make gem size smaller
|
5
|
+
|
6
|
+
## 2.0
|
7
|
+
* Add 'select' and 'search' commands *(more info in README and `nehm help`)*
|
8
|
+
* Many performance improvements *(changes in application structure)*
|
9
|
+
* More stable *(Many bug fixes and error handling)*
|
10
|
+
* Less dependencies *(Remove 4 dependencies)*
|
11
|
+
* Prettier README
|
12
|
+
|
3
13
|
## 1.6.1
|
4
14
|
* Fix nehm's fails when download tracks from url
|
5
15
|
|
data/README.md
CHANGED
@@ -1,17 +1,35 @@
|
|
1
|
-
|
1
|
+
<div align="center">
|
2
|
+
<img src="https://raw.github.com/bogem/nehm/master/Pictures/logo.png" alt="Logo"></img>
|
2
3
|
|
3
|
-
![ScreenShot](https://raw.github.com/bogem/nehm/master/Screenshots/screenshot.png)
|
4
4
|
|
5
|
-
|
5
|
+
<p><b><i>nehm</i></b> is a console tool, which downloads, sets IDv3 tags and adds to your iTunes library your SoundCloud posts or likes in convenient way</p>
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
<a href="http://badge.fury.io/rb/nehm"><img src="https://badge.fury.io/rb/nehm.svg" alt="Gem Version"></img></a>
|
8
|
+
<a href="https://gemnasium.com/bogem/nehm"><img src="https://gemnasium.com/bogem/nehm.svg" alt="Dependency staus"></img></a>
|
9
|
+
<a href="https://codeclimate.com/github/bogem/nehm"><img src="https://codeclimate.com/github/bogem/nehm/badges/gpa.svg" alt="Code climate"></img></a>
|
10
|
+
</div>
|
10
11
|
|
11
|
-
|
12
|
-
|
12
|
+
---
|
13
|
+
<div align="center">
|
14
|
+
<a href="https://www.dropbox.com/s/m4heiyq7vbpc4qs/1help.png" target="_blank"><img src="https://raw.github.com/bogem/nehm/master/Pictures/1help.png" alt="Help"></img></a>
|
15
|
+
<a href="https://www.dropbox.com/s/b68flm7hv5myhk4/2get.png" target="_blank"><img src="https://raw.github.com/bogem/nehm/master/Pictures/2get.png" alt="Select"></img></a>
|
16
|
+
<a href="https://www.dropbox.com/s/5gy6c5nzrsvhlv0/3select.png" target="_blank"><img src="https://raw.github.com/bogem/nehm/master/Pictures/3select.png" alt="Select"></img></a>
|
17
|
+
<a href="https://www.dropbox.com/s/ynn9kb0ykcdishp/4search.png" target="_blank"><img src="https://raw.github.com/bogem/nehm/master/Pictures/4search.png" alt="Search"></img></a>
|
18
|
+
|
19
|
+
<p><b>(clickable screenshots)</b></p>
|
20
|
+
|
21
|
+
</div>
|
22
|
+
|
23
|
+
***
|
24
|
+
|
25
|
+
<div align="center">
|
26
|
+
<h2>DISCLAIMER</h2>
|
27
|
+
|
28
|
+
<b><i><p>For personal use only</p>
|
29
|
+
|
30
|
+
Nehm developer doesn't responsible for any illegal usage of this program</i></b>
|
31
|
+
</div>
|
13
32
|
|
14
|
-
***Nehm developer doesn't responsible for any illegal usage of this program***
|
15
33
|
|
16
34
|
## Installation
|
17
35
|
|
@@ -48,57 +66,56 @@ Before using the nehm, you should set it up:
|
|
48
66
|
Enter path to desirable download directory (press enter to set it to ...
|
49
67
|
```
|
50
68
|
|
51
|
-
## Usage
|
69
|
+
## Usage Examples
|
52
70
|
|
53
|
-
|
71
|
+
Type `nehm help` to list of all available commands or `nehm help COMMAND` for specific command
|
54
72
|
|
55
|
-
|
73
|
+
Also commands and arguments (but **NOT** options) may be abbreviated, so long as they are unambiguous.
|
56
74
|
|
57
|
-
|
75
|
+
#### Get (download to default directory, set tags and add to iTunes library) your last like
|
58
76
|
|
59
|
-
|
77
|
+
`$ nehm get like` = `$ nehm g l`
|
60
78
|
|
61
|
-
|
79
|
+
#### Get your last post (last track or repost from your profile)
|
62
80
|
|
63
|
-
|
81
|
+
`$ nehm get post` = `$ nehm g p`
|
64
82
|
|
65
|
-
|
83
|
+
#### Get multiple last posts or likes
|
66
84
|
|
67
|
-
|
85
|
+
`$ nehm get 3 posts` = `$ nehm get 3 ps`
|
68
86
|
|
69
|
-
|
87
|
+
`$ nehm get 5 likes` = `$ nehm get 5 ls`
|
70
88
|
|
71
|
-
|
89
|
+
#### Just download and set tags any track
|
72
90
|
|
73
|
-
|
91
|
+
`$ nehm dl post` = `$ nehm d p`
|
74
92
|
|
75
|
-
|
93
|
+
#### Get tracks from another user
|
76
94
|
|
77
|
-
|
95
|
+
`$ nehm get post from nasa` or `$ nehm d l from bogem`
|
78
96
|
|
79
|
-
|
97
|
+
#### Get tracks to another directory
|
80
98
|
|
81
|
-
|
99
|
+
`$ nehm g p to ~/Downloads` or `$ nehm d l from bogem to .`
|
82
100
|
|
83
|
-
|
101
|
+
#### Get tracks to another iTunes playlist
|
84
102
|
|
85
|
-
|
103
|
+
`$ nehm g p pl MyPlaylist`
|
86
104
|
|
87
|
-
|
105
|
+
#### Get or download track from url
|
88
106
|
|
89
|
-
|
107
|
+
`$ nehm g https://soundcloud.com/nasa/delta-iv-launch`
|
90
108
|
|
91
|
-
|
109
|
+
#### Select likes or posts and download them
|
92
110
|
|
93
|
-
|
111
|
+
`$ nehm select likes` = `$ nehm sel l`
|
94
112
|
|
95
|
-
|
113
|
+
#### Search for tracks and download them
|
96
114
|
|
97
|
-
|
115
|
+
`$ nehm search kanye west` = `$ nehm sea kanye west`
|
98
116
|
|
99
|
-
`nehm help`
|
100
117
|
|
101
|
-
##FAQ
|
118
|
+
## FAQ
|
102
119
|
|
103
120
|
**Q: What is permalink?**
|
104
121
|
|
data/Rakefile
CHANGED
@@ -1,21 +1,71 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require 'bundler'
|
2
|
+
require 'colored'
|
3
|
+
require 'nehm/ui'
|
4
|
+
require 'rake'
|
3
5
|
|
4
|
-
|
6
|
+
Bundler::GemHelper.install_tasks
|
7
|
+
task default: %w(install)
|
5
8
|
|
6
|
-
|
7
|
-
system('gem build nehm.gemspec')
|
8
|
-
end
|
9
|
+
file = 'pkg/nehm-' + Nehm::VERSION + '.gem'
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
end
|
11
|
+
##
|
12
|
+
# Push to rubygems
|
13
13
|
|
14
|
-
task :
|
14
|
+
task :push => :build do
|
15
|
+
`gem push #{file}`
|
15
16
|
File.delete('./' + file)
|
16
17
|
end
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
19
|
+
##
|
20
|
+
# Add command with boilerplate code
|
21
|
+
#
|
22
|
+
# For example, you want to add 'get' command
|
23
|
+
# For that you should input 'rake nc[get]'
|
24
|
+
|
25
|
+
task :nc, [:cmd] do |_, args|
|
26
|
+
cmd = args[:cmd]
|
27
|
+
cmd_file = "lib/nehm/commands/#{cmd}_command.rb"
|
28
|
+
|
29
|
+
puts "Making #{cmd} command..."
|
30
|
+
|
31
|
+
code = <<-EOF
|
32
|
+
module Nehm
|
33
|
+
|
34
|
+
##
|
35
|
+
# Write here description for command
|
36
|
+
|
37
|
+
class #{cmd.capitalize}Command < Command
|
38
|
+
|
39
|
+
##
|
40
|
+
# Add all command's options in 'initialize' method
|
41
|
+
|
42
|
+
def initialize
|
43
|
+
super
|
44
|
+
end
|
45
|
+
|
46
|
+
def execute
|
47
|
+
end
|
48
|
+
|
49
|
+
def arguments
|
50
|
+
end
|
51
|
+
|
52
|
+
def program_name
|
53
|
+
'nehm #{cmd}'
|
54
|
+
end
|
55
|
+
|
56
|
+
def summary
|
57
|
+
end
|
58
|
+
|
59
|
+
def usage
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
64
|
+
EOF
|
65
|
+
|
66
|
+
# Write to file
|
67
|
+
File.open(cmd_file, 'w') { |f| f.write(code) }
|
68
|
+
|
69
|
+
Nehm::UI.success "Successfully made #{cmd} command!"
|
70
|
+
Nehm::UI.warning "Don't forget to add the name of command to CommandManager::COMMANDS"
|
21
71
|
end
|
data/bin/nehm
CHANGED
data/lib/nehm.rb
CHANGED
@@ -1,50 +1,72 @@
|
|
1
1
|
require 'colored'
|
2
|
-
require 'highline'
|
3
2
|
|
4
3
|
require 'nehm/client'
|
5
4
|
require 'nehm/cfg'
|
6
5
|
require 'nehm/command_manager'
|
6
|
+
require 'nehm/os'
|
7
7
|
require 'nehm/path_manager'
|
8
8
|
require 'nehm/playlist_manager'
|
9
|
+
require 'nehm/track_manager'
|
9
10
|
require 'nehm/ui'
|
10
11
|
require 'nehm/user_manager'
|
11
12
|
|
12
13
|
module Nehm
|
13
14
|
|
14
|
-
# TODO: add rake tests
|
15
|
-
# TODO: add search command
|
16
|
-
# TODO: add select command
|
17
|
-
|
18
15
|
def self.start(args)
|
16
|
+
if args.empty?
|
17
|
+
UI.say HELP
|
18
|
+
UI.term
|
19
|
+
end
|
20
|
+
|
19
21
|
init unless initialized?
|
20
22
|
|
21
23
|
CommandManager.run(args)
|
22
24
|
end
|
23
25
|
|
26
|
+
HELP = <<-EOF
|
27
|
+
#{'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
|
28
|
+
|
29
|
+
#{'Available nehm commands:'.yellow}
|
30
|
+
#{'get'.green} Download, set tags and add to your iTunes library last post or like from your profile
|
31
|
+
#{'dl'.green} Download and set tags last post or like from your profile
|
32
|
+
#{'configure'.green} Configure application
|
33
|
+
#{'help'.green} Show help for specified command
|
34
|
+
#{'search'.green} Search tracks, print them nicely and download selected tracks
|
35
|
+
#{'select'.green} Get likes or posts from your account, nicely print them and download selected tracks
|
36
|
+
#{'version'.green} Show version of installed nehm
|
37
|
+
|
38
|
+
See #{'nehm help COMMAND'.yellow} to read about a specific command
|
39
|
+
|
40
|
+
Commands and arguments (but NOT options) may be abbreviated, so long as they are unambiguous.
|
41
|
+
e.g. 'nehm g l' is short for 'nehm get like'.
|
42
|
+
EOF
|
43
|
+
|
24
44
|
module_function
|
25
45
|
|
26
46
|
def init
|
27
|
-
UI.
|
47
|
+
UI.say 'Hello!'.green
|
28
48
|
UI.say 'Before using the nehm, you should set it up:'
|
29
49
|
Cfg.create unless Cfg.exist?
|
30
50
|
|
31
51
|
PathManager.set_dl_path
|
32
52
|
UI.newline
|
33
53
|
|
34
|
-
|
54
|
+
UserManager.set_uid
|
55
|
+
UI.newline
|
56
|
+
|
57
|
+
if OS.mac?
|
35
58
|
PlaylistManager.set_playlist
|
36
59
|
UI.newline
|
37
60
|
end
|
38
61
|
|
39
|
-
|
62
|
+
UI.success "Now you can use nehm!"
|
40
63
|
UI.newline
|
41
64
|
|
42
|
-
UI
|
43
|
-
sleep(1)
|
65
|
+
sleep(UI::SLEEP_PERIOD)
|
44
66
|
end
|
45
67
|
|
46
68
|
def initialized?
|
47
|
-
|
69
|
+
Cfg.exist?
|
48
70
|
end
|
49
71
|
|
50
72
|
end
|
data/lib/nehm/cfg.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'yaml'
|
2
2
|
|
3
3
|
module Nehm
|
4
4
|
|
@@ -8,18 +8,18 @@ module Nehm
|
|
8
8
|
module Cfg
|
9
9
|
|
10
10
|
FILE_PATH = File.join(ENV['HOME'], '.nehmconfig')
|
11
|
-
CONFIG_FILE = Bogy.new(file: FILE_PATH)
|
12
11
|
|
13
12
|
def self.[](key)
|
14
|
-
|
13
|
+
config_hash[key.to_s]
|
15
14
|
end
|
16
15
|
|
17
16
|
def self.[]=(key, value)
|
18
|
-
|
17
|
+
config_hash[key.to_s] = value
|
18
|
+
write
|
19
19
|
end
|
20
20
|
|
21
21
|
def self.create
|
22
|
-
File.
|
22
|
+
File.new(FILE_PATH, 'w+')
|
23
23
|
end
|
24
24
|
|
25
25
|
def self.exist?
|
@@ -27,7 +27,20 @@ module Nehm
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def self.key?(key)
|
30
|
-
|
30
|
+
config_hash.key?(key.to_s)
|
31
|
+
end
|
32
|
+
|
33
|
+
module_function
|
34
|
+
|
35
|
+
def config_hash
|
36
|
+
@config_hash ||= YAML.load_file(FILE_PATH)
|
37
|
+
@config_hash ||= {} unless @config_hash
|
38
|
+
|
39
|
+
@config_hash
|
40
|
+
end
|
41
|
+
|
42
|
+
def write
|
43
|
+
IO.write(FILE_PATH, config_hash.to_yaml)
|
31
44
|
end
|
32
45
|
|
33
46
|
end
|
data/lib/nehm/client.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
require 'certifi'
|
2
|
-
require '
|
3
|
-
require 'json'
|
4
|
-
require 'soundcloud'
|
2
|
+
require 'nehm/http_client'
|
5
3
|
|
6
4
|
module Nehm
|
7
5
|
|
8
6
|
##
|
9
7
|
# Client module contains all SC API interaction methods
|
8
|
+
# Also it forms urls und send them to HTTPClient
|
10
9
|
|
11
10
|
module Client
|
12
11
|
|
@@ -16,14 +15,9 @@ module Nehm
|
|
16
15
|
ENV['SSL_CERT_FILE'] = Certifi.where
|
17
16
|
|
18
17
|
##
|
19
|
-
#
|
18
|
+
# HTTP client object
|
20
19
|
|
21
|
-
|
22
|
-
|
23
|
-
##
|
24
|
-
# SoundCloud client object
|
25
|
-
|
26
|
-
SC_CLIENT = Soundcloud.new(client_id: CLIENT_ID)
|
20
|
+
HTTP_CLIENT = HTTPClient.new
|
27
21
|
|
28
22
|
##
|
29
23
|
# Max limit of tracks for correct SoundCloud requests
|
@@ -33,7 +27,7 @@ module Nehm
|
|
33
27
|
##
|
34
28
|
# Returns raw array of likes or posts (depends on argument 'type')
|
35
29
|
|
36
|
-
def self.tracks(count, type, uid)
|
30
|
+
def self.tracks(count, offset, type, uid)
|
37
31
|
UI.term "Invalid number of #{type}" if count == 0
|
38
32
|
|
39
33
|
iterations = count.to_f / TRACKS_LIMIT
|
@@ -47,48 +41,51 @@ module Nehm
|
|
47
41
|
tracks +=
|
48
42
|
case type
|
49
43
|
when :likes
|
50
|
-
likes(limit, i * TRACKS_LIMIT, uid)
|
44
|
+
likes(limit, i * TRACKS_LIMIT + offset, uid)
|
51
45
|
when :posts
|
52
|
-
posts(limit, i * TRACKS_LIMIT, uid)
|
46
|
+
posts(limit, i * TRACKS_LIMIT + offset, uid)
|
53
47
|
end
|
54
48
|
end
|
55
49
|
tracks
|
56
50
|
end
|
57
51
|
|
52
|
+
def self.search(query, limit, offset)
|
53
|
+
uri = "/tracks?q=#{query}&limit=#{limit}&offset=#{offset}"
|
54
|
+
HTTP_CLIENT.get(1, uri)
|
55
|
+
end
|
56
|
+
|
58
57
|
##
|
59
|
-
# Returns
|
58
|
+
# Returns track hash from SoundCloud by specified uri
|
60
59
|
|
61
|
-
def self.
|
62
|
-
|
63
|
-
rescue SoundCloud::ResponseError => e
|
64
|
-
return nil if e.message =~ /404/
|
60
|
+
def self.track(uri)
|
61
|
+
HTTP_CLIENT.resolve(uri)
|
65
62
|
end
|
66
63
|
|
67
64
|
##
|
68
|
-
# Returns
|
65
|
+
# Returns user hash from SoundCloud or nil if user doesn't exist
|
69
66
|
|
70
|
-
def self.
|
71
|
-
|
67
|
+
def self.user(permalink)
|
68
|
+
url = "http://soundcloud.com/#{permalink}"
|
69
|
+
begin
|
70
|
+
HTTP_CLIENT.resolve(url)
|
71
|
+
rescue HTTPClient::Status404
|
72
|
+
return nil
|
73
|
+
rescue HTTPClient::ConnectionError
|
74
|
+
UI.term "Connection error. Check your internet connection\nSoundCloud can also be down"
|
75
|
+
end
|
72
76
|
end
|
73
77
|
|
74
78
|
module_function
|
75
79
|
|
76
80
|
def likes(limit, offset, uid)
|
77
|
-
|
81
|
+
uri = "/users/#{uid}/favorites?limit=#{limit}&offset=#{offset}"
|
82
|
+
HTTP_CLIENT.get(1, uri)
|
78
83
|
end
|
79
84
|
|
80
|
-
##
|
81
|
-
# Stantard SoundCloud Ruby wrapper doesn't support reposts if user
|
82
|
-
# isn't authorized
|
83
|
-
# But api-v2.soundcloud.com supports it
|
84
|
-
|
85
|
-
# TODO: use net/http instead of Faraday
|
86
|
-
|
87
85
|
def posts(limit, offset, uid)
|
88
|
-
|
89
|
-
response =
|
90
|
-
|
91
|
-
parsed['collection']
|
86
|
+
uri = "/profile/soundcloud:users:#{uid}?limit=#{limit}&offset=#{offset}"
|
87
|
+
response = HTTP_CLIENT.get(2, uri)
|
88
|
+
response['collection']
|
92
89
|
end
|
93
90
|
|
94
91
|
end
|