From b54b08c91bb7f59a9ea720abbf944809d1ea8956 Mon Sep 17 00:00:00 2001 From: reiv Date: Sat, 17 Oct 2015 22:36:08 +0200 Subject: [PATCH] Simplify with itertools.islice(). --- youtube_dl/extractor/soundcloud.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/youtube_dl/extractor/soundcloud.py b/youtube_dl/extractor/soundcloud.py index 3fe991849..959f27975 100644 --- a/youtube_dl/extractor/soundcloud.py +++ b/youtube_dl/extractor/soundcloud.py @@ -532,11 +532,7 @@ class SoundcloudSearchIE(SearchInfoExtractor, SoundcloudIE): collection_id='Query "{0}"'.format(query), q=query.encode('utf-8')) - for _ in range(n): - try: - track = next(tracks) - except StopIteration: - break + for track in itertools.islice(tracks, n): uri = track['uri'] title = track['title'] results.append(self.url_result(url=uri))