aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey M․ <dstftw@gmail.com>2019-02-02 23:40:06 +0700
committerSergey M․ <dstftw@gmail.com>2019-02-02 23:40:30 +0700
commit7c5307f4c4e91ef6551d70cd844b93fbdc5c3cf0 (patch)
treef8031f79b07f1e793f694dd6b010f307890ce651
parent6cc6e0c34d0f67747be7bac91690820f47b26acb (diff)
[soundcloud:pagedplaylist] Improve (closes #19086)
-rw-r--r--youtube_dl/extractor/soundcloud.py28
1 files changed, 16 insertions, 12 deletions
diff --git a/youtube_dl/extractor/soundcloud.py b/youtube_dl/extractor/soundcloud.py
index 1c8d3c53b..5536e7851 100644
--- a/youtube_dl/extractor/soundcloud.py
+++ b/youtube_dl/extractor/soundcloud.py
@@ -18,6 +18,7 @@ from ..utils import (
int_or_none,
unified_strdate,
update_url_query,
+ url_or_none,
)
@@ -395,20 +396,23 @@ class SoundcloudPagedPlaylistBaseIE(SoundcloudPlaylistBaseIE):
# Empty collection may be returned, in this case we proceed
# straight to next_href
- def append_url_result(entries, item):
- for cand in (item, item.get('track'), item.get('playlist')):
- if isinstance(cand, dict):
- permalink_url = cand.get('permalink_url')
- if permalink_url and permalink_url.startswith('http'):
- return entries.append(
- self.url_result(
- permalink_url,
- ie=SoundcloudIE.ie_key() if SoundcloudIE.suitable(permalink_url) else None,
- video_id=self._extract_id(cand),
- video_title=cand.get('title')))
+ def resolve_entry(candidates):
+ for cand in candidates:
+ if not isinstance(cand, dict):
+ continue
+ permalink_url = url_or_none(cand.get('permalink_url'))
+ if not permalink_url:
+ continue
+ return self.url_result(
+ permalink_url,
+ ie=SoundcloudIE.ie_key() if SoundcloudIE.suitable(permalink_url) else None,
+ video_id=self._extract_id(cand),
+ video_title=cand.get('title'))
for e in collection:
- append_url_result(entries, e)
+ entry = resolve_entry((e, e.get('track'), e.get('playlist')))
+ if entry:
+ entries.append(entry)
next_href = response.get('next_href')
if not next_href: