drum 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +11 -4
- data/lib/drum/service/spotify.rb +31 -20
- data/lib/drum/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: c57a5a57b0b2a67b669af5f6880f8f8811ba396847918e7c2a05a2a14cc80728
|
4
|
+
data.tar.gz: a82247076c0d3065cf851bb05ac2f2785c5e70b460b6d3411176be4b2eb233c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82c97fae35962275b4d9f38daaece537c8ef4a66ae5101396294f98d43371473b76d522f0798979dc16dcf9312e516881c1ec06d75bc515c07bea739cdeca94b
|
7
|
+
data.tar.gz: cc88ce5d6624f2ff2c12b2dd7dcc8b46701bc9ddfa9da21a453c39a733b438288071ccd3d7b698c30a226045422d154b9ef2bb8f3b366dbd5d5e7f3a747ffebf
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -29,7 +29,8 @@ The basic usage pattern is always `drum cp [source] [destination]` where `source
|
|
29
29
|
* `@stdout`
|
30
30
|
* A dash `-`, synonymous with `@stdin` and `@stdout`, depending on usage
|
31
31
|
|
32
|
-
>
|
32
|
+
> [!NOTE]
|
33
|
+
> If the source is folder-like, i.e. includes multiple playlists, the destination has to be folder-like too. (The reverse is not true though.)
|
33
34
|
|
34
35
|
### Examples
|
35
36
|
|
@@ -59,7 +60,8 @@ Currently, the following music services are supported:
|
|
59
60
|
* Apple Music
|
60
61
|
* Local, YAML-based playlists (via stdio or files)
|
61
62
|
|
62
|
-
>
|
63
|
+
> [!NOTE]
|
64
|
+
> The tool only processes metadata, not the actual audio files.
|
63
65
|
|
64
66
|
## Development
|
65
67
|
|
@@ -67,11 +69,13 @@ After checking out the repo, run `bin/setup` (or `bundle install`) to install de
|
|
67
69
|
|
68
70
|
To run the application, run `bundle exec bin/drum`. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
69
71
|
|
70
|
-
>
|
72
|
+
> [!IMPORTANT]
|
73
|
+
> You may need to run `bundle exec ruby bin/drum` on Windows
|
71
74
|
|
72
75
|
To package the application into a gem, run `bundle exec rake build`. The built gem should then be located in `pkg`.
|
73
76
|
|
74
|
-
>
|
77
|
+
> [!IMPORTANT]
|
78
|
+
> If you wish to install `drum` using `gem install`, you may need to install additional gems such as `rb-scpt` on macOS to use platform-specific integrations. See [the `Gemfile`](Gemfile) for more information.
|
75
79
|
|
76
80
|
To install the gem, run `bundle exec rake install`.
|
77
81
|
|
@@ -79,6 +83,9 @@ To generate the documentation, run `bundle exec rake yard`.
|
|
79
83
|
|
80
84
|
To run tests, run `bundle exec rake spec`.
|
81
85
|
|
86
|
+
> [!TIP]
|
87
|
+
> If you wish to use a language server such as Solargraph and code completion isn't working for required gems, you may have to run `yard gems`: https://solargraph.org/guides/troubleshooting
|
88
|
+
|
82
89
|
### Spotify
|
83
90
|
|
84
91
|
To use the service integration with Spotify, set the following environment variables:
|
data/lib/drum/service/spotify.rb
CHANGED
@@ -241,30 +241,30 @@ module Drum
|
|
241
241
|
# Download helpers
|
242
242
|
|
243
243
|
def all_sp_library_playlists(offset: 0)
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
[]
|
244
|
+
all_sp_playlists = []
|
245
|
+
while !(sp_playlists = @me.playlists(limit: PLAYLISTS_CHUNK_SIZE, offset: offset)).empty?
|
246
|
+
offset += PLAYLISTS_CHUNK_SIZE
|
247
|
+
all_sp_playlists += sp_playlists
|
249
248
|
end
|
249
|
+
all_sp_playlists
|
250
250
|
end
|
251
251
|
|
252
252
|
def all_sp_playlist_tracks(sp_playlist, offset: 0)
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
[]
|
253
|
+
all_sp_tracks = []
|
254
|
+
while !(sp_tracks = sp_playlist.tracks(limit: TRACKS_CHUNK_SIZE, offset: offset)).empty?
|
255
|
+
offset += TRACKS_CHUNK_SIZE
|
256
|
+
all_sp_tracks += sp_tracks
|
258
257
|
end
|
258
|
+
all_sp_tracks
|
259
259
|
end
|
260
260
|
|
261
261
|
def all_sp_library_tracks(offset: 0)
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
[]
|
262
|
+
all_sp_tracks = []
|
263
|
+
while !(sp_tracks = @me.saved_tracks(limit: SAVED_TRACKS_CHUNKS_SIZE, offset: offset)).empty?
|
264
|
+
offset += SAVED_TRACKS_CHUNKS_SIZE
|
265
|
+
all_sp_tracks += sp_tracks
|
267
266
|
end
|
267
|
+
all_sp_tracks
|
268
268
|
end
|
269
269
|
|
270
270
|
def extract_sp_features(sp_track)
|
@@ -555,11 +555,22 @@ module Drum
|
|
555
555
|
log.info 'Fetching playlists...'
|
556
556
|
Enumerator.new(sp_playlists.length) do |enum|
|
557
557
|
sp_playlists.each do |sp_playlist|
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
558
|
+
3.times do |attempt|
|
559
|
+
begin
|
560
|
+
if attempt > 0
|
561
|
+
log.info "Attempt \##{attempt + 1} to download '#{sp_playlist.name}'..."
|
562
|
+
end
|
563
|
+
new_playlist = self.from_sp_playlist(sp_playlist)
|
564
|
+
enum.yield new_playlist
|
565
|
+
break
|
566
|
+
rescue RestClient::TooManyRequests => e
|
567
|
+
seconds = e.response.headers[:retry_after]&.to_f || 0.5
|
568
|
+
log.info "Got 429 Too Many Requests while downloading '#{sp_playlist.name}', retrying in #{seconds} seconds..."
|
569
|
+
sleep seconds
|
570
|
+
rescue StandardError => e
|
571
|
+
log.info "Could not download playlist '#{sp_playlist.name}': #{e}"
|
572
|
+
break
|
573
|
+
end
|
563
574
|
end
|
564
575
|
end
|
565
576
|
end
|
data/lib/drum/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: drum
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- fwcd
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|