summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRemita Amine <[email protected]>2019-12-09 14:38:12 +0100
committerRemita Amine <[email protected]>2019-12-09 14:38:12 +0100
commitcf80ff186eab6963fcfb108919a25b7ed28813d1 (patch)
tree3857981130d8f0776250bcf7b90c71401ec26fdc
parent0e6ec3caf6c20bb5b27c063b2b946686e0b5159f (diff)
downloadyoutube-dl-cf80ff186eab6963fcfb108919a25b7ed28813d1.tar.gz
youtube-dl-cf80ff186eab6963fcfb108919a25b7ed28813d1.zip
[soundcloud] add support for token protected embeds(#18954)
-rw-r--r--youtube_dl/extractor/soundcloud.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/youtube_dl/extractor/soundcloud.py b/youtube_dl/extractor/soundcloud.py
index 988dec4fa..c2ee54457 100644
--- a/youtube_dl/extractor/soundcloud.py
+++ b/youtube_dl/extractor/soundcloud.py
@@ -28,7 +28,12 @@ from ..utils import (
class SoundcloudEmbedIE(InfoExtractor):
- _VALID_URL = r'https?://(?:w|player|p)\.soundcloud\.com/player/?.*?url=(?P<id>.*)'
+ _VALID_URL = r'https?://(?:w|player|p)\.soundcloud\.com/player/?.*?\burl=(?P<id>.+)'
+ _TEST = {
+ # from https://www.soundi.fi/uutiset/ennakkokuuntelussa-timo-kaukolammen-station-to-station-to-station-julkaisua-juhlitaan-tanaan-g-livelabissa/
+ 'url': 'https://w.soundcloud.com/player/?visual=true&url=https%3A%2F%2Fapi.soundcloud.com%2Fplaylists%2F922213810&show_artwork=true&maxwidth=640&maxheight=960&dnt=1&secret_token=s-ziYey',
+ 'only_matching': True,
+ }
@staticmethod
def _extract_urls(webpage):
@@ -37,8 +42,13 @@ class SoundcloudEmbedIE(InfoExtractor):
webpage)]
def _real_extract(self, url):
- return self.url_result(compat_urlparse.parse_qs(
- compat_urlparse.urlparse(url).query)['url'][0])
+ query = compat_urlparse.parse_qs(
+ compat_urlparse.urlparse(url).query)
+ api_url = query['url'][0]
+ secret_token = query.get('secret_token')
+ if secret_token:
+ api_url = update_url_query(api_url, {'secret_token': secret_token[0]})
+ return self.url_result(api_url)
class SoundcloudIE(InfoExtractor):