audio_addict 0.1.4 → 0.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/README.md +1 -1
- data/bin/radio +1 -0
- data/lib/audio_addict/channel.rb +10 -3
- data/lib/audio_addict/commands/channels.rb +36 -2
- data/lib/audio_addict/commands/history.rb +2 -2
- data/lib/audio_addict/commands/log.rb +10 -2
- data/lib/audio_addict/commands/now.rb +1 -1
- data/lib/audio_addict/commands/vote.rb +56 -19
- data/lib/audio_addict/radio.rb +5 -0
- data/lib/audio_addict/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 463dda325c6bd171a44438bea714b4f0058ddc3c34cf5a5cd8cba93d32bf278a
|
4
|
+
data.tar.gz: 0643c29d7061962195bb97aff3db432b8d79d766c9ac31c94edca328742ad53b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf473be5bba0733b671697664c51cc7250240dfa3dea3839ff01fd55edbb34645e7c8ca01837f86ccf621ee3630b9fcaf5ea6eec68cefd8158c1370deccda6f7
|
7
|
+
data.tar.gz: 0c3cdd6c9741159363ac71ea9b353a4cea9aec56fbc0fab783fe84a8f32d9ea93576fe41f2068cb6710c98547cfcedf6e439980ed674a61194265edec2e90c53
|
data/README.md
CHANGED
@@ -65,7 +65,7 @@ Commands:
|
|
65
65
|
channels Show list of channels
|
66
66
|
now Show network, channel and playing track
|
67
67
|
history Show track history for the current channel
|
68
|
-
vote Vote on
|
68
|
+
vote Vote on a recently played track
|
69
69
|
playlist Generate playlists
|
70
70
|
config Manage local configuration
|
71
71
|
log Manage local like log
|
data/bin/radio
CHANGED
data/lib/audio_addict/channel.rb
CHANGED
@@ -35,9 +35,16 @@ module AudioAddict
|
|
35
35
|
track_history.first
|
36
36
|
end
|
37
37
|
|
38
|
-
def
|
39
|
-
|
40
|
-
|
38
|
+
def similar_channels
|
39
|
+
similar = properties['similar_channels']
|
40
|
+
return [] unless similar
|
41
|
+
ids = similar.map { |s| s['similar_channel_id'] }
|
42
|
+
radio.search_by_id ids
|
43
|
+
end
|
44
|
+
|
45
|
+
def vote(direction = :up, track: nil)
|
46
|
+
track ||= current_track.id
|
47
|
+
endpoint = "tracks/#{track}/vote/#{id}"
|
41
48
|
|
42
49
|
if direction == :delete
|
43
50
|
radio.api.delete endpoint
|
@@ -5,13 +5,17 @@ module AudioAddict
|
|
5
5
|
|
6
6
|
help "List and search channels in the currently set radio network"
|
7
7
|
|
8
|
-
usage "radio channels [SEARCH]"
|
8
|
+
usage "radio channels [SEARCH --info]"
|
9
9
|
usage "radio channels --help"
|
10
10
|
|
11
|
+
option "-i --info", "Show results with additional info, such as channel description and related channels"
|
12
|
+
|
11
13
|
param "SEARCH", "Channel name or a partial name to search for"
|
12
14
|
|
13
15
|
example "radio channels"
|
16
|
+
example "radio channels --info"
|
14
17
|
example "radio channels metal"
|
18
|
+
example "radio channels metal -i"
|
15
19
|
|
16
20
|
def run(args)
|
17
21
|
needs :network
|
@@ -23,8 +27,38 @@ module AudioAddict
|
|
23
27
|
channels = search ? radio.search(search) : radio.channels
|
24
28
|
|
25
29
|
channels = channels.values
|
30
|
+
if args['--info']
|
31
|
+
show_verbose channels
|
32
|
+
else
|
33
|
+
show_compact channels
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def show_verbose(channels)
|
40
|
+
channels.each do |channel|
|
41
|
+
say ""
|
42
|
+
say "!txtgrn!#{channel.name.ljust 22} !txtrst!# #{channel.key}"
|
43
|
+
say ""
|
44
|
+
say word_wrap "#{channel.description}"
|
45
|
+
say ""
|
46
|
+
|
47
|
+
similar = channel.similar_channels
|
48
|
+
|
49
|
+
if similar.any?
|
50
|
+
say "Similar Channels:"
|
51
|
+
similar.each do |key, similar|
|
52
|
+
say "- !txtblu!#{similar.name.ljust 20}!txtrst! # #{key}"
|
53
|
+
end
|
54
|
+
say ""
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def show_compact(channels)
|
26
60
|
channels.each do |channel|
|
27
|
-
say "!
|
61
|
+
say "!txtblu!#{channel.key.rjust 25} !txtgrn!#{channel.name.strip}"
|
28
62
|
end
|
29
63
|
end
|
30
64
|
|
@@ -10,8 +10,8 @@ module AudioAddict
|
|
10
10
|
needs :network, :channel
|
11
11
|
say "!undgrn!#{radio.name} > #{current_channel.name}"
|
12
12
|
say ''
|
13
|
-
tracks.each do |
|
14
|
-
say "!txtgrn! #{
|
13
|
+
tracks.each do |track|
|
14
|
+
say "!txtgrn! #{track.artist.rjust max_artist_len}!txtrst! : !txtblu!#{track.title}"
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -3,25 +3,33 @@ module AudioAddict
|
|
3
3
|
class LogCmd < Base
|
4
4
|
summary "Manage local like log"
|
5
5
|
|
6
|
-
usage "radio log show"
|
6
|
+
usage "radio log show [SEARCH]"
|
7
7
|
usage "radio log tail [--lines N]"
|
8
8
|
usage "radio log sort"
|
9
9
|
usage "radio log --help"
|
10
10
|
|
11
11
|
option "-l --lines N", "Number of lines to show [default: 5]"
|
12
12
|
|
13
|
+
param "SEARCH", "Show only log lines matching this string"
|
14
|
+
|
13
15
|
command "show", "Show the entire like log"
|
14
16
|
command "tail", "Show the last few rows of the like log"
|
15
17
|
command "sort", "Sort the log alphabetically and save it"
|
16
18
|
|
17
19
|
example "radio log show"
|
20
|
+
example "radio log show paramore"
|
18
21
|
example "radio log tail"
|
19
22
|
example "radio log tail --lines 10"
|
20
23
|
example "radio log sort"
|
21
24
|
|
22
25
|
def show_command(args)
|
23
26
|
setup
|
24
|
-
|
27
|
+
search = args['SEARCH']
|
28
|
+
if search
|
29
|
+
puts File.readlines(logfile).select { |l| l.downcase.include? search.downcase }
|
30
|
+
else
|
31
|
+
puts File.read(logfile)
|
32
|
+
end
|
25
33
|
end
|
26
34
|
|
27
35
|
def tail_command(args)
|
@@ -1,44 +1,73 @@
|
|
1
1
|
module AudioAddict
|
2
2
|
module Commands
|
3
3
|
class VoteCmd < Base
|
4
|
-
summary "Vote on
|
4
|
+
summary "Vote on a recently played track"
|
5
5
|
|
6
|
-
help "Start an interactive voting prompt for the currently playing track."
|
6
|
+
help "Start an interactive voting prompt for the currently playing track or for previously played tracks."
|
7
7
|
|
8
|
-
usage "radio vote [--all]"
|
8
|
+
usage "radio vote [--all --past]"
|
9
9
|
usage "radio vote --help"
|
10
10
|
|
11
11
|
option "-a --all", "Show all voting options"
|
12
|
+
option "-p --past", "Vote on previously played tracks"
|
13
|
+
|
14
|
+
example "radio vote"
|
15
|
+
example "radio vote --all"
|
16
|
+
example "radio vote --past"
|
17
|
+
example "radio vote --all --past"
|
18
|
+
example "radio vote -ap"
|
12
19
|
|
13
20
|
def run(args)
|
14
21
|
needs :network, :channel, :session_key
|
22
|
+
@args = args
|
23
|
+
vote_mode == :now ? vote_now : vote_past
|
24
|
+
end
|
15
25
|
|
16
|
-
|
26
|
+
private
|
17
27
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
current_channel.vote answer
|
24
|
-
resay "!txtgrn!Voted"
|
28
|
+
def vote_past
|
29
|
+
track = get_user_track
|
30
|
+
unless track == :cancel
|
31
|
+
vote = get_user_vote
|
32
|
+
send_vote vote, track unless vote == :cancel
|
25
33
|
end
|
26
34
|
end
|
27
35
|
|
28
|
-
|
36
|
+
def vote_now
|
37
|
+
NowCmd.new.run
|
38
|
+
puts ""
|
39
|
+
vote = get_user_vote
|
40
|
+
send_vote vote unless vote == :cancel
|
41
|
+
end
|
29
42
|
|
30
|
-
def
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
43
|
+
def send_vote(vote, track = nil)
|
44
|
+
say "Voting... "
|
45
|
+
current_channel.vote vote, track: track
|
46
|
+
resay "!txtgrn!Voted"
|
47
|
+
end
|
48
|
+
|
49
|
+
def tracks
|
50
|
+
@tracks ||= current_channel.track_history
|
51
|
+
end
|
52
|
+
|
53
|
+
def max_artist_len
|
54
|
+
tracks.map { |t| t.artist.size }.max
|
55
|
+
end
|
56
|
+
|
57
|
+
def get_user_track
|
58
|
+
options = tracks.map { |t| ["#{t.artist.ljust max_artist_len} > #{t.title}", t.id]}.to_h
|
59
|
+
options = { "Cancel" => :cancel }.merge options
|
60
|
+
prompt.select "Track:", options, marker: '>'
|
61
|
+
end
|
62
|
+
|
63
|
+
def get_user_vote
|
64
|
+
vote_style == :menu ? menu_prompt : simple_prompt
|
36
65
|
end
|
37
66
|
|
38
67
|
def menu_prompt
|
39
68
|
options = { "Like" => :up, "Dislike" => :down,
|
40
69
|
"Unvote" => :delete, "Cancel" => :cancel }
|
41
|
-
prompt.select "
|
70
|
+
prompt.select "Vote:", options, marker: '>'
|
42
71
|
end
|
43
72
|
|
44
73
|
def simple_prompt
|
@@ -46,6 +75,14 @@ module AudioAddict
|
|
46
75
|
like ? :up : :cancel
|
47
76
|
end
|
48
77
|
|
78
|
+
def vote_style
|
79
|
+
@args['--all'] ? :menu : :simple
|
80
|
+
end
|
81
|
+
|
82
|
+
def vote_mode
|
83
|
+
@args['--past'] ? :past : :now
|
84
|
+
end
|
85
|
+
|
49
86
|
end
|
50
87
|
end
|
51
88
|
end
|
data/lib/audio_addict/radio.rb
CHANGED
data/lib/audio_addict/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: audio_addict
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Danny Ben Shitrit
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-12-
|
11
|
+
date: 2018-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colsole
|