audio_addict 0.3.0 → 0.4.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3530b3f712aaf7023144c17e182aca9aa659cde5c10426207a7f74a7c5ed94e2
4
- data.tar.gz: 84935800acaa568734b0b7d326420f414d03287dab47f23049d5ab1b99c8f5e8
3
+ metadata.gz: 426a2b37a0f6f0d2f7a0bc151aeb481630ea6c2449065e1d154e87d39af3af36
4
+ data.tar.gz: 42ef3f68930178372a1bbcc2c9694bce20da72ee65672421c14b672821afa24d
5
5
  SHA512:
6
- metadata.gz: 831a5050b49f28803e23a1e65565558eea4a10dca028b9320de05994f7028ab3e3721aab474dc5a09e0655fd6b3479b8db0bd11530266f650ab5a128ad0d6725
7
- data.tar.gz: 2a8a65335a02e86725780441d78515c9667c83f34b2674269da749e25476bbca1bd56dedcb67e0fca8f68c98b27a88e5eaaf6632a279c2386bb12e6ae4b887a8
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
@@ -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
@@ -1,9 +1,8 @@
1
1
  module AudioAddict
2
2
  class Error < StandardError; end
3
-
4
3
  class Interrupt < Error; end
5
-
6
4
  class ArgumentError < Error; end
5
+ class DependencyError < Error; end
7
6
 
8
7
  class ConfigError < Error
9
8
  attr_reader :missing_keys
@@ -20,5 +20,9 @@ module AudioAddict
20
20
  def title
21
21
  properties["title"].strip
22
22
  end
23
+
24
+ def search_string
25
+ "#{artist}, #{title}"
26
+ end
23
27
  end
24
28
  end
@@ -1,3 +1,3 @@
1
1
  module AudioAddict
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -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.3.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-06 00:00:00.000000000 Z
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