nehm 2.0.1 → 2.1
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 +4 -4
- data/lib/nehm.rb +1 -1
- data/lib/nehm/commands/configure_command.rb +5 -3
- data/lib/nehm/commands/get_command.rb +4 -2
- data/lib/nehm/commands/help_command.rb +1 -1
- data/lib/nehm/commands/search_command.rb +21 -0
- data/lib/nehm/commands/select_command.rb +12 -0
- data/lib/nehm/menu.rb +5 -18
- data/lib/nehm/track.rb +9 -0
- data/lib/nehm/tracks_view_command.rb +8 -28
- data/lib/nehm/ui.rb +8 -4
- data/lib/nehm/version.rb +1 -1
- data/nehm.gemspec +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: c10edc21faa4a5d48238b4016cccd64ed556294e
|
4
|
+
data.tar.gz: 0e73986835c88704ba2c838c78a8a5b1e95ecd85
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 125b005c86619752e5046656af178595b759e5a73f67be7905b887d56166a2afeff1a74ff16cb6b59113e51d3fb064a1655ed08963b0d399d978575f6da25233
|
7
|
+
data.tar.gz: 1c2dfc04d057d4b93a96098454e2e9e9f656dd3b397a38875ae0f319cc5d93f98f196cd74405be34162b4757ffa102ace446023ba6fda5734526783924b3ac30
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# nehm change log
|
2
2
|
|
3
|
+
## 2.1
|
4
|
+
* `search` command
|
5
|
+
* Use dash-options *(see help)*
|
6
|
+
* Remove `offset` option
|
7
|
+
* Show duration of track in `search` and `select` commands
|
8
|
+
* Remove message bar in `search` and `select` commands
|
9
|
+
|
3
10
|
## 2.0.1
|
4
11
|
* Make gem size smaller
|
5
12
|
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
<img src="https://raw.github.com/bogem/nehm/master/Pictures/logo.png" alt="Logo"></img>
|
3
3
|
|
4
4
|
|
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>
|
5
|
+
<p><b><i>nehm</i></b> is a console tool, which downloads, sets IDv3 tags and adds to your iTunes library your <b>SoundCloud</b> posts or likes in convenient way</p>
|
6
6
|
|
7
7
|
<a href="http://badge.fury.io/rb/nehm"><img src="https://badge.fury.io/rb/nehm.svg" alt="Gem Version"></img></a>
|
8
8
|
<a href="https://gemnasium.com/bogem/nehm"><img src="https://gemnasium.com/bogem/nehm.svg" alt="Dependency staus"></img></a>
|
@@ -16,7 +16,7 @@
|
|
16
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
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
18
|
|
19
|
-
<p><b>(
|
19
|
+
<p><b>(click to zoom)</b></p>
|
20
20
|
|
21
21
|
</div>
|
22
22
|
|
@@ -82,9 +82,9 @@ Also commands and arguments (but **NOT** options) may be abbreviated, so long as
|
|
82
82
|
|
83
83
|
#### Get multiple last posts or likes
|
84
84
|
|
85
|
-
`$ nehm get 3 posts` = `$ nehm
|
85
|
+
`$ nehm get 3 posts` = `$ nehm g 3 ps`
|
86
86
|
|
87
|
-
`$ nehm get 5 likes` = `$ nehm
|
87
|
+
`$ nehm get 5 likes` = `$ nehm g 5 ls`
|
88
88
|
|
89
89
|
#### Just download and set tags any track
|
90
90
|
|
data/lib/nehm.rb
CHANGED
@@ -6,7 +6,7 @@ module Nehm
|
|
6
6
|
show_info
|
7
7
|
UI.newline
|
8
8
|
show_menu
|
9
|
-
sleep
|
9
|
+
UI.sleep
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
@@ -31,8 +31,10 @@ module Nehm
|
|
31
31
|
permalink = UserManager.default_permalink
|
32
32
|
UI.say "Permalink: #{permalink.cyan}" if permalink
|
33
33
|
|
34
|
-
|
35
|
-
|
34
|
+
if OS.mac?
|
35
|
+
playlist = PlaylistManager.default_playlist
|
36
|
+
UI.say "iTunes playlist: #{playlist.to_s.cyan}" if playlist
|
37
|
+
end
|
36
38
|
end
|
37
39
|
|
38
40
|
def show_menu
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module Nehm
|
2
2
|
class GetCommand < Command
|
3
3
|
|
4
|
+
FIRST_TRACK = [1, 0]
|
5
|
+
|
4
6
|
def initialize
|
5
7
|
super
|
6
8
|
|
@@ -28,9 +30,9 @@ module Nehm
|
|
28
30
|
count = @options[:args].pop.to_i
|
29
31
|
track_manager.posts(count, 0)
|
30
32
|
when /^l/
|
31
|
-
track_manager.likes(
|
33
|
+
track_manager.likes(*FIRST_TRACK)
|
32
34
|
when /^p/
|
33
|
-
track_manager.posts(
|
35
|
+
track_manager.posts(*FIRST_TRACK)
|
34
36
|
when /https:\/\/soundcloud.com\//
|
35
37
|
track_manager.track_from_url(arg)
|
36
38
|
when nil
|
@@ -6,9 +6,30 @@ module Nehm
|
|
6
6
|
|
7
7
|
def initialize
|
8
8
|
super
|
9
|
+
|
10
|
+
add_option(:"-t", '-t PATH',
|
11
|
+
'Download track(s) to PATH')
|
12
|
+
|
13
|
+
add_option(:"-pl", '-pl PLAYLIST',
|
14
|
+
'Add track(s) to iTunes playlist with PLAYLIST name')
|
15
|
+
|
16
|
+
add_option(:"-lim", '-lim NUMBER',
|
17
|
+
'Show NUMBER tracks on each page')
|
18
|
+
|
9
19
|
end
|
10
20
|
|
11
21
|
def execute
|
22
|
+
# Convert dash-options to normal options
|
23
|
+
options_to_convert = { :"-t" => :to,
|
24
|
+
:"-pl" => :pl,
|
25
|
+
:"-lim" => :limit }
|
26
|
+
|
27
|
+
options_to_convert.each do |k,v|
|
28
|
+
value = @options[k]
|
29
|
+
@options.delete(k)
|
30
|
+
@options[v] = value unless value.nil?
|
31
|
+
end
|
32
|
+
|
12
33
|
@query = @options[:args].join(' ')
|
13
34
|
super
|
14
35
|
end
|
@@ -13,6 +13,18 @@ module Nehm
|
|
13
13
|
|
14
14
|
add_option(:from, 'from PERMALINK',
|
15
15
|
'Select track(s) from user with PERMALINK')
|
16
|
+
|
17
|
+
add_option(:to, 'to PATH',
|
18
|
+
'Download track(s) to PATH')
|
19
|
+
|
20
|
+
add_option(:pl, 'pl PLAYLIST',
|
21
|
+
'Add track(s) to iTunes playlist with PLAYLIST name')
|
22
|
+
|
23
|
+
add_option(:limit, 'limit NUMBER',
|
24
|
+
'Show NUMBER tracks on each page')
|
25
|
+
|
26
|
+
add_option(:offset, 'offset NUMBER',
|
27
|
+
'Show from NUMBER+1 track')
|
16
28
|
end
|
17
29
|
|
18
30
|
def arguments
|
data/lib/nehm/menu.rb
CHANGED
@@ -2,8 +2,6 @@ module Nehm
|
|
2
2
|
module UI
|
3
3
|
class Menu
|
4
4
|
|
5
|
-
attr_writer :msg_bar, :header
|
6
|
-
|
7
5
|
def initialize
|
8
6
|
@choices = {}
|
9
7
|
@inc_index = 1
|
@@ -37,21 +35,13 @@ module Nehm
|
|
37
35
|
@items << "#{visual_index} #{desc}"
|
38
36
|
end
|
39
37
|
|
40
|
-
def
|
41
|
-
|
42
|
-
UI.newline
|
38
|
+
def header=(value)
|
39
|
+
@items.unshift(value)
|
43
40
|
end
|
44
41
|
|
45
|
-
|
46
|
-
|
47
|
-
# last successful or not operations
|
48
|
-
# Shown before menu
|
49
|
-
|
50
|
-
def show_msg_bar
|
51
|
-
UI.say 'Message:'
|
52
|
-
UI.say " #{@msg_bar}"
|
42
|
+
def show_header
|
43
|
+
UI.say @header
|
53
44
|
UI.newline
|
54
|
-
@msg_bar.clear
|
55
45
|
end
|
56
46
|
|
57
47
|
def newline
|
@@ -59,9 +49,6 @@ module Nehm
|
|
59
49
|
end
|
60
50
|
|
61
51
|
def select
|
62
|
-
show_header unless @header.to_s.empty?
|
63
|
-
show_msg_bar unless @msg_bar.to_s.empty?
|
64
|
-
|
65
52
|
# Add exit option
|
66
53
|
newline
|
67
54
|
choice('e', 'Exit'.red) { UI.term }
|
@@ -83,7 +70,7 @@ module Nehm
|
|
83
70
|
loop do
|
84
71
|
if @choices.keys.include? selected
|
85
72
|
block = @choices[selected]
|
86
|
-
block.call
|
73
|
+
block.call unless block.nil?
|
87
74
|
break
|
88
75
|
else
|
89
76
|
selected = UI.ask "You must choose one of [#{@choices.keys.join(', ')}]"
|
data/lib/nehm/track.rb
CHANGED
@@ -20,6 +20,15 @@ module Nehm
|
|
20
20
|
Artwork.new(self)
|
21
21
|
end
|
22
22
|
|
23
|
+
def duration
|
24
|
+
seconds = @hash['duration'] / 1000
|
25
|
+
|
26
|
+
time = Time.at(seconds)
|
27
|
+
time -= time.utc_offset
|
28
|
+
|
29
|
+
time.hour > 0 ? time.strftime("%H:%M:%S") : time.strftime("%M:%S")
|
30
|
+
end
|
31
|
+
|
23
32
|
def file_name
|
24
33
|
"#{full_name.tr(',./\\\'$%"', '')}.mp3"
|
25
34
|
end
|
@@ -7,40 +7,25 @@ module Nehm
|
|
7
7
|
|
8
8
|
def initialize
|
9
9
|
super
|
10
|
-
|
11
|
-
add_option(:to, 'to PATH',
|
12
|
-
'Download track(s) to PATH')
|
13
|
-
|
14
|
-
add_option(:pl, 'pl PLAYLIST',
|
15
|
-
'Add track(s) to iTunes playlist with PLAYLIST name')
|
16
|
-
|
17
|
-
add_option(:limit, 'limit NUMBER',
|
18
|
-
'Show NUMBER tracks on each page')
|
19
|
-
|
20
|
-
add_option(:offset, 'offset NUMBER',
|
21
|
-
'Show from NUMBER track')
|
22
|
-
|
23
10
|
end
|
24
11
|
|
25
12
|
def execute
|
13
|
+
setup_environment
|
14
|
+
|
26
15
|
tracks = []
|
27
16
|
old_offset = -1
|
28
17
|
|
29
18
|
@queue = []
|
30
19
|
@track_manager = TrackManager.new(@options)
|
31
20
|
|
32
|
-
setup_environment
|
33
|
-
|
34
21
|
loop do
|
35
|
-
# If offset changed
|
22
|
+
# If offset changed, update list of tracks
|
36
23
|
unless old_offset == @offset
|
37
24
|
tracks = get_tracks
|
38
25
|
old_offset = @offset
|
39
26
|
end
|
40
27
|
|
41
|
-
# If tracks == nil, then there is a last page or there aren't tracks
|
42
28
|
if tracks.nil?
|
43
|
-
@msg = 'There are no more tracks'.red
|
44
29
|
prev_page
|
45
30
|
next
|
46
31
|
end
|
@@ -57,14 +42,14 @@ module Nehm
|
|
57
42
|
UI.menu do |menu|
|
58
43
|
menu.header = 'Enter the number of track to add it to download queue'.green
|
59
44
|
|
60
|
-
|
61
|
-
|
45
|
+
ids = @queue.map(&:id) # Get ids of tracks in queue
|
62
46
|
tracks.each do |track|
|
63
|
-
|
47
|
+
track_info = "#{track.full_name} | #{track.duration}"
|
48
|
+
|
64
49
|
if ids.include? track.id
|
65
|
-
menu.choice(:added,
|
50
|
+
menu.choice(:added, track_info)
|
66
51
|
else
|
67
|
-
menu.choice(:inc,
|
52
|
+
menu.choice(:inc, track_info) { add_track_to_queue(track) }
|
68
53
|
end
|
69
54
|
end
|
70
55
|
|
@@ -100,11 +85,6 @@ module Nehm
|
|
100
85
|
|
101
86
|
def add_track_to_queue(track)
|
102
87
|
@queue << track
|
103
|
-
@msg = "'#{track.full_name}' added".green
|
104
|
-
end
|
105
|
-
|
106
|
-
def already_added(track)
|
107
|
-
@msg = "'#{track.full_name}' was already added".yellow
|
108
88
|
end
|
109
89
|
|
110
90
|
def download_tracks_from_queue
|
data/lib/nehm/ui.rb
CHANGED
@@ -19,6 +19,10 @@ module Nehm
|
|
19
19
|
puts "#{msg}\n".red
|
20
20
|
end
|
21
21
|
|
22
|
+
def self.menu(&block)
|
23
|
+
Menu.new(&block)
|
24
|
+
end
|
25
|
+
|
22
26
|
def self.newline
|
23
27
|
puts
|
24
28
|
end
|
@@ -27,12 +31,12 @@ module Nehm
|
|
27
31
|
puts msg
|
28
32
|
end
|
29
33
|
|
30
|
-
def self.
|
31
|
-
|
34
|
+
def self.sleep
|
35
|
+
sleep(SLEEP_PERIOD)
|
32
36
|
end
|
33
37
|
|
34
|
-
def self.
|
35
|
-
|
38
|
+
def self.success(msg)
|
39
|
+
puts msg.green
|
36
40
|
end
|
37
41
|
|
38
42
|
def self.term(msg = nil)
|
data/lib/nehm/version.rb
CHANGED
data/nehm.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ['Albert Nigmatzianov']
|
10
10
|
spec.email = ['albertnigma@gmail.com']
|
11
11
|
|
12
|
-
spec.summary = 'Convenient way to download tracks from SoundCloud via terminal'
|
12
|
+
spec.summary = 'Convenient way to download tracks (also to iTunes) from SoundCloud via terminal'
|
13
13
|
spec.description = 'nehm is a console tool, which downloads, sets IDv3 tags and adds to your iTunes library your SoundCloud posts or likes in convenient way. See homepage for instructions'
|
14
14
|
spec.homepage = 'http://www.github.com/bogem/nehm'
|
15
15
|
spec.license = 'MIT'
|
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: 2.
|
4
|
+
version: '2.1'
|
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-11-
|
11
|
+
date: 2015-11-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: certifi
|
@@ -123,5 +123,5 @@ rubyforge_project:
|
|
123
123
|
rubygems_version: 2.5.0
|
124
124
|
signing_key:
|
125
125
|
specification_version: 4
|
126
|
-
summary: Convenient way to download tracks from SoundCloud via terminal
|
126
|
+
summary: Convenient way to download tracks (also to iTunes) from SoundCloud via terminal
|
127
127
|
test_files: []
|