drum 0.2.2 → 0.2.3

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: c57a5a57b0b2a67b669af5f6880f8f8811ba396847918e7c2a05a2a14cc80728
4
- data.tar.gz: a82247076c0d3065cf851bb05ac2f2785c5e70b460b6d3411176be4b2eb233c8
3
+ metadata.gz: e1cf895018608f7c8ecbf68a5f243228d1569af86b9015c0f178b13f6614cd7c
4
+ data.tar.gz: f52ba7d7d00e81cd8f3f3a1793d637def247beb9c88a58d167d64e9c890ab841
5
5
  SHA512:
6
- metadata.gz: 82c97fae35962275b4d9f38daaece537c8ef4a66ae5101396294f98d43371473b76d522f0798979dc16dcf9312e516881c1ec06d75bc515c07bea739cdeca94b
7
- data.tar.gz: cc88ce5d6624f2ff2c12b2dd7dcc8b46701bc9ddfa9da21a453c39a733b438288071ccd3d7b698c30a226045422d154b9ef2bb8f3b366dbd5d5e7f3a747ffebf
6
+ metadata.gz: 5c24724da7a46dc623202cef18dc779f9c5fa98d0f34491da5a4445927ee47cf7b0dda2f0372c9ed0d26a6a3a4ec13cfb9f515227009ffb0239d6bb751908038
7
+ data.tar.gz: 806e30e6353f897cd3f163f663769913ccb33f9f5df7b1f629cf97b5258cf3f682b9bbc185906785b570d8f97e9930b74fa837d5fd1a5cc019336e42d5708528
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- drum (0.2.2)
4
+ drum (0.2.3)
5
5
  highline (~> 2.0)
6
6
  jwt (~> 2.2)
7
7
  launchy (~> 2.4)
@@ -31,6 +31,8 @@ module Drum
31
31
  TO_SPOTIFY_TRACKS_CHUNK_SIZE = 50
32
32
  UPLOAD_PLAYLIST_TRACKS_CHUNK_SIZE = 100
33
33
 
34
+ MAX_PLAYLIST_TRACKS = 10_000
35
+
34
36
  CLIENT_ID_VAR = 'SPOTIFY_CLIENT_ID'
35
37
  CLIENT_SECRET_VAR = 'SPOTIFY_CLIENT_SECRET'
36
38
 
@@ -254,6 +256,13 @@ module Drum
254
256
  while !(sp_tracks = sp_playlist.tracks(limit: TRACKS_CHUNK_SIZE, offset: offset)).empty?
255
257
  offset += TRACKS_CHUNK_SIZE
256
258
  all_sp_tracks += sp_tracks
259
+ if offset > sp_playlist.total + TRACKS_CHUNK_SIZE
260
+ log.warn "Truncating playlist '#{sp_playlist.name}' at #{offset}, which strangely seems to yield more tracks than its length of #{sp_playlist.total} would suggest."
261
+ break
262
+ elsif offset > MAX_PLAYLIST_TRACKS
263
+ log.warn "Truncating playlist '#{sp_playlist.name}' at #{offset}, since it exceeds the maximum of #{MAX_PLAYLIST_TRACKS} tracks."
264
+ break
265
+ end
257
266
  end
258
267
  all_sp_tracks
259
268
  end
@@ -555,6 +564,14 @@ module Drum
555
564
  log.info 'Fetching playlists...'
556
565
  Enumerator.new(sp_playlists.length) do |enum|
557
566
  sp_playlists.each do |sp_playlist|
567
+ # These playlists seem to cause trouble for some reason, by either
568
+ # 404ing or by returning seemingly endless amounts of tracks, so
569
+ # we'll ignore them for now...
570
+ if sp_playlist.name.start_with?('Your Top Songs')
571
+ log.info "Skipping '#{sp_playlist.name}'"
572
+ next
573
+ end
574
+
558
575
  3.times do |attempt|
559
576
  begin
560
577
  if attempt > 0
@@ -565,10 +582,15 @@ module Drum
565
582
  break
566
583
  rescue RestClient::TooManyRequests => e
567
584
  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
585
+ if seconds <= 300
586
+ log.warn "Got 429 Too Many Requests while downloading '#{sp_playlist.name}', retrying in #{seconds} seconds..."
587
+ sleep seconds
588
+ else
589
+ log.error "Got 429 Too Many Requests while downloading '#{sp_playlist.name}' with a too large retry time of #{seconds} seconds"
590
+ raise
591
+ end
570
592
  rescue StandardError => e
571
- log.info "Could not download playlist '#{sp_playlist.name}': #{e}"
593
+ log.warn "Could not download playlist '#{sp_playlist.name}': #{e}"
572
594
  break
573
595
  end
574
596
  end
data/lib/drum/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Drum
2
- VERSION = '0.2.2'
2
+ VERSION = '0.2.3'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: drum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - fwcd