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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0515ca290089497d8667ed64575eb60dc604ba793812b77437ced8d27f70e6bb
4
- data.tar.gz: 1da960b8dc5e79ce85328e918c43d214898824e51d544b613b58ede726666f97
3
+ metadata.gz: c57a5a57b0b2a67b669af5f6880f8f8811ba396847918e7c2a05a2a14cc80728
4
+ data.tar.gz: a82247076c0d3065cf851bb05ac2f2785c5e70b460b6d3411176be4b2eb233c8
5
5
  SHA512:
6
- metadata.gz: db118818875e8c9d0d5281697e033bcaeebb3bc204355e41ab4436ed2da1738297c703ed8aa813f32456f968851729794f3e209c0510ca1ddbf218b93af75ab0
7
- data.tar.gz: 24ce2b4be59b259617cc50ba66fc35c48aeeeb89faa716a5ad457a959364ccb39cb37b7fa86c4e4f4da6593b7c753bc9eebcde02226d24a6a65402f5d2e7eca8
6
+ metadata.gz: 82c97fae35962275b4d9f38daaece537c8ef4a66ae5101396294f98d43371473b76d522f0798979dc16dcf9312e516881c1ec06d75bc515c07bea739cdeca94b
7
+ data.tar.gz: cc88ce5d6624f2ff2c12b2dd7dcc8b46701bc9ddfa9da21a453c39a733b438288071ccd3d7b698c30a226045422d154b9ef2bb8f3b366dbd5d5e7f3a747ffebf
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- drum (0.2.1)
4
+ drum (0.2.2)
5
5
  highline (~> 2.0)
6
6
  jwt (~> 2.2)
7
7
  launchy (~> 2.4)
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
- > Note that 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.)
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
- > Note that the tool only processes metadata, not the actual audio files.
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
- > Note that you may need to run `bundle exec ruby bin/drum` on Windows
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
- > Note: 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.
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:
@@ -241,30 +241,30 @@ module Drum
241
241
  # Download helpers
242
242
 
243
243
  def all_sp_library_playlists(offset: 0)
244
- sp_playlists = @me.playlists(limit: PLAYLISTS_CHUNK_SIZE, offset: offset)
245
- unless sp_playlists.empty?
246
- sp_playlists + self.all_sp_library_playlists(offset: offset + PLAYLISTS_CHUNK_SIZE)
247
- else
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
- sp_tracks = sp_playlist.tracks(limit: TRACKS_CHUNK_SIZE, offset: offset)
254
- unless sp_tracks.empty?
255
- sp_tracks + self.all_sp_playlist_tracks(sp_playlist, offset: offset + TRACKS_CHUNK_SIZE)
256
- else
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
- sp_tracks = @me.saved_tracks(limit: SAVED_TRACKS_CHUNKS_SIZE, offset: offset)
263
- unless sp_tracks.empty?
264
- sp_tracks + self.all_sp_library_tracks(offset: offset + SAVED_TRACKS_CHUNKS_SIZE)
265
- else
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
- begin
559
- new_playlist = self.from_sp_playlist(sp_playlist)
560
- enum.yield new_playlist
561
- rescue StandardError => e
562
- log.info "Could not download playlist '#{sp_playlist.name}': #{e}"
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
@@ -1,3 +1,3 @@
1
1
  module Drum
2
- VERSION = '0.2.1'
2
+ VERSION = '0.2.2'
3
3
  end
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.1
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-01-19 00:00:00.000000000 Z
11
+ date: 2024-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor