From d6d26ee1eeeef686aa7fb84c56501d94f6d13365 Mon Sep 17 00:00:00 2001 From: Sogolumbo <33571916+Sogolumbo@users.noreply.github.com> Date: Mon, 5 Oct 2020 04:53:04 +0200 Subject: [PATCH] Log request count For large playlists (6500 songs) this method can take over a minute. To avoid wrong conclusions because the program 'is doing nothing' the number of items and needed requests is logged/printed. --- spotify-backup.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spotify-backup.py b/spotify-backup.py index 1a1fc70..12ef932 100755 --- a/spotify-backup.py +++ b/spotify-backup.py @@ -45,6 +45,10 @@ class SpotifyAPI: # fetches all pages and joins them, returning in a single list of objects. def list(self, url, params={}): response = self.get(url, params) + requests = int(response['total'] / params['limit']) + if requests > 10: + timeEstimate = int(0.27*requests); # in seconds, 0.28 was the average speed of 130 requests + log('{} items, {} items per request, {} requests, ~{} seconds'.format(response['total'], params['limit'], requests, timeEstimate)) items = response['items'] while response['next']: response = self.get(response['next'])