nehm 1.4.2 → 1.5
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 +9 -0
- data/README.md +3 -3
- data/lib/nehm.rb +2 -5
- data/lib/nehm/applescript.rb +5 -1
- data/lib/nehm/applescripts/music_master_library.applescript +3 -0
- data/lib/nehm/{config.rb → cfg.rb} +2 -2
- data/lib/nehm/configure.rb +3 -22
- data/lib/nehm/get.rb +1 -32
- data/lib/nehm/help.rb +3 -3
- data/lib/nehm/path_control.rb +6 -49
- data/lib/nehm/playlist.rb +1 -1
- data/lib/nehm/playlist_control.rb +13 -7
- data/lib/nehm/user_control.rb +4 -4
- data/lib/nehm/version.rb +1 -1
- data/nehm.gemspec +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f45c781d72f8543d6b8f6172bd94682d89d3589
|
4
|
+
data.tar.gz: 517a5d04219f8ff0eb36a968f9b4c0c6adb1dfb4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a4f13bfbadced60aa02119e1e69ede64c46deb7e7a5a067afb410014590287d50d09c9f2292c30f73027f2b08100f4e0ec6466ecdc9d5ad537310a31a89e98f
|
7
|
+
data.tar.gz: 99346b65d73ee41511e922b8cce7c3124ba342be5a4b5f64d8c4838efb3ba4c8831f233ac0c4deaeec953e726aa96538af3c544bb4b9dd91e25cdfc3c1aa7768
|
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,17 @@
|
|
1
1
|
# nehm change log
|
2
2
|
|
3
|
+
## 1.5
|
4
|
+
|
5
|
+
* Add support for Ruby 1.9.3
|
6
|
+
* Edit application structure
|
7
|
+
* Improve performance when adding tracks to iTunes library
|
8
|
+
* Remove useless iTunes path logic
|
9
|
+
* Prettify `nehm help`
|
10
|
+
|
3
11
|
## 1.4.2
|
4
12
|
|
5
13
|
* Fix: app fails if you didn't set up playlist (again)
|
14
|
+
* Reduce gem size
|
6
15
|
|
7
16
|
## 1.4.1
|
8
17
|
|
data/README.md
CHANGED
@@ -46,7 +46,7 @@ Go to usage for further instructions
|
|
46
46
|
|
47
47
|
**!!nehm doesn't add tracks to iTunes library, if you use Linux!!**
|
48
48
|
|
49
|
-
* To get (download to download directory, set tags and add to
|
49
|
+
* To get (download to download directory, set tags and add to iTunes library) your last like
|
50
50
|
|
51
51
|
`nehm get like`
|
52
52
|
|
@@ -72,7 +72,7 @@ Go to usage for further instructions
|
|
72
72
|
|
73
73
|
*(if you type `to current`, nehm will get track to current working directory)*
|
74
74
|
|
75
|
-
* To get tracks to another playlist
|
75
|
+
* To get tracks to another iTunes playlist
|
76
76
|
|
77
77
|
`nehm get post playlist MyPlaylist`
|
78
78
|
|
@@ -84,7 +84,7 @@ Go to usage for further instructions
|
|
84
84
|
|
85
85
|
`nehm dl https://soundcloud.com/nasa/delta-iv-launch`
|
86
86
|
|
87
|
-
* Also, you can configure nehm (change download directory,
|
87
|
+
* Also, you can configure nehm (change download directory, permalink)
|
88
88
|
|
89
89
|
`nehm configure`
|
90
90
|
|
data/lib/nehm.rb
CHANGED
@@ -3,7 +3,7 @@ require 'paint'
|
|
3
3
|
|
4
4
|
require 'nehm/applescript'
|
5
5
|
require 'nehm/artwork'
|
6
|
-
require 'nehm/
|
6
|
+
require 'nehm/cfg'
|
7
7
|
require 'nehm/configure'
|
8
8
|
require 'nehm/client'
|
9
9
|
require 'nehm/get'
|
@@ -45,15 +45,12 @@ module App
|
|
45
45
|
def init
|
46
46
|
puts Paint['Hello!', :green]
|
47
47
|
puts 'Before using the nehm, you should set it up:'
|
48
|
-
|
48
|
+
Cfg.create unless Cfg.exist?
|
49
49
|
|
50
50
|
PathControl.set_dl_path
|
51
51
|
puts "\n"
|
52
52
|
|
53
53
|
unless OS.linux?
|
54
|
-
PathControl.set_itunes_path_to_default
|
55
|
-
puts "\n"
|
56
|
-
|
57
54
|
PlaylistControl.set_playlist
|
58
55
|
puts "\n"
|
59
56
|
end
|
data/lib/nehm/applescript.rb
CHANGED
@@ -8,10 +8,14 @@ module AppleScript
|
|
8
8
|
output.chomp.split(', ')
|
9
9
|
end
|
10
10
|
|
11
|
+
def self.music_master_library
|
12
|
+
`osascript #{script_path(:music_master_library)}`
|
13
|
+
end
|
14
|
+
|
11
15
|
module_function
|
12
16
|
|
13
17
|
def script_path(script_name)
|
14
|
-
applescripts_path = File.expand_path(
|
18
|
+
applescripts_path = File.expand_path(File.join(File.dirname(__FILE__), "applescripts"))
|
15
19
|
File.join(applescripts_path, "#{script_name.to_s}.applescript")
|
16
20
|
end
|
17
21
|
end
|
data/lib/nehm/configure.rb
CHANGED
@@ -2,27 +2,9 @@
|
|
2
2
|
module Configure
|
3
3
|
def self.menu
|
4
4
|
loop do
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
['iTunes path', PathControl.itunes_root_path, :magenta],
|
9
|
-
['iTunes playlist', PlaylistControl.playlist, :cyan]]
|
10
|
-
|
11
|
-
options.each do |option|
|
12
|
-
# option[0] - name
|
13
|
-
# option[1] - value
|
14
|
-
# option[2] - color
|
15
|
-
output << option[0] + ': '
|
16
|
-
output <<
|
17
|
-
unless option[1].nil? && option[1].to_s.empty?
|
18
|
-
Paint[option[1], option[2]]
|
19
|
-
else
|
20
|
-
Paint["doesn't set up", 'gold']
|
21
|
-
end
|
22
|
-
output << "\n"
|
23
|
-
end
|
24
|
-
|
25
|
-
puts output
|
5
|
+
puts 'Download path: ' + Paint[Cfg[:dl_path], :magenta]
|
6
|
+
puts 'Permalink: ' + Paint[Cfg[:permalink], :cyan]
|
7
|
+
puts 'iTunes playlist: ' + Paint[PlaylistControl.playlist, :cyan] unless OS.linux?
|
26
8
|
puts "\n"
|
27
9
|
|
28
10
|
HighLine.new.choose do |menu|
|
@@ -30,7 +12,6 @@ module Configure
|
|
30
12
|
|
31
13
|
menu.choice('Edit download path'.freeze) { PathControl.set_dl_path }
|
32
14
|
menu.choice('Edit permalink'.freeze) { UserControl.log_in }
|
33
|
-
menu.choice('Edit iTunes path'.freeze) { PathControl.set_itunes_path } unless OS.linux?
|
34
15
|
menu.choice('Edit iTunes playlist'.freeze) { PlaylistControl.set_playlist } unless OS.linux?
|
35
16
|
menu.choice('Exit'.freeze) { puts 'Goodbye!'; exit }
|
36
17
|
end
|
data/lib/nehm/get.rb
CHANGED
@@ -46,32 +46,13 @@ module Get
|
|
46
46
|
exit
|
47
47
|
end
|
48
48
|
|
49
|
-
# Check if iTunes path set up
|
50
|
-
if !PathControl.itunes_path && get_or_dl == :get && !OS.linux?
|
51
|
-
puts Paint["You don't set up iTunes path!", :yellow]
|
52
|
-
puts "Your track won't add to iTunes library"
|
53
|
-
itunes_set_up = false
|
54
|
-
else
|
55
|
-
itunes_set_up = true
|
56
|
-
end
|
57
|
-
|
58
|
-
# Check if iTunes playlist set up
|
59
49
|
playlist = PlaylistControl.playlist
|
60
|
-
if !playlist && !playlist.to_s.empty? && get_or_dl == :get && !OS.linux?
|
61
|
-
puts Paint["You don't set up iTunes playlist!", :yellow]
|
62
|
-
puts "Your track won't add to iTunes playlist"
|
63
|
-
end
|
64
|
-
|
65
50
|
tracks.each do |track|
|
66
51
|
dl(track)
|
67
52
|
dl(track.artwork)
|
68
53
|
tag(track)
|
69
|
-
if itunes_set_up && !OS.linux? && get_or_dl == :get
|
70
|
-
cp(track)
|
71
|
-
wait_while_itunes_add_track_to_lib(track) unless playlist.to_s.empty?
|
72
|
-
playlist.add_track(track.file_path) unless playlist.to_s.empty?
|
73
|
-
end
|
74
54
|
track.artwork.suicide
|
55
|
+
playlist.add_track(track.file_path) if playlist && get_or_dl == :get && !OS.linux?
|
75
56
|
end
|
76
57
|
puts Paint['Done!', :green]
|
77
58
|
end
|
@@ -111,16 +92,4 @@ module Get
|
|
111
92
|
file.save
|
112
93
|
end
|
113
94
|
end
|
114
|
-
|
115
|
-
def cp(track)
|
116
|
-
puts 'Adding to iTunes library'
|
117
|
-
FileUtils.cp(track.file_path, PathControl.itunes_path)
|
118
|
-
end
|
119
|
-
|
120
|
-
# Check when iTunes will add track to its library from 'Auto' directory
|
121
|
-
def wait_while_itunes_add_track_to_lib(track)
|
122
|
-
loop do
|
123
|
-
break unless File.exist?(File.join(PathControl.itunes_path, track.file_name))
|
124
|
-
end
|
125
|
-
end
|
126
95
|
end
|
data/lib/nehm/help.rb
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
module Help
|
3
3
|
def self.available_commands
|
4
4
|
puts Paint['Avalaible nehm commands:', :yellow]
|
5
|
-
puts ' ' + Paint['get', :green]
|
6
|
-
puts ' ' + Paint['dl', :green]
|
7
|
-
puts ' ' + Paint['configure', :green] + '
|
5
|
+
puts ' ' + Paint['get', :green] + ' Downloading, setting tags and adding to your iTunes library last post or like from your profile'
|
6
|
+
puts ' ' + Paint['dl', :green] + ' Downloading and setting tags last post or like from your profile'
|
7
|
+
puts ' ' + Paint['configure', :green] + ' Configuring application'
|
8
8
|
puts "See #{Paint['nehm help [command]', :yellow]} to read about a specific subcommand"
|
9
9
|
end
|
10
10
|
|
data/lib/nehm/path_control.rb
CHANGED
@@ -17,12 +17,15 @@ module PathControl
|
|
17
17
|
end
|
18
18
|
|
19
19
|
path = HighLine.new.ask(path_ask + ':')
|
20
|
+
|
21
|
+
# If user press enter (set path to default)
|
20
22
|
path = default_path if path == '' && default_path
|
21
23
|
|
24
|
+
# If tilde at top of the line of path
|
22
25
|
path = PathControl.tilde_to_home(path) if PathControl.tilde_at_top?(path)
|
23
26
|
|
24
27
|
if Dir.exist?(path)
|
25
|
-
|
28
|
+
Cfg[:dl_path] = path
|
26
29
|
puts Paint["Download directory set up to #{Paint[path, :magenta]}", :green]
|
27
30
|
break
|
28
31
|
else
|
@@ -46,52 +49,6 @@ module PathControl
|
|
46
49
|
end
|
47
50
|
end
|
48
51
|
|
49
|
-
def self.itunes_path
|
50
|
-
Config[:itunes_path]
|
51
|
-
end
|
52
|
-
|
53
|
-
# Use in Configure.menu
|
54
|
-
def self.itunes_root_path
|
55
|
-
PathControl.itunes_path.sub("/iTunes\ Media/Automatically\ Add\ to\ iTunes.localized", '')
|
56
|
-
end
|
57
|
-
|
58
|
-
def self.set_itunes_path
|
59
|
-
loop do
|
60
|
-
default_path = File.join(ENV['HOME'], '/Music/iTunes')
|
61
|
-
path_ask = 'Enter path to iTunes directory'
|
62
|
-
|
63
|
-
if Dir.exist?(default_path)
|
64
|
-
path_ask << " (press enter to set it to #{Paint[default_path, :magenta]})"
|
65
|
-
else
|
66
|
-
default_path = nil
|
67
|
-
end
|
68
|
-
|
69
|
-
path = HighLine.new.ask(path_ask + ':')
|
70
|
-
path = default_path if path == '' && default_path
|
71
|
-
|
72
|
-
path = PathControl.tilde_to_home(path) if PathControl.tilde_at_top?(path)
|
73
|
-
|
74
|
-
path = File.join(path, "iTunes\ Media/Automatically\ Add\ to\ iTunes.localized")
|
75
|
-
|
76
|
-
if Dir.exist?(path)
|
77
|
-
Config[:itunes_path] = path
|
78
|
-
puts Paint["iTunes directory set up to #{Paint[PathControl.itunes_root_path, :magenta]}", :green]
|
79
|
-
break
|
80
|
-
else
|
81
|
-
puts Paint["This directory doesn't exist. Please enter correct path", :red]
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
def self.set_itunes_path_to_default
|
87
|
-
itunes_path = File.join(ENV['HOME'], "/Music/iTunes/iTunes\ Media/Automatically\ Add\ to\ iTunes.localized")
|
88
|
-
if Dir.exist?(itunes_path)
|
89
|
-
Config[:itunes_path] = itunes_path
|
90
|
-
else
|
91
|
-
puts Paint["Don't know where your iTunes path. Set it up manually from ", 'gold'] + Paint['nehm configure', :yellow]
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
52
|
def self.tilde_to_home(path)
|
96
53
|
File.join(ENV['HOME'], path[1..-1])
|
97
54
|
end
|
@@ -103,8 +60,8 @@ module PathControl
|
|
103
60
|
module_function
|
104
61
|
|
105
62
|
def default_dl_path
|
106
|
-
if
|
107
|
-
|
63
|
+
if Cfg[:dl_path]
|
64
|
+
Cfg[:dl_path]
|
108
65
|
else
|
109
66
|
puts Paint["You don't set up download path!", :red]
|
110
67
|
puts "Set it up from #{Paint['nehm configure', :yellow]} or use #{Paint['[to PATH_TO_DIRECTORY]', :yellow]} option"
|
data/lib/nehm/playlist.rb
CHANGED
@@ -1,23 +1,19 @@
|
|
1
1
|
module PlaylistControl
|
2
2
|
def self.playlist
|
3
|
-
|
4
|
-
@temp_playlist
|
5
|
-
elsif !Config[:playlist].nil?
|
6
|
-
Playlist.new(Config[:playlist])
|
7
|
-
end
|
3
|
+
@temp_playlist || default_user_playlist || music_master_library
|
8
4
|
end
|
9
5
|
|
10
6
|
def self.set_playlist
|
11
7
|
loop do
|
12
8
|
playlist = HighLine.new.ask('Enter name of default iTunes playlist to which you want add tracks (press Enter to unset default playlist)')
|
13
9
|
if playlist == ''
|
14
|
-
|
10
|
+
Cfg[:playlist] = nil
|
15
11
|
puts Paint['Default iTunes playlist unset', :green]
|
16
12
|
break
|
17
13
|
end
|
18
14
|
|
19
15
|
if AppleScript.list_of_playlists.include? playlist
|
20
|
-
|
16
|
+
Cfg[:playlist] = playlist
|
21
17
|
puts Paint["Default iTunes playlist set up to #{playlist}", :green]
|
22
18
|
break
|
23
19
|
else
|
@@ -34,4 +30,14 @@ module PlaylistControl
|
|
34
30
|
exit
|
35
31
|
end
|
36
32
|
end
|
33
|
+
|
34
|
+
module_function
|
35
|
+
|
36
|
+
def default_user_playlist
|
37
|
+
Playlist.new(Cfg[:playlist]) unless Cfg[:playlist].nil?
|
38
|
+
end
|
39
|
+
|
40
|
+
def music_master_library
|
41
|
+
Playlist.new(AppleScript.music_master_library)
|
42
|
+
end
|
37
43
|
end
|
data/lib/nehm/user_control.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module UserControl
|
2
2
|
|
3
3
|
def self.logged_in?
|
4
|
-
|
4
|
+
Cfg.key?(:default_id)
|
5
5
|
end
|
6
6
|
|
7
7
|
def self.log_in
|
@@ -10,8 +10,8 @@ module UserControl
|
|
10
10
|
url = "https://soundcloud.com/#{permalink}"
|
11
11
|
if user_exist?(permalink)
|
12
12
|
user = Client.get('/resolve', url: url)
|
13
|
-
|
14
|
-
|
13
|
+
Cfg[:default_id] = user.id
|
14
|
+
Cfg[:permalink] = permalink
|
15
15
|
puts Paint['Successfully logged in!', :green]
|
16
16
|
break
|
17
17
|
else
|
@@ -38,7 +38,7 @@ module UserControl
|
|
38
38
|
|
39
39
|
def default_user
|
40
40
|
if UserControl.logged_in?
|
41
|
-
User.new(
|
41
|
+
User.new(Cfg[:default_id])
|
42
42
|
else
|
43
43
|
puts Paint["You didn't logged in", :red]
|
44
44
|
puts "Login from #{Paint['nehm configure', :yellow]} or use #{Paint['[from PERMALINK]', :yellow]} option"
|
data/lib/nehm/version.rb
CHANGED
data/nehm.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.bindir = 'bin'
|
19
19
|
spec.executables = 'nehm'
|
20
20
|
spec.require_paths = ['lib']
|
21
|
-
spec.required_ruby_version = '>=
|
21
|
+
spec.required_ruby_version = '>= 1.9.3'
|
22
22
|
|
23
23
|
spec.add_dependency 'soundcloud', '>= 0.3.2'
|
24
24
|
spec.add_dependency 'taglib-ruby', '>= 0.7.0'
|
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.
|
4
|
+
version: '1.5'
|
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-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: soundcloud
|
@@ -115,9 +115,10 @@ files:
|
|
115
115
|
- lib/nehm/applescript.rb
|
116
116
|
- lib/nehm/applescripts/add_track_to_playlist.applescript
|
117
117
|
- lib/nehm/applescripts/list_of_playlists.applescript
|
118
|
+
- lib/nehm/applescripts/music_master_library.applescript
|
118
119
|
- lib/nehm/artwork.rb
|
120
|
+
- lib/nehm/cfg.rb
|
119
121
|
- lib/nehm/client.rb
|
120
|
-
- lib/nehm/config.rb
|
121
122
|
- lib/nehm/configure.rb
|
122
123
|
- lib/nehm/get.rb
|
123
124
|
- lib/nehm/help.rb
|
@@ -142,7 +143,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
142
143
|
requirements:
|
143
144
|
- - ">="
|
144
145
|
- !ruby/object:Gem::Version
|
145
|
-
version:
|
146
|
+
version: 1.9.3
|
146
147
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
147
148
|
requirements:
|
148
149
|
- - ">="
|