Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
8074c41d
Commit
8074c41d
authored
Nov 11, 2015
by
Pierre Ynard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
youtube.lua: helper to extract signature descrambling javascript code
parent
f87f4539
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
15 deletions
+18
-15
share/lua/playlist/youtube.lua
share/lua/playlist/youtube.lua
+18
-15
No files found.
share/lua/playlist/youtube.lua
View file @
8074c41d
...
...
@@ -70,24 +70,33 @@ function buf_iter( s )
return
line
end
-- Helper to search and extract code from javascript stream
function
js_extract
(
js
,
pattern
)
js
.
i
=
0
-- Reset to beginning
for
line
in
buf_iter
,
js
do
local
ex
=
string.match
(
line
,
pattern
)
if
ex
then
return
ex
end
end
vlc
.
msg
.
err
(
"Couldn't process youtube video URL, please check for updates to this script"
)
return
nil
end
-- Descramble the URL signature using the javascript code that does that
-- in the web page
function
js_descramble
(
sig
,
js_url
)
-- Fetch javascript code
local
js
=
{
stream
=
vlc
.
stream
(
js_url
),
lines
=
{},
i
=
0
}
if
not
js
.
stream
then
vlc
.
msg
.
err
(
"Couldn't process youtube video URL, please check for updates to this script"
)
return
sig
end
-- Look for the descrambler function's name
local
descrambler
=
nil
for
line
in
buf_iter
,
js
do
-- c&&a.set("signature",br(c));
descrambler
=
string.match
(
line
,
"%.set%(\"
signature
\
",(.-)%("
)
if
descrambler
then
break
end
end
local
descrambler
=
js_extract
(
js
,
"%.set%(\"
signature
\
",(.-)%("
)
if
not
descrambler
then
vlc
.
msg
.
err
(
"Couldn't process youtube video URL, please check for updates to this script"
)
return
sig
end
...
...
@@ -95,15 +104,9 @@ function js_descramble( sig, js_url )
-- conveniently preceded by the definition of a helper object
-- that it uses. Example:
-- var Fo={TR:function(a){a.reverse()},TU:function(a,b){var c=a[0];a[0]=a[b%a.length];a[b]=c},sH:function(a,b){a.splice(0,b)}};function Go(a){a=a.split("");Fo.sH(a,2);Fo.TU(a,28);Fo.TU(a,44);Fo.TU(a,26);Fo.TU(a,40);Fo.TU(a,64);Fo.TR(a,26);Fo.sH(a,1);return a.join("")};
local
transformations
=
nil
local
rules
=
nil
js
.
i
=
0
-- Reset to beginning
for
line
in
buf_iter
,
js
do
transformations
,
rules
=
string.match
(
line
,
"var ..={(.-)};function "
..
descrambler
..
"%([^)]*%){(.-)}"
)
if
transformations
or
rules
then
break
end
end
local
rules
=
js_extract
(
js
,
"function "
..
descrambler
..
"%([^)]*%){(.-)}"
)
local
transformations
=
js_extract
(
js
,
"var ..={(.-)};function "
..
descrambler
..
"%("
)
if
not
transformations
or
not
rules
then
vlc
.
msg
.
err
(
"Couldn't process youtube video URL, please check for updates to this script"
)
return
sig
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment