Skip to content

Commit fc247a5

Browse files
committed
requests.get() does not have permission and 401's here
1 parent 800c1bf commit fc247a5

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

soundscrape/soundscrape.py

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -167,28 +167,24 @@ def process_soundcloud(vargs):
167167
resolved = client.get('/resolve', url=track_url, limit=200)
168168

169169
elif likes:
170-
userId = str(client.get('/resolve', url=artist_url).id)
171-
172-
resolved = client.get('/users/' + userId + '/favorites', limit=200, linked_partitioning=1)
173-
next_href = False
174-
if(hasattr(resolved, 'next_href')):
175-
next_href = resolved.next_href
176-
while (next_href):
177-
178-
resolved2 = requests.get(next_href).json()
179-
if('next_href' in resolved2):
180-
next_href = resolved2['next_href']
181-
else:
182-
next_href = False
183-
resolved2 = soundcloud.resource.ResourceList(resolved2['collection'])
184-
resolved.collection.extend(resolved2)
170+
puts_safe(colored.green('Loading Likes...'))
171+
user_id = str(client.get('/resolve', url=artist_url).id)
172+
resolved = client.get('/users/' + user_id + '/favorites', limit=200, linked_partitioning=1)
173+
next_href = getattr(resolved, 'next_href', None)
174+
175+
while next_href:
176+
puts_safe(colored.white('Loading (more) likes...'))
177+
temp_resolved = client.get(next_href)
178+
next_href = getattr(temp_resolved, 'next_href', None)
179+
180+
resolved.collection.extend(temp_resolved.collection)
181+
puts_safe(colored.green('Loaded ' + str(len(resolved.collection)) + ' Likes...'))
185182
resolved = resolved.collection
186183

187184
else:
188185
resolved = client.get('/resolve', url=artist_url, limit=200)
189186

190187
except Exception as e: # HTTPError?
191-
192188
# SoundScrape is trying to prevent us from downloading this.
193189
# We're going to have to stop trusting the API/client and
194190
# do all our own scraping. Boo.

0 commit comments

Comments
 (0)