[vlc-commits] soundcloud.lua: don't treat JavaScript assets as line-based
Pierre Ynard
git at videolan.org
Sun Mar 7 00:17:35 UTC 2021
vlc | branch: master | Pierre Ynard <linkfanel at yahoo.fr> | Sun Mar 7 00:44:41 2021 +0100| [302d55967b127a3519b714f8cdabd0257fbb3b45] | committer: Pierre Ynard
soundcloud.lua: don't treat JavaScript assets as line-based
Following changes in the SoundCloud JavaScript web assets, the API
magic is only found anymore in assets with lines exceeding the VLC API
line-length limit of 200 kB, making it impossible to extract this way
and causing playback failure.
These JavaScript assets are minified into one-liners, so it makes no
sense anyway to attempt to read and parse them line by line. Instead,
this now reads up to 4 MB of text from them (the relevant asset
currently weighs 1 MB). This way is arguably better and also more
efficient to begin with.
Refs #24957
Fixes #25508
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=302d55967b127a3519b714f8cdabd0257fbb3b45
---
share/lua/playlist/soundcloud.lua | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/share/lua/playlist/soundcloud.lua b/share/lua/playlist/soundcloud.lua
index 3860837fcf..b1d6dcec20 100644
--- a/share/lua/playlist/soundcloud.lua
+++ b/share/lua/playlist/soundcloud.lua
@@ -45,18 +45,18 @@ function extract_magic( url )
return nil
end
- while true do
- local line = s:readline()
- if not line then break end
+ local line = s:read( 4096*1024 )
+ if not line then
+ return nil
+ end
- -- The API magic appears under a similar form several times
- -- in one of the javascript assets
- -- {client_id:"z21TN9SfM0GjGteSzk4ViM1KEwMRNWZF"}
- local client_id = string.match( line, '[{,]client_id:"(%w+)"[},]' )
- if client_id then
- vlc.msg.dbg( "Found soundcloud API magic" )
- return client_id
- end
+ -- The API magic appears under a similar form several times
+ -- in one of the javascript assets
+ -- {client_id:"z21TN9SfM0GjGteSzk4ViM1KEwMRNWZF"}
+ local client_id = string.match( line, '[{,]client_id:"(%w+)"[},]' )
+ if client_id then
+ vlc.msg.dbg( "Found soundcloud API magic" )
+ return client_id
end
return nil
end
More information about the vlc-commits
mailing list