vlc | branch: master | Cheng Sun <[email protected]> | Wed Feb 15 19:36:02 2012 +0000| [574f292a932d8445fa3a8416bc11988be32728fe] | committer: Jean-Baptiste Kempf
lua soundcloud.com playlist Adds support for soundcloud.com URL parsing Signed-off-by: Jean-Baptiste Kempf <[email protected]> > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=574f292a932d8445fa3a8416bc11988be32728fe --- share/Makefile.am | 2 + share/lua/playlist/soundcloud.lua | 50 +++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 0 deletions(-) diff --git a/share/Makefile.am b/share/Makefile.am index f7b64cb..1d93f1a 100644 --- a/share/Makefile.am +++ b/share/Makefile.am @@ -195,6 +195,7 @@ nobase_vlclib_DATA = \ lua/playlist/pinkbike.luac \ lua/playlist/pluzz.luac \ lua/playlist/rockbox_fm_presets.luac \ + lua/playlist/soundcloud.luac \ lua/playlist/vimeo.luac \ lua/playlist/youtube.luac \ lua/playlist/youtube_homepage.luac \ @@ -265,6 +266,7 @@ EXTRA_DIST += \ lua/playlist/pinkbike.lua \ lua/playlist/pluzz.lua \ lua/playlist/rockbox_fm_presets.lua \ + lua/playlist/soundcloud.lua \ lua/playlist/vimeo.lua \ lua/playlist/youtube.lua \ lua/playlist/youtube_homepage.lua \ diff --git a/share/lua/playlist/soundcloud.lua b/share/lua/playlist/soundcloud.lua new file mode 100644 index 0000000..58f5aac --- /dev/null +++ b/share/lua/playlist/soundcloud.lua @@ -0,0 +1,50 @@ +--[[ + $Id$ + + Copyright © 2012 the VideoLAN team + + Authors: Cheng Sun <chengsun9atgmail.com> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. +--]] + +-- Probe function. +function probe() + return vlc.access == "http" + and string.match( vlc.path, "soundcloud\.com/.+/.+" ) +end + +-- Parse function. +function parse() + if string.match ( vlc.path, "soundcloud\.com" ) then + while true do + line = vlc.readline() + if not line then break end + if string.match( line, "window\.SC\.bufferTracks\.push" ) then + -- all the data is nicely stored on this one line + _,_,uid,token,name = string.find (line, + "window\.SC\.bufferTracks\.push.*" .. + "\"uid\":\"([^\"]*)\".*" .. + "\"token\":\"([^\"]*)\".*" .. + "\"title\":\"([^\"]*)\"") + -- we only want the first one of these lines + break + end + end + path = "http://media.soundcloud.com/stream/"..uid.."?stream_token="..token + return { { path = path; name = name } } + end + return {} +end _______________________________________________ vlc-commits mailing list [email protected] http://mailman.videolan.org/listinfo/vlc-commits
