nehm 1.5.1 → 1.5.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/CHANGELOG.md +4 -0
- data/bin/nehm +3 -0
- data/lib/nehm.rb +1 -1
- data/lib/nehm/cfg.rb +9 -23
- data/lib/nehm/get.rb +0 -1
- data/lib/nehm/help.rb +56 -46
- data/lib/nehm/user_control.rb +13 -15
- data/lib/nehm/version.rb +1 -1
- data/nehm.gemspec +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b08eefd3115d43cbe5cd3668fc4dcab6b2393b52
|
4
|
+
data.tar.gz: c1f896f13a89eeac413c7f3dc7f4be5341bc8dcd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb02cb4c2974269b3de4c6d2e661f1e9b4e00b5e25fd4c3936bc4ccd806bfed6aad887681542bae3602010738e426e4c894a8861e2da738bd3689a0bb1d96445
|
7
|
+
data.tar.gz: f88c3e0575446c42bee43d55b2394275c5f83525994eae2732f3b09d749fa63b4291efde25d073d04cac340a66d24581a175b0291baf784c107c353dca85f2b3
|
data/CHANGELOG.md
CHANGED
data/bin/nehm
CHANGED
data/lib/nehm.rb
CHANGED
data/lib/nehm/cfg.rb
CHANGED
@@ -1,41 +1,27 @@
|
|
1
|
-
require '
|
1
|
+
require 'bogy'
|
2
2
|
|
3
3
|
# Cfg module manipulate with nehm's config file (~/.nehmconfig)
|
4
4
|
module Cfg
|
5
|
+
FILE_PATH = File.join(ENV['HOME'], '.nehmconfig')
|
6
|
+
CONFIG_FILE = Bogy.new(file: FILE_PATH)
|
7
|
+
|
5
8
|
def self.[](key)
|
6
|
-
|
7
|
-
config_hash[key.to_s]
|
9
|
+
CONFIG_FILE[key.to_s]
|
8
10
|
end
|
9
11
|
|
10
12
|
def self.[]=(key, value)
|
11
|
-
|
12
|
-
config_hash[key.to_s] = value
|
13
|
-
save_config(config_hash)
|
13
|
+
CONFIG_FILE[key.to_s] = value
|
14
14
|
end
|
15
15
|
|
16
16
|
def self.create
|
17
|
-
File.open(
|
17
|
+
File.open(FILE_PATH, 'w+') { |f| f.write("---\napp: nehm") }
|
18
18
|
end
|
19
19
|
|
20
20
|
def self.exist?
|
21
|
-
File.exist?(
|
21
|
+
File.exist?(FILE_PATH)
|
22
22
|
end
|
23
23
|
|
24
24
|
def self.key?(key)
|
25
|
-
|
26
|
-
end
|
27
|
-
|
28
|
-
module_function
|
29
|
-
|
30
|
-
def file_path
|
31
|
-
File.join(ENV['HOME'], '.nehmconfig')
|
32
|
-
end
|
33
|
-
|
34
|
-
def load_config
|
35
|
-
YAML.load_file(file_path)
|
36
|
-
end
|
37
|
-
|
38
|
-
def save_config(config_hash)
|
39
|
-
IO.write(file_path, config_hash.to_yaml)
|
25
|
+
CONFIG_FILE.to_h.key?(key.to_s)
|
40
26
|
end
|
41
27
|
end
|
data/lib/nehm/get.rb
CHANGED
data/lib/nehm/help.rb
CHANGED
@@ -1,16 +1,18 @@
|
|
1
1
|
# Help module responds to 'nehm help ...' command
|
2
2
|
module Help
|
3
3
|
def self.available_commands
|
4
|
-
puts
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
puts <<-HELP.gsub(/^ {6}/, '')
|
5
|
+
#{Paint['Avalaible nehm commands:', :yellow]}
|
6
|
+
#{Paint['get', :green]} Downloading, setting tags and adding to your iTunes library last post or like from your profile
|
7
|
+
#{Paint['dl', :green]} Downloading and setting tags last post or like from your profile
|
8
|
+
#{Paint['configure', :green]} Configuring application
|
9
|
+
See #{Paint['nehm help [command]', :yellow]} to read about a specific subcommand
|
10
|
+
HELP
|
9
11
|
end
|
10
12
|
|
11
13
|
def self.show(command)
|
12
14
|
case command
|
13
|
-
when 'get', 'dl', 'configure'
|
15
|
+
when 'get', 'dl', 'configure', 'permalink'
|
14
16
|
Help.send(command)
|
15
17
|
when nil
|
16
18
|
Help.available_commands
|
@@ -24,54 +26,62 @@ module Help
|
|
24
26
|
module_function
|
25
27
|
|
26
28
|
def configure
|
27
|
-
puts
|
28
|
-
|
29
|
-
|
30
|
-
|
29
|
+
puts <<-CONFIGURE.gsub(/^ {6}/, '')
|
30
|
+
#{Paint['Input:', :yellow]} nehm configure
|
31
|
+
|
32
|
+
#{Paint['Summary:', :yellow]}
|
33
|
+
Configuring nehm app
|
34
|
+
CONFIGURE
|
31
35
|
end
|
32
36
|
|
33
37
|
def dl
|
34
|
-
puts
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
38
|
+
puts <<-DL.gsub(/^ {6}/, '')
|
39
|
+
#{Paint['Input:', :yellow]} nehm dl OPTIONS [from PERMALINK] [to PATH_TO_DIRECTORY] [playlist ITUNES_PLAYLIST]
|
40
|
+
|
41
|
+
#{Paint['Summary:', :yellow]}
|
42
|
+
Downloading tracks from SoundCloud and setting tags
|
43
|
+
|
44
|
+
#{Paint['OPTIONS:', :yellow]}
|
45
|
+
#{Paint['post', :green]} Do same with last post (track or repost) from your profile
|
46
|
+
#{Paint['<number> posts', :green]} Do same with last <number> posts from your profile
|
47
|
+
#{Paint['like', :green]} Do same with your last like
|
48
|
+
#{Paint['<number> likes', :green]} Do same with your last <number> likes
|
49
|
+
#{Paint['url', :magenta]} Do same with track from entered url
|
50
|
+
|
51
|
+
#{Paint['Extra options:', :yellow]}
|
52
|
+
#{Paint['from PERMALINK', :green]} Do aforecited operations from custom user profile
|
53
|
+
#{Paint['to PATH_TO_DIRECTORY', :green]} Do aforecited operations to custom directory
|
54
|
+
#{Paint['to current', :green]} Do aforecited operations to current working directory
|
55
|
+
#{Paint['playlist ITUNES_PLAYLIST', :green]} Do aforecited operations to custom iTunes playlist
|
56
|
+
DL
|
51
57
|
end
|
52
58
|
|
53
59
|
def get
|
54
|
-
puts
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
60
|
+
puts <<-GET.gsub(/^ {6}/, '')
|
61
|
+
#{Paint['Input:', :yellow]} nehm get OPTIONS [from PERMALINK] [to PATH_TO_DIRECTORY] [playlist ITUNES_PLAYLIST]
|
62
|
+
|
63
|
+
#{Paint['Summary:', :yellow]}
|
64
|
+
Downloading tracks, setting tags and adding to your iTunes library tracks from Soundcloud
|
65
|
+
|
66
|
+
#{Paint['OPTIONS:', :yellow]}
|
67
|
+
#{Paint['post', :green]} Do same with last post (track or repost) from your profile
|
68
|
+
#{Paint['<number> posts', :green]} Do same with last <number> posts from your profile
|
69
|
+
#{Paint['like', :green]} Do same with your last like
|
70
|
+
#{Paint['<number> likes', :green]} Do same with your last <number> likes
|
71
|
+
#{Paint['url', :magenta]} Do same with track from entered url
|
72
|
+
|
73
|
+
#{Paint['Extra options:', :yellow]}
|
74
|
+
#{Paint['from PERMALINK', :green]} Do aforecited operations from profile with PERMALINK
|
75
|
+
#{Paint['to PATH_TO_DIRECTORY', :green]} Do aforecited operations to custom directory
|
76
|
+
#{Paint['to current', :green]} Do aforecited operations to current working directory
|
77
|
+
#{Paint['playlist ITUNES_PLAYLIST', :green]} Do aforecited operations to custom iTunes playlist
|
78
|
+
GET
|
71
79
|
end
|
72
80
|
|
73
81
|
def permalink
|
74
|
-
puts
|
75
|
-
|
82
|
+
puts <<-PERM.gsub(/^ {6}/, '')
|
83
|
+
Permalink is the last word in your profile url
|
84
|
+
Example: for profile url #{Paint['soundcloud.com/qwerty', :magenta]} permalink is #{Paint['qwerty', :magenta]}
|
85
|
+
PERM
|
76
86
|
end
|
77
87
|
end
|
data/lib/nehm/user_control.rb
CHANGED
@@ -1,4 +1,7 @@
|
|
1
1
|
module UserControl
|
2
|
+
def self.user
|
3
|
+
@temp_user || default_user
|
4
|
+
end
|
2
5
|
|
3
6
|
def self.logged_in?
|
4
7
|
Cfg.key?(:default_id)
|
@@ -7,9 +10,8 @@ module UserControl
|
|
7
10
|
def self.log_in
|
8
11
|
loop do
|
9
12
|
permalink = HighLine.new.ask('Please enter your permalink (last word in your profile url): ')
|
10
|
-
|
11
|
-
if
|
12
|
-
user = Client.get('/resolve', url: url)
|
13
|
+
user = get_user(permalink)
|
14
|
+
if user
|
13
15
|
Cfg[:default_id] = user.id
|
14
16
|
Cfg[:permalink] = permalink
|
15
17
|
puts Paint['Successfully logged in!', :green]
|
@@ -21,8 +23,8 @@ module UserControl
|
|
21
23
|
end
|
22
24
|
|
23
25
|
def self.temp_user=(permalink)
|
24
|
-
|
25
|
-
|
26
|
+
user = get_user(permalink)
|
27
|
+
if user
|
26
28
|
@temp_user = User.new(user.id)
|
27
29
|
else
|
28
30
|
puts Paint['Invalid permalink. Please enter correct permalink', :red]
|
@@ -30,10 +32,6 @@ module UserControl
|
|
30
32
|
end
|
31
33
|
end
|
32
34
|
|
33
|
-
def self.user
|
34
|
-
@temp_user || default_user
|
35
|
-
end
|
36
|
-
|
37
35
|
module_function
|
38
36
|
|
39
37
|
def default_user
|
@@ -46,16 +44,16 @@ module UserControl
|
|
46
44
|
end
|
47
45
|
end
|
48
46
|
|
49
|
-
def
|
50
|
-
|
51
|
-
|
47
|
+
def get_user(permalink)
|
48
|
+
begin
|
49
|
+
user = Client.get('/resolve', url: "https://soundcloud.com/#{permalink}")
|
52
50
|
rescue SoundCloud::ResponseError => e
|
53
51
|
if e.message =~ /404/
|
54
|
-
|
52
|
+
user = nil
|
55
53
|
else
|
56
54
|
raise e
|
57
55
|
end
|
58
|
-
|
59
|
-
|
56
|
+
end
|
57
|
+
user
|
60
58
|
end
|
61
59
|
end
|
data/lib/nehm/version.rb
CHANGED
data/nehm.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.2
|
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-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: soundcloud
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: bogy
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
97
111
|
description: " nehm is a console tool, which downloads, sets IDv3 tags and adds to
|
98
112
|
your iTunes library your SoundCloud posts or likes in convenient way. See homepage
|
99
113
|
for instructions "
|