audio_addict 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -0
- data/lib/audio_addict/cli.rb +1 -0
- data/lib/audio_addict/commands/download.rb +70 -0
- data/lib/audio_addict/exceptions.rb +1 -2
- data/lib/audio_addict/track.rb +4 -0
- data/lib/audio_addict/version.rb +1 -1
- data/lib/audio_addict/youtube.rb +41 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 426a2b37a0f6f0d2f7a0bc151aeb481630ea6c2449065e1d154e87d39af3af36
|
4
|
+
data.tar.gz: 42ef3f68930178372a1bbcc2c9694bce20da72ee65672421c14b672821afa24d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 656a86ab1ff70b214af607befecf191bba4de6fc33e74f8c674c938f8732525e9cba98827962f1a86c0fb0ede9340e9b8e78f3f546dc367f6a89d2594f51b9e8
|
7
|
+
data.tar.gz: 33a50eac62b23ad09ed0cf8e5a5d6afa93a082765f44a377050d8105d50501c39788ae7e28b1e7963132589df31ac5539e0f5e7618a207ea30becd35a2a3a09a
|
data/README.md
CHANGED
@@ -41,11 +41,13 @@ Features
|
|
41
41
|
- [RadioTunes]
|
42
42
|
- [JazzRadio]
|
43
43
|
- [ClassicalRadio]
|
44
|
+
- [ZenRadio]
|
44
45
|
- View list of channels
|
45
46
|
- View currently playing track
|
46
47
|
- Vote on the currently playing track
|
47
48
|
- Save a log of a all your liked tracks
|
48
49
|
- Generate playlists (requires a premium account)
|
50
|
+
- Download songs from Youtube (using youtube-dl)
|
49
51
|
|
50
52
|
|
51
53
|
Usage
|
@@ -68,6 +70,7 @@ Commands:
|
|
68
70
|
playlist Generate playlists
|
69
71
|
config Manage local configuration
|
70
72
|
log Manage local like log
|
73
|
+
download Download songs from YouTube
|
71
74
|
api Make direct calls to the AudioAddict API
|
72
75
|
|
73
76
|
```
|
@@ -80,3 +83,4 @@ Commands:
|
|
80
83
|
[RadioTunes]: http://www.radiotunes.com
|
81
84
|
[JazzRadio]: http://www.jazzradio.com
|
82
85
|
[ClassicalRadio]: http://www.classicalradio.com
|
86
|
+
[ZenRadio]: http://www.zenradio.com
|
data/lib/audio_addict/cli.rb
CHANGED
@@ -13,6 +13,7 @@ module AudioAddict
|
|
13
13
|
router.route "playlist", to: Commands::PlaylistCmd
|
14
14
|
router.route "config", to: Commands::ConfigCmd
|
15
15
|
router.route "log", to: Commands::LogCmd
|
16
|
+
router.route "download", to: Commands::DownloadCmd
|
16
17
|
router.route "api", to: Commands::APICmd
|
17
18
|
|
18
19
|
router
|
@@ -0,0 +1,70 @@
|
|
1
|
+
module AudioAddict
|
2
|
+
module Commands
|
3
|
+
class DownloadCmd < Base
|
4
|
+
summary "Download songs from YouTube"
|
5
|
+
|
6
|
+
help "This command uses youtube-dl to download the currently playing song, or songs from your like-log."
|
7
|
+
|
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
|
+
|
13
|
+
option "-l --lines N", "Number of log lines to download [default: 1]"
|
14
|
+
option "-c --count N", "Number of YouTube search results to download [default: 1]"
|
15
|
+
|
16
|
+
param "QUERY", "YouTube search query"
|
17
|
+
|
18
|
+
command "current", "Download the currently playing song"
|
19
|
+
command "log", "Download the last N songs from the like-log"
|
20
|
+
command "search", "Download any song matching the Youtube search query"
|
21
|
+
|
22
|
+
example "radio download current"
|
23
|
+
example "radio download current --count 3"
|
24
|
+
example "radio download log --lines 2 --count 3"
|
25
|
+
example "radio download search 'Brimstone, Bright Shadow' -c2"
|
26
|
+
|
27
|
+
def current_command
|
28
|
+
needs :network, :channel
|
29
|
+
count = args['--count']
|
30
|
+
|
31
|
+
say "!txtblu!Downloading !txtrst!: ... "
|
32
|
+
|
33
|
+
track = current_channel.current_track
|
34
|
+
query = track.search_string
|
35
|
+
|
36
|
+
resay "!txtblu!Downloading !txtgrn!: #{query}"
|
37
|
+
|
38
|
+
Youtube.new(query).get count
|
39
|
+
end
|
40
|
+
|
41
|
+
def log_command
|
42
|
+
needs :like_log
|
43
|
+
count = args['--count']
|
44
|
+
lines = args['--lines']&.to_i
|
45
|
+
|
46
|
+
data = log.data[-lines..-1]
|
47
|
+
data.each do |line|
|
48
|
+
network, channel, artist, song = line.split(" :: ")
|
49
|
+
query = "#{artist}, #{song}"
|
50
|
+
say "\n!txtblu!Downloading !txtgrn!: #{query}"
|
51
|
+
Youtube.new(query).get count
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def search_command
|
56
|
+
query = args['QUERY']
|
57
|
+
count = args['--count']
|
58
|
+
|
59
|
+
say "\n!txtblu!Downloading !txtgrn!: #{query}"
|
60
|
+
Youtube.new(query).get count
|
61
|
+
end
|
62
|
+
|
63
|
+
private
|
64
|
+
|
65
|
+
def log
|
66
|
+
@log ||= Log.new
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
data/lib/audio_addict/track.rb
CHANGED
data/lib/audio_addict/version.rb
CHANGED
@@ -0,0 +1,41 @@
|
|
1
|
+
module AudioAddict
|
2
|
+
class Youtube
|
3
|
+
include Inspectable
|
4
|
+
include Colsole
|
5
|
+
|
6
|
+
attr_reader :query
|
7
|
+
|
8
|
+
def initialize(query)
|
9
|
+
@query = query
|
10
|
+
end
|
11
|
+
|
12
|
+
def inspectable
|
13
|
+
[:query]
|
14
|
+
end
|
15
|
+
|
16
|
+
def get(count = 1)
|
17
|
+
raise DependencyError, "This command requires youtube-dl" unless command_exist? 'youtube-dl'
|
18
|
+
success = execute command(count: count, query: query)
|
19
|
+
raise DependencyError, "youtube-dl exited with an error" unless success
|
20
|
+
end
|
21
|
+
|
22
|
+
def command(args)
|
23
|
+
command_template % args
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def execute(command)
|
29
|
+
if ENV['YOUTUBE_DL_DRY_RUN']
|
30
|
+
puts "DRY RUN: #{command}"
|
31
|
+
true
|
32
|
+
else
|
33
|
+
system command
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def command_template
|
38
|
+
@command_template ||= %Q[youtube-dl --extract-audio --audio-format mp3 ytsearch%{count}:"%{query}"]
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
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.
|
4
|
+
version: 0.4.0
|
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: 2021-01-
|
11
|
+
date: 2021-01-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colsole
|
@@ -114,6 +114,7 @@ files:
|
|
114
114
|
- lib/audio_addict/commands/base.rb
|
115
115
|
- lib/audio_addict/commands/channels.rb
|
116
116
|
- lib/audio_addict/commands/config.rb
|
117
|
+
- lib/audio_addict/commands/download.rb
|
117
118
|
- lib/audio_addict/commands/history.rb
|
118
119
|
- lib/audio_addict/commands/log.rb
|
119
120
|
- lib/audio_addict/commands/login.rb
|
@@ -129,6 +130,7 @@ files:
|
|
129
130
|
- lib/audio_addict/radio.rb
|
130
131
|
- lib/audio_addict/track.rb
|
131
132
|
- lib/audio_addict/version.rb
|
133
|
+
- lib/audio_addict/youtube.rb
|
132
134
|
homepage: https://github.com/dannyben/audio_addict
|
133
135
|
licenses:
|
134
136
|
- MIT
|