Some videos from YouTube are protected.
- All URLs for normal and adaptive videos are on the source page of YouTube video link
- To be able to download them, the signature has to be "decoded"
"s= [encoded Key].... " => "
signature=[decoded Key] ...."
It uses for example (link can be found on the source page) :
=> hxxps://s.ytimg.com/yts/jsbin/player-fr_FR-vfllzCe0j/
base.js
- They change very often this file / functions (names, methods) :
Example : from 17_08_2016 :
Here, signature =
By(s) - found inside the
base.js file - will change in few days
By=function(a){
a=a.split("");
Ay.cV(a,3);
Ay.LF(a,50);
Ay.xS(a,5);
Ay.LF(a,46);
Ay.LF(a,5);
Ay.cV(a,2);
return a.join("")
};
Ay={
xS:function(a){
a.reverse()
},
LF:function(a,b){
var c=a[0];
a[0]=a[b%a.length];
a=c
},
cV:function(a,b){
a.splice(0,b)
}
};
=> s3 w50 r w46 w5 s2
(splice 3 , swap 0 50, reverse, swap 0 46, swap 0 5 , splice 2 )
An example :
s= 32F32F75167E33997472D3D0A05FD5D4A0451AE7DDB.B25DB7C863DBBC4628B9936CD62FBF14FD5BE02E2C
splice 3:
32F32F75167E33997472D3D0A05FD5D4A0451AE7DDB.B25DB7C863DBBC4628B9936CD62FBF14FD5BE02E2C
32F75167E33997472D3D0A05FD5D4A0451AE7DDB.B25DB7C863DBBC4628B9936CD62FBF14FD5BE02E2C
swap 0 50:
32F75167E33997472D3D0A05FD5D4A0451AE7DDB.B25DB7C86
3DBBC4628B9936CD62FBF14FD5BE02E2C
reverse:
C2E20EB5DF41FBF26DC6399B8264CBBD368C7BD52B.BDD7EA1540A4D5DF50A0D3D27479933E76157F23
swap 0 46:
72E20EB5DF41FBF26DC6399B8264CBBD368C7BD52B.BDD
CEA1540A4D5DF50A0D3D27479933E76157F23
swap 0 5:
E2E20
7B5DF41FBF26DC6399B8264CBBD368C7BD52B.BDDCEA1540A4D5DF50A0D3D27479933E76157F23
splice 2:
E2E207B5DF41FBF26DC6399B8264CBBD368C7BD52B.BDDCEA1540A4D5DF50A0D3D27479933E76157F23
E207B5DF41FBF26DC6399B8264CBBD368C7BD52B.BDDCEA1540A4D5DF50A0D3D27479933E76157F23
became:
signature=E207B5DF41FBF26DC6399B8264CBBD368C7BD52B.BDDCEA1540A4D5DF50A0D3D27479933E76157F23
Then a program / script can easily retrieve the webpage content of the video, look inside the structure and find :
- title,
- urls for different quality of videos
- itag info => itag structure => gives the size (1280x720, 640x360 etc)
- etc,...
With the link I gave as "example" we can find :
Normals :
- 1280x720 - video/mp4; codecs="avc1.64001F, mp4a.40.2"
- 640x360 - video/webm; codecs="vp8.0, vorbis"
- 640x360 - video/mp4; codecs="avc1.42001E, mp4a.40.2"
- 320x180 - video/3gpp; codecs="mp4v.20.3, mp4a.40.2"
- 176x144 - video/3gpp; codecs="mp4v.20.3, mp4a.40.2"
Adaptives :
- 1920x1080 - video/mp4; codecs="avc1.640028"
- 1920x1080 - video/webm; codecs="vp9"
- 1280x720 - video/mp4; codecs="avc1.4d401f"
- 1280x720 - video/webm; codecs="vp9"
- 854x480 - video/mp4; codecs="avc1.4d401e"
- 854x480 - video/webm; codecs="vp9"
- 640x360 - video/mp4; codecs="avc1.4d401e"
- 640x360 - video/webm; codecs="vp9"
- 426x240 - video/mp4; codecs="avc1.4d4015"
- 426x240 - video/webm; codecs="vp9"
- 256x144 - video/mp4; codecs="avc1.4d400c"
- 256x144 - video/webm; codecs="vp9"
- - audio/mp4; codecs="mp4a.40.2"
- - audio/webm; codecs="vorbis"
- - audio/webm; codecs="opus"
- - audio/webm; codecs="opus"
- - audio/webm; codecs="opus"
When playing a video on YouTube, the browser will make the job for you:
select the quality you want, from the video reader and then :
F12 to open advanced option,
- look at the network requests
- search for a video type in use (several occurence)
- copy paste the url
- delete the range parameter and its content
Example :
hxxps://
www.youtube.com/watch?v=oG08ukJPtR8
hxxps://r8---sn-aigllnze.googlevideo.com/videoplayback?...
....
....
&ratebypass=yes&
signature=E207B5DF41FBF26DC6399B8264CBBD368C7BD52B.BDDCEA1540A4D5DF50A0D3D27479933E76157F23&c=WEB&cver=1.20160817&
range=486745-825314&rn=10&rbuf=27797
Delete
range=486745-825314
=> you have now a temporarily working URL to download the whole file.
(ONLY DOWNLOAD THE FILES YOU OWN )
Each time you refresh the main page, the structure of videos available is here, but parameters are in another order, and s Keys are different.
The main part I describe is interesting when a person want to make a program to directly have all videos available for one video link, and choose the one he prefers.
In the source code, there are also links for files with video and music separated