Commit d4b92298 authored by Pierre Ynard's avatar Pierre Ynard

soundcloud.lua: support for private tracks

parent 58ad6be8
......@@ -42,30 +42,17 @@ function parse()
line = vlc.readline()
if not line then break end
if not path then
local track = string.match( line, "soundcloud:tracks:(%d+)" )
if track then
-- API magic
local client_id = "02gUJC0hH2ct1EGOcYXQIzRFU91c72Ea"
-- app_version is not required by the API but we send it
-- anyway to remain unconspicuous
local app_version = "a089efd"
local api = vlc.stream( "https://api.soundcloud.com/i1/tracks/"..track.."/streams?client_id="..client_id.."&app_version="..app_version )
if not api then
break
end
local streams = api:readline() -- data is on one line only
-- For now only quality available is 128 kbps (http_mp3_128_url)
path = string.match( streams, "[\"']http_mp3_%d+_url[\"'] *: *[\"'](.-)[\"']" )
if path then
-- FIXME: do this properly
path = string.gsub( path, "\\u0026", "&" )
end
end
-- Parameters for API call
if not track then
track = string.match( line, "soundcloud:tracks:(%d+)" )
end
-- For private tracks
if not secret then
secret = string.match( line, "[\"']secret_token[\"'] *: *[\"'](.-)[\"']" )
end
-- Metadata
if not name then
name = string.match( line, "[\"']title[\"'] *: *\"(.-[^\\])\"" )
if name then
......@@ -92,6 +79,26 @@ function parse()
end
end
if track then
-- API magic
local client_id = "02gUJC0hH2ct1EGOcYXQIzRFU91c72Ea"
-- app_version is not required by the API but we send it anyway
-- to remain unconspicuous
local app_version = "a089efd"
local api = vlc.stream( "https://api.soundcloud.com/i1/tracks/"..track.."/streams?client_id="..client_id.."&app_version="..app_version..( secret and "&secret_token="..secret or "" ) )
if api then
local streams = api:readline() -- data is on one line only
-- For now only quality available is 128 kbps (http_mp3_128_url)
path = string.match( streams, "[\"']http_mp3_%d+_url[\"'] *: *[\"'](.-)[\"']" )
if path then
-- FIXME: do this properly
path = string.gsub( path, "\\u0026", "&" )
end
end
end
if not path then
vlc.msg.err( "Couldn't extract soundcloud audio URL, please check for updates to this script" )
return { }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment