diff options
Diffstat (limited to 'searx/engines/soundcloud.py')
| -rw-r--r-- | searx/engines/soundcloud.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/searx/engines/soundcloud.py b/searx/engines/soundcloud.py index d59755e04..284689bf6 100644 --- a/searx/engines/soundcloud.py +++ b/searx/engines/soundcloud.py @@ -28,8 +28,10 @@ categories = ['music'] paging = True # search-url -url = 'https://api.soundcloud.com/' +# missing attribute: user_id, app_version, app_locale +url = 'https://api-v2.soundcloud.com/' search_url = url + 'search?{query}'\ + '&variant_ids='\ '&facet=model'\ '&limit=20'\ '&offset={offset}'\ @@ -49,7 +51,9 @@ def get_client_id(): if response.ok: tree = html.fromstring(response.content) - script_tags = tree.xpath("//script[contains(@src, '/assets/app')]") + # script_tags has been moved from /assets/app/ to /assets/ path. I + # found client_id in https://a-v2.sndcdn.com/assets/49-a0c01933-3.js + script_tags = tree.xpath("//script[contains(@src, '/assets/')]") app_js_urls = [script_tag.get('src') for script_tag in script_tags if script_tag is not None] # extracts valid app_js urls from soundcloud.com content @@ -57,14 +61,14 @@ def get_client_id(): # gets app_js and searches for the clientid response = http_get(app_js_url) if response.ok: - cids = cid_re.search(response.text) + cids = cid_re.search(response.content.decode("utf-8")) if cids is not None and len(cids.groups()): return cids.groups()[0] logger.warning("Unable to fetch guest client_id from SoundCloud, check parser!") return "" -def init(): +def init(engine_settings=None): global guest_client_id # api-key guest_client_id = get_client_id() |