audio_addict 0.4.1 → 0.4.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/bin/radio +8 -12
- data/lib/audio_addict/api.rb +12 -11
- data/lib/audio_addict/cache.rb +2 -2
- data/lib/audio_addict/channel.rb +12 -9
- data/lib/audio_addict/cli.rb +12 -12
- data/lib/audio_addict/commands/api.rb +14 -13
- data/lib/audio_addict/commands/base.rb +3 -3
- data/lib/audio_addict/commands/channels.rb +23 -23
- data/lib/audio_addict/commands/config.rb +57 -57
- data/lib/audio_addict/commands/download.rb +20 -19
- data/lib/audio_addict/commands/history.rb +6 -6
- data/lib/audio_addict/commands/log.rb +37 -35
- data/lib/audio_addict/commands/login.rb +11 -11
- data/lib/audio_addict/commands/now.rb +5 -5
- data/lib/audio_addict/commands/playlist.rb +25 -24
- data/lib/audio_addict/commands/set.rb +24 -22
- data/lib/audio_addict/commands/vote.rb +32 -32
- data/lib/audio_addict/config.rb +7 -3
- data/lib/audio_addict/exceptions.rb +2 -2
- data/lib/audio_addict/extensions/file.rb +18 -14
- data/lib/audio_addict/inspectable.rb +2 -2
- data/lib/audio_addict/log.rb +2 -2
- data/lib/audio_addict/radio.rb +19 -19
- data/lib/audio_addict/track.rb +5 -4
- data/lib/audio_addict/version.rb +1 -1
- data/lib/audio_addict/youtube.rb +6 -4
- data/lib/audio_addict.rb +8 -8
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1bfa79e76c8667fc213082f955d753693b2f81f1857e82ac610d6b8db960ffb4
|
4
|
+
data.tar.gz: eb1b970c1eee32668eea5deee9c9b9d9658801451399fb55734870d0a995a5ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3fa5acfa2d77638568b0fa54ccd2e69a88e535fe30d2b8a35ba090b40a1aaae4ee68a1e3bf82eef38cbf751b4e2000dfec0b782a89634eb310bd65653354c003
|
7
|
+
data.tar.gz: 5547a8ab8c783357bb801bcc222b7f65dfadad970b4ded6bf623723651ad5e7c6b18379e624ace46af55d71f9460e8b74f6d973a5f57b811674f01d1a92e73ef
|
data/bin/radio
CHANGED
@@ -7,28 +7,24 @@ router = AudioAddict::CLI.router
|
|
7
7
|
|
8
8
|
begin
|
9
9
|
exit router.run ARGV
|
10
|
-
|
11
10
|
rescue Interrupt, AudioAddict::Interrupt, TTY::Reader::InputInterrupt
|
12
11
|
say "\nGoodbye"
|
13
|
-
exit 1
|
14
|
-
|
12
|
+
exit 1
|
15
13
|
rescue AudioAddict::ConfigError => e
|
16
|
-
say
|
14
|
+
say '!undred!ERROR: Missing Configuration Values'
|
17
15
|
say "#{e.message}:"
|
18
16
|
e.missing_keys.each do |key|
|
19
17
|
say "- !txtblu!#{key}"
|
20
18
|
end
|
21
|
-
say
|
22
|
-
say
|
23
|
-
exit 1
|
24
|
-
|
19
|
+
say ''
|
20
|
+
say 'Run !txtpur!radio config guide!txtrst! for more information'
|
21
|
+
exit 1
|
25
22
|
rescue => e
|
26
23
|
if ENV['DEBUG']
|
27
|
-
puts e.backtrace.reverse
|
28
|
-
say
|
24
|
+
puts e.backtrace.reverse
|
25
|
+
say ''
|
29
26
|
end
|
30
27
|
say "!undred!ERROR: #{e.class}"
|
31
28
|
say e.message
|
32
29
|
exit 1
|
33
|
-
|
34
|
-
end
|
30
|
+
end
|
data/lib/audio_addict/api.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
require
|
1
|
+
require 'httparty'
|
2
2
|
|
3
3
|
module AudioAddict
|
4
4
|
class API
|
5
5
|
include HTTParty
|
6
6
|
include Cache
|
7
7
|
|
8
|
-
base_uri
|
8
|
+
base_uri 'https://api.audioaddict.com/v1'
|
9
9
|
debug_output $stderr if ENV['AUDIO_ADDICT_DEBUG']
|
10
10
|
|
11
11
|
attr_accessor :network
|
@@ -16,10 +16,10 @@ module AudioAddict
|
|
16
16
|
|
17
17
|
def login(username, password)
|
18
18
|
session = session(username, password)
|
19
|
-
Config.session_key = session[
|
20
|
-
Config.listen_key = session[
|
21
|
-
Config.email = session[
|
22
|
-
Config.premium = session[
|
19
|
+
Config.session_key = session['key']
|
20
|
+
Config.listen_key = session['member']['listen_key']
|
21
|
+
Config.email = session['member']['email']
|
22
|
+
Config.premium = session['member']['user_type'] == 'premium'
|
23
23
|
Config.save
|
24
24
|
end
|
25
25
|
|
@@ -40,13 +40,13 @@ module AudioAddict
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def basic_auth
|
43
|
-
http.basic_auth
|
43
|
+
http.basic_auth 'streams', 'diradio'
|
44
44
|
end
|
45
45
|
|
46
46
|
def session(username, password)
|
47
47
|
params = { member_session: { username: username, password: password } }
|
48
48
|
basic_auth
|
49
|
-
response http.post "/#{network ||
|
49
|
+
response http.post "/#{network || 'di'}/member_sessions", body: params
|
50
50
|
end
|
51
51
|
|
52
52
|
def session_key
|
@@ -57,10 +57,11 @@ module AudioAddict
|
|
57
57
|
Config.listen_key
|
58
58
|
end
|
59
59
|
|
60
|
-
|
60
|
+
private
|
61
61
|
|
62
62
|
def response(httparty_response)
|
63
|
-
raise APIError
|
63
|
+
raise APIError, httparty_response unless httparty_response.success?
|
64
|
+
|
64
65
|
JSON.parse httparty_response.body
|
65
66
|
end
|
66
67
|
|
@@ -69,7 +70,7 @@ module AudioAddict
|
|
69
70
|
end
|
70
71
|
|
71
72
|
def headers
|
72
|
-
{
|
73
|
+
{ 'X-Session-Key' => session_key }
|
73
74
|
end
|
74
75
|
end
|
75
76
|
end
|
data/lib/audio_addict/cache.rb
CHANGED
data/lib/audio_addict/channel.rb
CHANGED
@@ -7,19 +7,21 @@ module AudioAddict
|
|
7
7
|
attr_reader :radio
|
8
8
|
|
9
9
|
def initialize(radio, properties)
|
10
|
-
@radio
|
10
|
+
@radio = radio
|
11
|
+
@properties = properties
|
11
12
|
end
|
12
13
|
|
13
14
|
def inspectable
|
14
|
-
[
|
15
|
+
%i[key name id]
|
15
16
|
end
|
16
17
|
|
17
18
|
def active?
|
18
19
|
# Seems like each network has a different way of marking inactive channels.
|
19
20
|
# This is where we normalize it
|
20
|
-
return false
|
21
|
-
return false if name[0] ==
|
22
|
-
|
21
|
+
return false unless properties['asset_id']
|
22
|
+
return false if (name[0] == 'X') && (key[0] != 'x')
|
23
|
+
|
24
|
+
true
|
23
25
|
end
|
24
26
|
|
25
27
|
def track_history
|
@@ -36,9 +38,10 @@ module AudioAddict
|
|
36
38
|
end
|
37
39
|
|
38
40
|
def similar_channels
|
39
|
-
similar = properties[
|
41
|
+
similar = properties['similar_channels']
|
40
42
|
return [] unless similar
|
41
|
-
|
43
|
+
|
44
|
+
ids = similar.map { |s| s['similar_channel_id'] }
|
42
45
|
radio.search_by_id ids
|
43
46
|
end
|
44
47
|
|
@@ -52,10 +55,10 @@ module AudioAddict
|
|
52
55
|
radio.api.post "#{endpoint}/#{direction}"
|
53
56
|
end
|
54
57
|
|
55
|
-
log_like track if direction == :up
|
58
|
+
log_like track if (direction == :up) && Config.like_log
|
56
59
|
end
|
57
60
|
|
58
|
-
|
61
|
+
private
|
59
62
|
|
60
63
|
def log_like(track = nil)
|
61
64
|
track ||= current_track
|
data/lib/audio_addict/cli.rb
CHANGED
@@ -2,19 +2,19 @@ module AudioAddict
|
|
2
2
|
class CLI
|
3
3
|
def self.router
|
4
4
|
router = MisterBin::Runner.new version: VERSION,
|
5
|
-
header:
|
5
|
+
header: 'AudioAddict Radio Utilities'
|
6
6
|
|
7
|
-
router.route
|
8
|
-
router.route
|
9
|
-
router.route
|
10
|
-
router.route
|
11
|
-
router.route
|
12
|
-
router.route
|
13
|
-
router.route
|
14
|
-
router.route
|
15
|
-
router.route
|
16
|
-
router.route
|
17
|
-
router.route
|
7
|
+
router.route 'login', to: Commands::LoginCmd
|
8
|
+
router.route 'set', to: Commands::SetCmd
|
9
|
+
router.route 'channels', to: Commands::ChannelsCmd
|
10
|
+
router.route 'now', to: Commands::NowCmd
|
11
|
+
router.route 'history', to: Commands::HistoryCmd
|
12
|
+
router.route 'vote', to: Commands::VoteCmd
|
13
|
+
router.route 'playlist', to: Commands::PlaylistCmd
|
14
|
+
router.route 'config', to: Commands::ConfigCmd
|
15
|
+
router.route 'log', to: Commands::LogCmd
|
16
|
+
router.route 'download', to: Commands::DownloadCmd
|
17
|
+
router.route 'api', to: Commands::APICmd
|
18
18
|
|
19
19
|
router
|
20
20
|
end
|
@@ -1,18 +1,18 @@
|
|
1
1
|
module AudioAddict
|
2
2
|
module Commands
|
3
3
|
class APICmd < Base
|
4
|
-
summary
|
4
|
+
summary 'Make direct calls to the AudioAddict API'
|
5
5
|
|
6
|
-
help
|
6
|
+
help 'This command sends a request to the provided API endpoint. The currently configured network is automatically prepended to the endpoint path, and the output is converted to YAML format.'
|
7
7
|
|
8
|
-
usage
|
9
|
-
usage
|
8
|
+
usage 'radio api [get|post|delete] ENDPOINT'
|
9
|
+
usage 'radio api --help'
|
10
10
|
|
11
|
-
param
|
11
|
+
param 'ENDPOINT', 'API endpoint path'
|
12
12
|
|
13
|
-
example
|
14
|
-
example
|
15
|
-
example
|
13
|
+
example 'radio api channels'
|
14
|
+
example 'radio api get track_history/channel/1'
|
15
|
+
example 'radio api post tracks/1/vote/2/up'
|
16
16
|
|
17
17
|
def run
|
18
18
|
needs :network
|
@@ -20,16 +20,17 @@ module AudioAddict
|
|
20
20
|
puts response.to_yaml
|
21
21
|
end
|
22
22
|
|
23
|
-
|
23
|
+
private
|
24
24
|
|
25
25
|
def api_method
|
26
|
-
return :post if args[
|
27
|
-
return :delete if args[
|
28
|
-
|
26
|
+
return :post if args['post']
|
27
|
+
return :delete if args['delete']
|
28
|
+
|
29
|
+
:get
|
29
30
|
end
|
30
31
|
|
31
32
|
def endpoint
|
32
|
-
args[
|
33
|
+
args['ENDPOINT']
|
33
34
|
end
|
34
35
|
|
35
36
|
def api
|
@@ -1,58 +1,58 @@
|
|
1
1
|
module AudioAddict
|
2
2
|
module Commands
|
3
3
|
class ChannelsCmd < Base
|
4
|
-
summary
|
4
|
+
summary 'Show list of channels'
|
5
5
|
|
6
|
-
help
|
6
|
+
help 'This command lets you list and search for channels in the currently active radio network.'
|
7
7
|
|
8
|
-
usage
|
9
|
-
usage
|
8
|
+
usage 'radio channels [SEARCH --info]'
|
9
|
+
usage 'radio channels --help'
|
10
10
|
|
11
|
-
option
|
11
|
+
option '-i --info', 'Show results with additional info, such as channel description and related channels'
|
12
12
|
|
13
|
-
param
|
13
|
+
param 'SEARCH', 'Channel name or a partial name to search for'
|
14
14
|
|
15
|
-
example
|
16
|
-
example
|
17
|
-
example
|
18
|
-
example
|
15
|
+
example 'radio channels'
|
16
|
+
example 'radio channels --info'
|
17
|
+
example 'radio channels metal'
|
18
|
+
example 'radio channels metal -i'
|
19
19
|
|
20
20
|
def run
|
21
21
|
needs :network
|
22
22
|
|
23
23
|
say "!undgrn!#{radio.name}\n"
|
24
24
|
|
25
|
-
search = args[
|
25
|
+
search = args['SEARCH']
|
26
26
|
|
27
27
|
channels = search ? radio.search(search) : radio.channels
|
28
28
|
|
29
29
|
channels = channels.values
|
30
|
-
if args[
|
30
|
+
if args['--info']
|
31
31
|
show_verbose channels
|
32
32
|
else
|
33
33
|
show_compact channels
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
-
|
37
|
+
private
|
38
38
|
|
39
39
|
def show_verbose(channels)
|
40
40
|
channels.each do |channel|
|
41
|
-
say
|
41
|
+
say ''
|
42
42
|
say "!txtgrn!#{channel.name.ljust 22} !txtrst!# #{channel.key}"
|
43
|
-
say
|
44
|
-
say word_wrap
|
45
|
-
say
|
43
|
+
say ''
|
44
|
+
say word_wrap channel.description.to_s
|
45
|
+
say ''
|
46
46
|
|
47
47
|
similar = channel.similar_channels
|
48
48
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
say ""
|
49
|
+
next unless similar.any?
|
50
|
+
|
51
|
+
say 'Similar Channels:'
|
52
|
+
similar.each do |key, similar_channel|
|
53
|
+
say "- !txtblu!#{similar_channel.name.ljust 20}!txtrst! # #{key}"
|
55
54
|
end
|
55
|
+
say ''
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
@@ -1,57 +1,57 @@
|
|
1
1
|
module AudioAddict
|
2
2
|
module Commands
|
3
3
|
class ConfigCmd < Base
|
4
|
-
summary
|
5
|
-
|
6
|
-
help
|
7
|
-
|
8
|
-
usage
|
9
|
-
usage
|
10
|
-
usage
|
11
|
-
usage
|
12
|
-
usage
|
13
|
-
usage
|
14
|
-
usage
|
15
|
-
usage
|
16
|
-
|
17
|
-
param
|
18
|
-
param
|
19
|
-
|
20
|
-
option
|
21
|
-
option
|
22
|
-
|
23
|
-
command
|
24
|
-
command
|
25
|
-
command
|
26
|
-
command
|
27
|
-
command
|
28
|
-
command
|
29
|
-
command
|
30
|
-
|
31
|
-
example
|
32
|
-
example
|
33
|
-
example
|
34
|
-
example
|
4
|
+
summary 'Manage local configuration'
|
5
|
+
|
6
|
+
help 'This command provides low level access to your local configuration file.'
|
7
|
+
|
8
|
+
usage 'radio config set KEY VALUE'
|
9
|
+
usage 'radio config get KEY'
|
10
|
+
usage 'radio config del KEY'
|
11
|
+
usage 'radio config show'
|
12
|
+
usage 'radio config edit'
|
13
|
+
usage 'radio config check'
|
14
|
+
usage 'radio config guide'
|
15
|
+
usage 'radio config --help'
|
16
|
+
|
17
|
+
param 'KEY', 'Config key'
|
18
|
+
param 'VALUE', 'Config value'
|
19
|
+
|
20
|
+
option '-s --show', 'Show the contents of the config file'
|
21
|
+
option '-e --edit', 'Open the config file for editing'
|
22
|
+
|
23
|
+
command 'get', 'Show the value of this config key'
|
24
|
+
command 'set', 'Set the value of this config key'
|
25
|
+
command 'del', 'Delete the value of this config key'
|
26
|
+
command 'show', 'Show the entire config file contents'
|
27
|
+
command 'edit', 'Open the config file for editing'
|
28
|
+
command 'guide', 'Show a list of supported config keys and their purpose'
|
29
|
+
command 'check', 'Verify and report problems with the config file'
|
30
|
+
|
31
|
+
example 'radio config edit'
|
32
|
+
example 'radio config set like_log ~/like.log'
|
33
|
+
example 'radio config del session_key'
|
34
|
+
example 'radio config get listen_key'
|
35
35
|
|
36
36
|
def get_command
|
37
|
-
key = args[
|
37
|
+
key = args['KEY'].to_sym
|
38
38
|
value = Config.properties[key]
|
39
|
-
say value ? "!txtgrn!#{value}" :
|
39
|
+
say value ? "!txtgrn!#{value}" : '!txtred!<Unset>'
|
40
40
|
end
|
41
41
|
|
42
42
|
def set_command
|
43
|
-
key = args[
|
44
|
-
value = args[
|
43
|
+
key = args['KEY'].to_sym
|
44
|
+
value = args['VALUE']
|
45
45
|
Config.properties[key] = value
|
46
46
|
Config.save
|
47
47
|
say "!txtgrn!#{key}=#{value}"
|
48
48
|
end
|
49
49
|
|
50
50
|
def del_command
|
51
|
-
key = args[
|
51
|
+
key = args['KEY'].to_sym
|
52
52
|
Config.delete key
|
53
53
|
Config.save
|
54
|
-
say
|
54
|
+
say '!txtgrn!Deleted'
|
55
55
|
end
|
56
56
|
|
57
57
|
def show_command
|
@@ -59,12 +59,12 @@ module AudioAddict
|
|
59
59
|
if File.exist? Config.path
|
60
60
|
puts File.read Config.path
|
61
61
|
else
|
62
|
-
say
|
62
|
+
say '!txtred!File Not Found'
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
66
|
def edit_command
|
67
|
-
editor = ENV[
|
67
|
+
editor = ENV['EDITOR'] || 'vi'
|
68
68
|
system "#{editor} #{Config.path}"
|
69
69
|
end
|
70
70
|
|
@@ -72,7 +72,7 @@ module AudioAddict
|
|
72
72
|
key_guide.each do |key, value|
|
73
73
|
say "!txtgrn!#{key}"
|
74
74
|
say word_wrap " #{value}"
|
75
|
-
say
|
75
|
+
say ''
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
@@ -81,17 +81,17 @@ module AudioAddict
|
|
81
81
|
warnings = verify_and_show_keys optional_keys
|
82
82
|
|
83
83
|
say "Done. #{errors} errors, #{warnings} warnings."
|
84
|
-
errors
|
84
|
+
errors.positive? ? 1 : 0
|
85
85
|
end
|
86
86
|
|
87
|
-
|
87
|
+
private
|
88
88
|
|
89
89
|
def verify_and_show_keys(keys, critical: false)
|
90
90
|
problems = 0
|
91
|
-
prefix = critical ?
|
91
|
+
prefix = critical ? '!txtred!Error !txtrst!' : '!txtylw!Warning!txtrst!'
|
92
92
|
|
93
93
|
keys.each do |key, command|
|
94
|
-
|
94
|
+
unless Config.has_key? key
|
95
95
|
problems += 1
|
96
96
|
say "#{prefix} : Key !txtgrn!#{key}!txtrst! is not set. Fix with !txtpur!radio #{command}!txtrst!."
|
97
97
|
end
|
@@ -102,30 +102,30 @@ module AudioAddict
|
|
102
102
|
|
103
103
|
def key_guide
|
104
104
|
{
|
105
|
-
email:
|
105
|
+
email: "Last email used for logging in.\nUsually set with !txtpur!radio login!txtrst!.",
|
106
106
|
session_key: "Used for authentication.\nUsually set with !txtpur!radio login!txtrst!.",
|
107
|
-
listen_key:
|
108
|
-
network:
|
109
|
-
channel:
|
110
|
-
like_log:
|
111
|
-
cache_dir:
|
112
|
-
cache_life:
|
107
|
+
listen_key: "Used for generating playlists.\nUsually set with !txtpur!radio login!txtrst!.",
|
108
|
+
network: "Specify the AudioAddict network you are currently listening to.\nUsually set with !txtpur!radio set!txtrst!.",
|
109
|
+
channel: "Specify the AudioAddict channel you are currently listening to.\nUsually set with !txtpur!radio set!txtrst!.",
|
110
|
+
like_log: "Specify the path to store all your positive votes.\nIf this is not set, votes will only be sent to AudioAddict and not logged locally.",
|
111
|
+
cache_dir: "Specify the path to store API response cache.\nDefault: ~/.audio_addict/cache",
|
112
|
+
cache_life: "Specify the cache life period.\nDefault: 6h.",
|
113
113
|
}
|
114
114
|
end
|
115
115
|
|
116
116
|
def required_keys
|
117
117
|
{
|
118
|
-
email:
|
119
|
-
session_key:
|
120
|
-
listen_key:
|
121
|
-
network:
|
122
|
-
channel:
|
118
|
+
email: 'login',
|
119
|
+
session_key: 'login',
|
120
|
+
listen_key: 'login',
|
121
|
+
network: 'set',
|
122
|
+
channel: 'set',
|
123
123
|
}
|
124
124
|
end
|
125
125
|
|
126
126
|
def optional_keys
|
127
127
|
{
|
128
|
-
like_log:
|
128
|
+
like_log: 'config set like_log PATH',
|
129
129
|
}
|
130
130
|
end
|
131
131
|
end
|
@@ -1,35 +1,36 @@
|
|
1
1
|
module AudioAddict
|
2
2
|
module Commands
|
3
3
|
class DownloadCmd < Base
|
4
|
-
summary
|
4
|
+
summary 'Download songs from YouTube'
|
5
5
|
|
6
|
-
help
|
6
|
+
help 'This command uses youtube-dl to download the currently playing song, or songs from your like-log.'
|
7
7
|
|
8
|
-
usage
|
9
|
-
usage
|
10
|
-
usage
|
11
|
-
usage
|
8
|
+
usage 'radio download current [--count N]'
|
9
|
+
usage 'radio download log [--lines N --count N]'
|
10
|
+
usage 'radio download search QUERY [--count N]'
|
11
|
+
usage 'radio download --help'
|
12
12
|
|
13
|
-
option
|
14
|
-
option
|
13
|
+
option '-l --lines N', 'Number of log lines to download [default: 1]'
|
14
|
+
option '-c --count N',
|
15
|
+
"Number of YouTube search results to download\nDefaults to the value of the AUDIO_ADDICT_DOWNLOAD_COUNT environment variable, or 1"
|
15
16
|
|
16
|
-
param
|
17
|
+
param 'QUERY', 'YouTube search query'
|
17
18
|
|
18
|
-
command
|
19
|
-
command
|
20
|
-
command
|
19
|
+
command 'current', 'Download the currently playing song'
|
20
|
+
command 'log', 'Download the last N songs from the like-log'
|
21
|
+
command 'search', 'Download any song matching the Youtube search query'
|
21
22
|
|
22
|
-
environment
|
23
|
+
environment 'AUDIO_ADDICT_DOWNLOAD_COUNT', 'Set the default download count (--count)'
|
23
24
|
|
24
|
-
example
|
25
|
-
example
|
26
|
-
example
|
25
|
+
example 'radio download current'
|
26
|
+
example 'radio download current --count 3'
|
27
|
+
example 'radio download log --lines 2 --count 3'
|
27
28
|
example "radio download search 'Brimstone, Bright Shadow' -c2"
|
28
29
|
|
29
30
|
def current_command
|
30
31
|
needs :network, :channel
|
31
32
|
|
32
|
-
say
|
33
|
+
say '!txtblu!Downloading !txtrst!: ... '
|
33
34
|
|
34
35
|
track = current_channel.current_track
|
35
36
|
query = track.search_string
|
@@ -43,9 +44,9 @@ module AudioAddict
|
|
43
44
|
needs :like_log
|
44
45
|
lines = args['--lines']&.to_i
|
45
46
|
|
46
|
-
data = log.data[-lines
|
47
|
+
data = log.data[-lines..]
|
47
48
|
data.each do |line|
|
48
|
-
|
49
|
+
_network, _channel, artist, song = line.split(' :: ')
|
49
50
|
query = "#{artist}, #{song}"
|
50
51
|
say "\n!txtblu!Downloading !txtgrn!: #{query}"
|
51
52
|
Youtube.new(query).get count
|
@@ -1,23 +1,23 @@
|
|
1
1
|
module AudioAddict
|
2
2
|
module Commands
|
3
3
|
class HistoryCmd < Base
|
4
|
-
summary
|
4
|
+
summary 'Show track history for the current channel'
|
5
5
|
|
6
|
-
help
|
6
|
+
help 'This command shows the last few tracks that were playing on the currently active channel in reverse order (top track is the most recent).'
|
7
7
|
|
8
|
-
usage
|
9
|
-
usage
|
8
|
+
usage 'radio history'
|
9
|
+
usage 'radio history --help'
|
10
10
|
|
11
11
|
def run
|
12
12
|
needs :network, :channel
|
13
13
|
say "!undgrn!#{radio.name} > #{current_channel.name}"
|
14
|
-
say
|
14
|
+
say ''
|
15
15
|
tracks.each do |track|
|
16
16
|
say "!txtgrn! #{track.artist.rjust max_artist_len}!txtrst! : !txtblu!#{track.title}"
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
|
20
|
+
private
|
21
21
|
|
22
22
|
def tracks
|
23
23
|
@tracks ||= current_channel.track_history
|