Repository: ytdl-org/youtube-dl

Issue:
soundcloud: cannot download secret embedded playlist
$ youtube-dl --verbose "https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/playlists/49676035%3Fsecret_token%3Ds-phZhg"
[debug] System config: []
[debug] User config: []
[debug] Command-line args: ['--verbose', 'https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/playlists/49676035%3Fsecret_token%3Ds-phZhg']
[debug] Encodings: locale UTF-8, fs UTF-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2014.09.06
[debug] Python version 2.6.6 - Linux-2.6.32-431.23.3.el6.x86_64-x86_64-with-redhat-6.5-Santiago
[debug] Proxy map: {}
[soundcloud:playlist] 49676035: Downloading playlist
ERROR: Unable to download JSON metadata: HTTP Error 404: Not Found; please report this issue on https://yt-dl.org/bug . Be sure to call youtube-dl with the --verbose flag and include its complete output. Make sure you are using the latest version; type  youtube-dl -U  to update.
  File "/home/me/bin/youtube-dl/youtube_dl/extractor/common.py", line 211, in _request_webpage
    return self._downloader.urlopen(url_or_request)
  File "/home/me/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 1244, in urlopen
    return self._opener.open(req, timeout=self._socket_timeout)
  File "/usr/lib64/python2.6/urllib2.py", line 397, in open
    response = meth(req, response)
  File "/usr/lib64/python2.6/urllib2.py", line 510, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib64/python2.6/urllib2.py", line 435, in error
    return self._call_chain(_args)
  File "/usr/lib64/python2.6/urllib2.py", line 369, in _call_chain
    result = func(_args)
  File "/usr/lib64/python2.6/urllib2.py", line 518, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)



Discussion:
Works for me?

Works for me too. Please update youtube-dl to the last version and try again.

That's because that playlist was changed on soundcloud from private to public since the bug report. But here's another one:
% youtube-dl --verbose "https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/167464311%3Fsecret_token%3Ds-IcRLW"
[debug] System config: []
[debug] User config: []
[debug] Command-line args: ['--verbose', 'https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/167464311%3Fsecret_token%3Ds-IcRLW']
[debug] Encodings: locale UTF-8, fs UTF-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2014.09.16.1
[debug] Python version 2.6.6 - Linux-2.6.32-431.29.2.el6.x86_64-x86_64-with-redhat-6.5-Santiago
[debug] Proxy map: {}
[soundcloud] 167464311: Downloading info JSON
ERROR: Unable to download JSON metadata: HTTP Error 404: Not Found; please report this issue on https://yt-dl.org/bug . Be sure to call youtube-dl with the --verbose flag and include its complete output. Make sure you are using the latest version; type  youtube-dl -U  to update.
  File "/afs/ifh.de/user/w/waschk/public/bin/youtube-dl/youtube_dl/extractor/common.py", line 211, in _request_webpage
    return self._downloader.urlopen(url_or_request)
  File "/afs/ifh.de/user/w/waschk/public/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 1264, in urlopen
    return self._opener.open(req, timeout=self._socket_timeout)
  File "/usr/lib64/python2.6/urllib2.py", line 397, in open
    response = meth(req, response)
  File "/usr/lib64/python2.6/urllib2.py", line 510, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib64/python2.6/urllib2.py", line 435, in error
    return self._call_chain(_args)
  File "/usr/lib64/python2.6/urllib2.py", line 369, in _call_chain
    result = func(_args)
  File "/usr/lib64/python2.6/urllib2.py", line 518, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)


Resolving patch:
diff --git a/youtube_dl/extractor/soundcloud.py b/youtube_dl/extractor/soundcloud.py
--- a/youtube_dl/extractor/soundcloud.py
+++ b/youtube_dl/extractor/soundcloud.py
@@ -31,7 +31,8 @@ class SoundcloudIE(InfoExtractor):
                             (?!sets/|likes/?(?:$|[?#]))
                             (?P<title>[\w\d-]+)/?
                             (?P<token>[^?]+?)?(?:[?].*)?$)
-                       |(?:api\.soundcloud\.com/tracks/(?P<track_id>\d+))
+                       |(?:api\.soundcloud\.com/tracks/(?P<track_id>\d+)
+                          (?:/?\?secret_token=(?P<secret_token>[^&]+?))?$)
                        |(?P<player>(?:w|player|p.)\.soundcloud\.com/player/?.*?url=.*)
                     )
                     '''
@@ -80,6 +81,20 @@ class SoundcloudIE(InfoExtractor):
                 'duration': 9,
             },
         },
+        # private link (alt format)
+        {
+            'url': 'https://api.soundcloud.com/tracks/123998367?secret_token=s-8Pjrp',
+            'md5': 'aa0dd32bfea9b0c5ef4f02aacd080604',
+            'info_dict': {
+                'id': '123998367',
+                'ext': 'mp3',
+                'title': 'Youtube - Dl Test Video \'\' Ä↭',
+                'uploader': 'jaimeMF',
+                'description': 'test chars:  \"\'/\\ä↭',
+                'upload_date': '20131209',
+                'duration': 9,
+            },
+        },
         # downloadable song
         {
             'url': 'https://soundcloud.com/oddsamples/bus-brakes',
@@ -197,6 +212,9 @@ def _real_extract(self, url):
         if track_id is not None:
             info_json_url = 'http://api.soundcloud.com/tracks/' + track_id + '.json?client_id=' + self._CLIENT_ID
             full_title = track_id
+            token = mobj.group('secret_token')
+            if token:
+                info_json_url += "&secret_token=" + token
         elif mobj.group('player'):
             query = compat_urlparse.parse_qs(compat_urlparse.urlparse(url).query)
             return self.url_result(query['url'][0])


Test patch: