nehm 1.5.4 → 1.5.5.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 +9 -25
- data/bin/nehm +1 -1
- data/lib/nehm.rb +42 -37
- data/lib/nehm/applescript.rb +18 -15
- data/lib/nehm/artwork.rb +26 -24
- data/lib/nehm/cfg.rb +21 -18
- data/lib/nehm/client.rb +14 -12
- data/lib/nehm/configure.rb +18 -16
- data/lib/nehm/get.rb +82 -83
- data/lib/nehm/help.rb +75 -72
- data/lib/nehm/os.rb +5 -3
- data/lib/nehm/path_manager.rb +52 -50
- data/lib/nehm/playlist.rb +13 -11
- data/lib/nehm/playlist_manager.rb +34 -30
- data/lib/nehm/track.rb +45 -43
- data/lib/nehm/user.rb +58 -55
- data/lib/nehm/user_manager.rb +45 -43
- data/lib/nehm/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b56162720e521296eab895683dc2fa1c8829d9d
|
4
|
+
data.tar.gz: edfdc21208cc7ef4fcf079b10c76717a64ef6a6d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b136d0b1e1db0198a9ed64e8dca40208f08f8218d606f5ecbfac05652270745f171ed0b41895502c1be0717b2acd6f2d82961f4fd96a20768a1201009ddb1b3f
|
7
|
+
data.tar.gz: cc7b42a50791e55e5014b8da6f4d295d9ad7c66d1cfa8564942f916ae2ca0328efae6e8d2f70c8a217b858db2c4efead95b58990e020291c2f68039279bdf8a5
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
# nehm change log
|
2
2
|
|
3
|
+
## 1.5.5.1
|
4
|
+
* Fix bug with `nil` in user class
|
5
|
+
|
6
|
+
## 1.5.5
|
7
|
+
* Add `version` command
|
8
|
+
* Some bug fixes for Linux users
|
9
|
+
* Edit some output messages
|
10
|
+
* Minor optimizations
|
11
|
+
|
3
12
|
## 1.5.4
|
4
13
|
* Add availability to get/dl 300+ likes and posts
|
5
14
|
* More convenient CLI
|
@@ -21,7 +30,6 @@
|
|
21
30
|
* Add `url` option to `dl` and `get`
|
22
31
|
|
23
32
|
## 1.5
|
24
|
-
|
25
33
|
* Add support for Ruby 1.9.3
|
26
34
|
* Edit application structure
|
27
35
|
* Improve performance when adding tracks to iTunes library
|
@@ -29,16 +37,13 @@
|
|
29
37
|
* Prettify `nehm help`
|
30
38
|
|
31
39
|
## 1.4.2
|
32
|
-
|
33
40
|
* Fix: app fails if you didn't set up playlist (again)
|
34
41
|
* Reduce gem size
|
35
42
|
|
36
43
|
## 1.4.1
|
37
|
-
|
38
44
|
* Fix: app fails if you didn't set up playlist
|
39
45
|
|
40
46
|
## 1.4
|
41
|
-
|
42
47
|
* Now nehm can automatically add track to iTunes playlist. Enter `nehm configure` to set it up
|
43
48
|
* Also you can download tracks with custom iTunes playlist with `playlist PLAYLIST` feature. See the 'Usage' for instructions
|
44
49
|
* Handle more errors
|
@@ -49,91 +54,70 @@
|
|
49
54
|
* Minor improvements and fixes
|
50
55
|
|
51
56
|
## 1.3.3
|
52
|
-
|
53
57
|
* Add `to current` feature
|
54
58
|
|
55
59
|
## 1.3.2
|
56
|
-
|
57
60
|
* Add check for no user's posts/likes
|
58
61
|
|
59
62
|
## 1.3.1.1
|
60
|
-
|
61
63
|
* Minor changes
|
62
64
|
|
63
65
|
## 1.3.1
|
64
|
-
|
65
66
|
* Edit looped configure menu
|
66
67
|
|
67
68
|
## 1.3
|
68
|
-
|
69
69
|
* Now you can type short paths to download and iTunes paths while configuring nehm (e.g. ~/Music)
|
70
70
|
* Configure menu doesn't automatically exit after choose
|
71
71
|
* nehm doesn't ask for iTunes path by first run
|
72
72
|
|
73
73
|
## 1.2.2
|
74
|
-
|
75
74
|
* Tracks has got now year tag
|
76
75
|
|
77
76
|
## 1.2.1
|
78
|
-
|
79
77
|
* Minor technical update
|
80
78
|
|
81
79
|
## 1.2
|
82
|
-
|
83
80
|
* Add `to PARHTODIRECTORY` feature. See the 'Usage' for instructions
|
84
81
|
* Improve readability of help
|
85
82
|
* Add some error checks
|
86
83
|
|
87
84
|
## 1.1
|
88
|
-
|
89
85
|
* Add `from PERMALINK` feature. See the 'Usage' for instructions
|
90
86
|
|
91
87
|
## 1.0.7.1
|
92
|
-
|
93
88
|
* Remove useless dependency :)
|
94
89
|
|
95
90
|
## 1.0.7
|
96
|
-
|
97
91
|
* Add paint dependency
|
98
92
|
|
99
93
|
## 1.0.6.1
|
100
|
-
|
101
94
|
* Edit gem description
|
102
95
|
* Edit dependencies
|
103
96
|
|
104
97
|
## 1.0.6
|
105
|
-
|
106
98
|
* Add check for invalid number of likes/posts
|
107
99
|
* Add `CHANGELOG.md`
|
108
100
|
* Use `OPTIONS` instead of `[options]` in help
|
109
101
|
|
110
102
|
## 1.0.5
|
111
|
-
|
112
103
|
* Fix bundler development dependency
|
113
104
|
|
114
105
|
## 1.0.4
|
115
|
-
|
116
106
|
* Edit summary in gemspec
|
117
107
|
|
118
108
|
## 1.0.3
|
119
|
-
|
120
109
|
* Change description of nehm
|
121
110
|
|
122
111
|
## 1.0.2
|
123
|
-
|
124
112
|
* Edit path to nehm version in Rakefile
|
125
113
|
* Fix: nehm fails, then setting tags to track
|
126
114
|
|
127
115
|
## 1.0.1
|
128
|
-
|
129
116
|
* Rakefile:
|
130
|
-
|
131
117
|
* Add push (push to rubygems.org) task
|
132
118
|
* Modify tasks
|
133
|
-
|
134
119
|
* Edit required Ruby version
|
135
120
|
* Fix: if you type invalid argument in `nehm get`, then app fails
|
136
121
|
|
137
122
|
## 1.0
|
138
|
-
|
139
123
|
* First release!
|
data/bin/nehm
CHANGED
data/lib/nehm.rb
CHANGED
@@ -15,52 +15,57 @@ require 'nehm/playlist_manager'
|
|
15
15
|
require 'nehm/track'
|
16
16
|
require 'nehm/user'
|
17
17
|
require 'nehm/user_manager'
|
18
|
+
require 'nehm/version'
|
18
19
|
|
19
|
-
module
|
20
|
-
|
21
|
-
|
20
|
+
module Nehm
|
21
|
+
module App
|
22
|
+
def self.do(args)
|
23
|
+
init unless initialized?
|
22
24
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
rescue Interrupt
|
40
|
-
puts "\nGoodbye!"
|
41
|
-
end
|
25
|
+
command = args.shift
|
26
|
+
case command
|
27
|
+
when 'get'
|
28
|
+
Get[:get, args]
|
29
|
+
when 'dl'
|
30
|
+
Get[:dl, args]
|
31
|
+
when 'configure'
|
32
|
+
Configure.menu
|
33
|
+
when 'version'
|
34
|
+
puts Nehm::VERSION
|
35
|
+
when 'help', nil
|
36
|
+
Help.show(args.first)
|
37
|
+
else
|
38
|
+
puts Paint["Invalid command '#{command}'", :red]
|
39
|
+
puts "Input #{Paint['nehm help', :yellow]} for all avalaible commands"
|
40
|
+
end
|
42
41
|
|
43
|
-
|
42
|
+
# SIGINT
|
43
|
+
rescue Interrupt
|
44
|
+
puts "\nGoodbye!"
|
45
|
+
end
|
44
46
|
|
45
|
-
|
46
|
-
puts Paint['Hello!', :green]
|
47
|
-
puts 'Before using the nehm, you should set it up:'
|
48
|
-
Cfg.create unless Cfg.exist?
|
47
|
+
module_function
|
49
48
|
|
50
|
-
|
51
|
-
|
49
|
+
def init
|
50
|
+
puts Paint['Hello!', :green]
|
51
|
+
puts 'Before using the nehm, you should set it up:'
|
52
|
+
Cfg.create unless Cfg.exist?
|
52
53
|
|
53
|
-
|
54
|
-
PlaylistManager.set_playlist
|
54
|
+
PathManager.set_dl_path
|
55
55
|
puts "\n"
|
56
|
-
end
|
57
56
|
|
58
|
-
|
57
|
+
unless OS.linux?
|
58
|
+
PlaylistManager.set_playlist
|
59
|
+
puts "\n"
|
60
|
+
end
|
59
61
|
|
60
|
-
|
61
|
-
|
62
|
+
UserManager.log_in
|
63
|
+
|
64
|
+
puts Paint["Now you can use nehm!\n", :green]
|
65
|
+
end
|
62
66
|
|
63
|
-
|
64
|
-
|
67
|
+
def initialized?
|
68
|
+
File.exist?(Cfg::FILE_PATH)
|
69
|
+
end
|
65
70
|
end
|
66
71
|
end
|
data/lib/nehm/applescript.rb
CHANGED
@@ -1,21 +1,24 @@
|
|
1
|
-
module
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
module Nehm
|
2
|
+
# Module which works with AppleScript scripts
|
3
|
+
module AppleScript
|
4
|
+
def self.add_track_to_playlist(track_path, playlist_name)
|
5
|
+
`osascript \"#{script_path(:add_track_to_playlist)}\" \"#{track_path}\" \"#{playlist_name}\" > /dev/null`
|
6
|
+
end
|
5
7
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
def self.list_of_playlists
|
9
|
+
output = `osascript \"#{script_path(:list_of_playlists)}\"`
|
10
|
+
output.chomp.split(', ')
|
11
|
+
end
|
10
12
|
|
11
|
-
|
12
|
-
|
13
|
-
|
13
|
+
def self.music_master_library
|
14
|
+
`osascript \"#{script_path(:music_master_library)}\"`
|
15
|
+
end
|
14
16
|
|
15
|
-
|
17
|
+
module_function
|
16
18
|
|
17
|
-
|
18
|
-
|
19
|
-
|
19
|
+
def script_path(script_name)
|
20
|
+
applescripts_path = File.expand_path(File.join(File.dirname(__FILE__), 'applescripts'))
|
21
|
+
File.join(applescripts_path, "#{script_name.to_s}.applescript")
|
22
|
+
end
|
20
23
|
end
|
21
24
|
end
|
data/lib/nehm/artwork.rb
CHANGED
@@ -1,30 +1,32 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
module Nehm
|
2
|
+
# Artwork objects contains all needed information of track's artwork
|
3
|
+
class Artwork
|
4
|
+
def initialize(track)
|
5
|
+
@track = track
|
6
|
+
end
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
def file_path
|
9
|
+
File.join('/tmp', "#{@track.id}.jpg")
|
10
|
+
end
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
# Use in Get.dl
|
13
|
+
def name
|
14
|
+
'artwork'
|
15
|
+
end
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
17
|
+
def suicide
|
18
|
+
File.delete(file_path)
|
19
|
+
end
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
21
|
+
def url
|
22
|
+
hash = @track.hash
|
23
|
+
url =
|
24
|
+
if hash['artwork_url'].nil?
|
25
|
+
hash['user']['avatar_url']
|
26
|
+
else
|
27
|
+
hash['artwork_url']
|
28
|
+
end
|
29
|
+
url.sub('large', 't500x500')
|
30
|
+
end
|
29
31
|
end
|
30
32
|
end
|
data/lib/nehm/cfg.rb
CHANGED
@@ -1,27 +1,30 @@
|
|
1
1
|
require 'bogy'
|
2
2
|
|
3
|
-
# Cfg module manipulate with nehm's config file (~/.nehmconfig)
|
4
|
-
module Cfg
|
5
|
-
FILE_PATH = File.join(ENV['HOME'], '.nehmconfig')
|
6
|
-
CONFIG_FILE = Bogy.new(file: FILE_PATH)
|
7
3
|
|
8
|
-
|
9
|
-
|
10
|
-
|
4
|
+
module Nehm
|
5
|
+
# Cfg module manipulates with nehm's config file (~/.nehmconfig)
|
6
|
+
module Cfg
|
7
|
+
FILE_PATH = File.join(ENV['HOME'], '.nehmconfig')
|
8
|
+
CONFIG_FILE = Bogy.new(file: FILE_PATH)
|
11
9
|
|
12
|
-
|
13
|
-
|
14
|
-
|
10
|
+
def self.[](key)
|
11
|
+
CONFIG_FILE[key.to_s]
|
12
|
+
end
|
15
13
|
|
16
|
-
|
17
|
-
|
18
|
-
|
14
|
+
def self.[]=(key, value)
|
15
|
+
CONFIG_FILE[key.to_s] = value
|
16
|
+
end
|
19
17
|
|
20
|
-
|
21
|
-
|
22
|
-
|
18
|
+
def self.create
|
19
|
+
File.open(FILE_PATH, 'w+') { |f| f.write("---\napp: nehm") }
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.exist?
|
23
|
+
File.exist?(FILE_PATH)
|
24
|
+
end
|
23
25
|
|
24
|
-
|
25
|
-
|
26
|
+
def self.key?(key)
|
27
|
+
CONFIG_FILE.to_h.key?(key.to_s)
|
28
|
+
end
|
26
29
|
end
|
27
30
|
end
|
data/lib/nehm/client.rb
CHANGED
@@ -1,21 +1,23 @@
|
|
1
1
|
require 'certifi'
|
2
2
|
require 'soundcloud'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
module Nehm
|
5
|
+
# Soundcloud API client.
|
6
|
+
module Client
|
7
|
+
# Set a SSL certificate file path for SC API
|
8
|
+
ENV['SSL_CERT_FILE'] = Certifi.where
|
8
9
|
|
9
|
-
|
10
|
-
|
10
|
+
# SoundCloud API client ID
|
11
|
+
CLIENT_ID = '11a37feb6ccc034d5975f3f803928a32'
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
13
|
+
def self.get(*args)
|
14
|
+
sc_client.get(*args)
|
15
|
+
end
|
15
16
|
|
16
|
-
|
17
|
+
module_function
|
17
18
|
|
18
|
-
|
19
|
-
|
19
|
+
def sc_client
|
20
|
+
@client ||= Soundcloud.new(client_id: CLIENT_ID)
|
21
|
+
end
|
20
22
|
end
|
21
23
|
end
|
data/lib/nehm/configure.rb
CHANGED
@@ -1,22 +1,24 @@
|
|
1
|
-
|
2
|
-
module
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
1
|
+
module Nehm
|
2
|
+
# Configure module responds to 'nehm configure' command
|
3
|
+
module Configure
|
4
|
+
def self.menu
|
5
|
+
loop do
|
6
|
+
puts "Download path: #{Paint[Cfg[:dl_path], :magenta]}"
|
7
|
+
puts "Permalink: #{Paint[Cfg[:permalink], :cyan]}"
|
8
|
+
puts "iTunes playlist: #{Paint[PlaylistManager.playlist, :cyan]}" unless OS.linux?
|
9
|
+
puts "\n"
|
9
10
|
|
10
|
-
|
11
|
-
|
11
|
+
HighLine.new.choose do |menu|
|
12
|
+
menu.prompt = Paint['Choose setting', :yellow]
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
menu.choice('Edit download path'.freeze) { PathManager.set_dl_path }
|
15
|
+
menu.choice('Edit permalink'.freeze) { UserManager.log_in }
|
16
|
+
menu.choice('Edit iTunes playlist'.freeze) { PlaylistManager.set_playlist } unless OS.linux?
|
17
|
+
menu.choice('Exit'.freeze) { puts 'Goodbye!'; exit }
|
18
|
+
end
|
19
|
+
sleep(1)
|
20
|
+
puts "\n"
|
17
21
|
end
|
18
|
-
sleep(1)
|
19
|
-
puts "\n"
|
20
22
|
end
|
21
23
|
end
|
22
24
|
end
|