nehm 2.0.1 → 2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 642f53e571f554b780f52a641af8fdfe81f0a05c
4
- data.tar.gz: d7eef194b669c2915a4ee53ddf7e8049b3e46058
3
+ metadata.gz: c10edc21faa4a5d48238b4016cccd64ed556294e
4
+ data.tar.gz: 0e73986835c88704ba2c838c78a8a5b1e95ecd85
5
5
  SHA512:
6
- metadata.gz: d5926b9ad5deabd35d73a8caff482596e37a2083ad048dc203fc6171c8758e0b3cb769f6a838e919938598cd25f650d97606df580de9764f590600ef232f870e
7
- data.tar.gz: 8097e9ef27791c75a04fa6841c1fea3d537426fda0551808702aba9fcc0376e4d2791e67aa0cd095462c38c554aef350188147038c99165ca6ddaf46063edfd7
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>(clickable screenshots)</b></p>
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 get 3 ps`
85
+ `$ nehm get 3 posts` = `$ nehm g 3 ps`
86
86
 
87
- `$ nehm get 5 likes` = `$ nehm get 5 ls`
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
@@ -62,7 +62,7 @@ EOF
62
62
  UI.success "Now you can use nehm!"
63
63
  UI.newline
64
64
 
65
- sleep(UI::SLEEP_PERIOD)
65
+ UI.sleep
66
66
  end
67
67
 
68
68
  def initialized?
@@ -6,7 +6,7 @@ module Nehm
6
6
  show_info
7
7
  UI.newline
8
8
  show_menu
9
- sleep(UI::SLEEP_PERIOD)
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
- playlist = PlaylistManager.default_playlist
35
- UI.say "iTunes playlist: #{playlist.to_s.cyan}" if playlist
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(1, 0)
33
+ track_manager.likes(*FIRST_TRACK)
32
34
  when /^p/
33
- track_manager.posts(1, 0)
35
+ track_manager.posts(*FIRST_TRACK)
34
36
  when /https:\/\/soundcloud.com\//
35
37
  track_manager.track_from_url(arg)
36
38
  when nil
@@ -19,7 +19,7 @@ module Nehm
19
19
  end
20
20
 
21
21
  def arguments
22
- { 'COMMAND' => 'name of command to show help' }
22
+ { 'COMMAND' => 'name of command (can be abbreviated) to show help' }
23
23
  end
24
24
 
25
25
  def program_name
@@ -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 show_header
41
- UI.say @header
42
- UI.newline
38
+ def header=(value)
39
+ @items.unshift(value)
43
40
  end
44
41
 
45
- ##
46
- # Message bar used to show messages of
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
- menu.msg_bar = @msg
61
-
45
+ ids = @queue.map(&:id) # Get ids of tracks in queue
62
46
  tracks.each do |track|
63
- ids = @queue.map(&:id) # Get ids of tracks in queue
47
+ track_info = "#{track.full_name} | #{track.duration}"
48
+
64
49
  if ids.include? track.id
65
- menu.choice(:added, track.full_name) { already_added(track) }
50
+ menu.choice(:added, track_info)
66
51
  else
67
- menu.choice(:inc, track.full_name) { add_track_to_queue(track) }
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.success(msg)
31
- puts msg.green
34
+ def self.sleep
35
+ sleep(SLEEP_PERIOD)
32
36
  end
33
37
 
34
- def self.menu(&block)
35
- Menu.new(&block)
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
@@ -1,3 +1,3 @@
1
1
  module Nehm
2
- VERSION = '2.0.1'.freeze
2
+ VERSION = '2.1'.freeze
3
3
  end
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.0.1
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 00:00:00.000000000 Z
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: []