Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Signature Length 86 #1156

Closed
awojnowski opened this issue Jul 31, 2013 · 14 comments
Closed

Signature Length 86 #1156

awojnowski opened this issue Jul 31, 2013 · 14 comments

Comments

@awojnowski
Copy link
Contributor

@awojnowski awojnowski commented Jul 31, 2013

Looks like YouTube's updated again.

Original Signature: 18184C5956D99A143BE0648737901F7AC5E209E46C.7DBEBFD57B779CA99ECEEEBA6B2B048458C0B530536
Cracked Signature: 539B0C854840B2B6ABEEECE99AC977B75DFB6BD7.C64E972E5CAEF1007378460EB341A99D6595C481

Original Signature: 808026AE3640F502A7693FD1256FCFD177E7176A35.9203A412593C8771B7C6A910CF310710A3824B81B84
Cracked Signature: B864283A017013FC019A6C7B1778C395214A4029.53A67D7E7713FCF1521DF3967A205F0463EA6208

Here's YouTube's decryption algorithm taken from their HTML 5 player (where the function fj cracks the signature and a is the signature input):

function fj(a) {
    a = a.split("");
    a = a.slice(2);
    a = a.reverse();
    a = gj(a, 39);
    a = gj(a, 55);
    a = gj(a, 49);
    a = a.slice(3);
    a = gj(a, 56);
    a = gj(a, 2);
    return a.join("")
}

function gj(a, b) {
    var c = a[0];
    a[0] = a[b % a.length];
    a[b] = c;
    return a
};
@patrickslin
Copy link
Contributor

@patrickslin patrickslin commented Jul 31, 2013

@speedyapocalypse where did you pull the decryption algo from? Is it working for all sig lengths or only 86?

@awojnowski
Copy link
Contributor Author

@awojnowski awojnowski commented Jul 31, 2013

@patrickslin I believe it just works for 86 and changes when YouTube updates their player. Email me and I can send you my method of getting the decryption algorithm (it's quite simple, but I just don't want to post it publicly). I believe this algorithm doesn't work on some videos (it failed some tests when we tried to swap to this method a while back) which is why manual signature comparison still has to be done. For my personal purposes, however, the algorithm works just fine.

@jhb50
Copy link

@jhb50 jhb50 commented Jul 31, 2013

Yes 86 changed again. This vid no longer works "http://www.youtube.com/watch?v=xbO3dfF9uuE"
old signature was A0A006F8A09C977D3D1930B1F5D91E538DA21FCAE6.4F2F98466A3BA20E8E4FBC9708A7846AD569B571574
new signature is A006F8A09C977D3D1930B1F5D91E538DA21FCAE6.4F2F98466A3BA20E8E4F1C9708A7846AD569B57B

@cinereous
Copy link

@cinereous cinereous commented Jul 31, 2013

I can't give good info, but I can give a test vid that doesn't work. (The last youtube-dl fixed a bunch of other Vevo vids (2013.07.25.2) so they really seem to be a moving target. A quick note of thanks to all the devs; you guys are doing an amazing job keeping up.

Anyway, here's another video to test with, that doesn't work:
youtube-dl http://www.youtube.com/watch?v=PxNYvk_0Onw -v
[debug] System config: []
[debug] User config: []
[debug] Command-line args: ['http://www.youtube.com/watch?v=PxNYvk_0Onw', '-v']
[debug] youtube-dl version 2013.07.25.2
[debug] Python version 2.7.3rc2 - Linux-3.5.3-debian-wheezy-sid
[debug] Proxy map: {}
[youtube] Setting language
[youtube] PxNYvk_0Onw: Downloading video webpage
[youtube] PxNYvk_0Onw: Downloading video info webpage
[youtube] PxNYvk_0Onw: Extracting video information
[youtube] PxNYvk_0Onw: Encrypted signatures detected.
[youtube] encrypted signature length 86 (42.43), itag 46, html5 player vflm_D8eE
[youtube] encrypted signature length 86 (42.43), itag 37, html5 player vflm_D8eE
[youtube] encrypted signature length 86 (42.43), itag 45, html5 player vflm_D8eE
[youtube] encrypted signature length 86 (42.43), itag 22, html5 player vflm_D8eE
[youtube] encrypted signature length 86 (42.43), itag 44, html5 player vflm_D8eE
[youtube] encrypted signature length 86 (42.43), itag 35, html5 player vflm_D8eE
[youtube] encrypted signature length 86 (42.43), itag 43, html5 player vflm_D8eE
[youtube] encrypted signature length 86 (42.43), itag 34, html5 player vflm_D8eE
[youtube] encrypted signature length 86 (42.43), itag 18, html5 player vflm_D8eE
[youtube] encrypted signature length 86 (42.43), itag 5, html5 player vflm_D8eE
[youtube] encrypted signature length 86 (42.43), itag 36, html5 player vflm_D8eE
[youtube] encrypted signature length 86 (42.43), itag 17, html5 player vflm_D8eE
ERROR: unable to download video
Traceback (most recent call last):
File "/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 573, in download
videos = self.extract_info(url)
File "/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 327, in extract_info
return self.process_ie_result(ie_result, download=download)
File "/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 410, in process_ie_result
for r in ie_result['entries']
File "/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 357, in process_ie_result
self.process_info(ie_result)
File "/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 550, in process_info
raise UnavailableVideoError()
UnavailableVideoError

@patrickslin
Copy link
Contributor

@patrickslin patrickslin commented Jul 31, 2013

New sig len 86 algo (manual):

python:
s[83:85] + s[26] + s[79:46:-1] + s[85] + s[45:36:-1] + s[30] + s[35:30:-1] + s[46] + s[29:26:-1] + s[82] + s[25:1:-1]

javascript:
s.slice(83, 85).join('') + s[26] + s.slice(47, 80).reverse().join('') + s[85] + s.slice(37, 46).reverse().join('') + s[30] + s.slice(31, 36).reverse().join('') + s[46] + s.slice(27, 30).reverse().join('') + s[82] + s.slice(2, 26).reverse().join('')

@AndreiArba
Copy link
Contributor

@AndreiArba AndreiArba commented Jul 31, 2013

I think the correct python decryption for 86 length signature is:
return s[80:82] + s[26] + s[80,47,-1] + s[85] + s[46,37,-1] + s[30] + s[36,31,-1] + s[46] + s[30,27,-1]+s[36] + s[26,2,-1]

@Baqan
Copy link

@Baqan Baqan commented Jul 31, 2013

@patrickslin your algo for length 86 work for common Vevo videos, but does not work with Vevo age-blocked videos, like this:

http://www.youtube.com/watch?v=07FYdnEawAQ

@patrickslin
Copy link
Contributor

@patrickslin patrickslin commented Jul 31, 2013

@AndreiArba I believe that the first two chars are the same for s[83:85] and s[80:82], so it doesn't seem to matter which slice you take. For the rest, when you slice with reverse step, the start item is included, but the stop is not. So, s.slice(47, 80).reverse().join('') translates to we want 47-79 (inclusive), or s[79:46:-1] (i.e. first item we don't want is index 46, so 47-79 reverse.

@Baqan I tried the javascript algo and it worked for the video that you mention. So, it should be correct, unless my python port is wrong...

@AndreiArba
Copy link
Contributor

@AndreiArba AndreiArba commented Jul 31, 2013

You're right @patrickslin. I made a confusion because in php I used to make substr(47,33), meaning chars 47-79 and then strrev(string reverse) and I taught in python is the same way(first taking the substring and then reverting it).

@jaimeMF
Copy link
Collaborator

@jaimeMF jaimeMF commented Jul 31, 2013

Thanks to all of you for the reports and the help!

For age protected videos it uses the same length but the old algorithm, so for these videos it have to use the old one.

@phihag
Copy link
Contributor

@phihag phihag commented Jul 31, 2013

For all affected users: These changes have been integrated in youtube-dl 2013.07.31. Type

sudo youtube-dl -U

to update.

@phihag phihag reopened this Jul 31, 2013
@phihag phihag closed this Jul 31, 2013
@gary9872
Copy link

@gary9872 gary9872 commented Aug 14, 2013

The Biebs is working but not Katy is not.

[debug] System config: []
[debug] User config: []
[debug] Command-line args: ['-v', 'http://www.youtube.com/watch?v=QGJuMBdaqIw']
[debug] youtube-dl version 2013.08.09
[debug] Python version 2.7.3 - Linux-3.5.7-gentoo-x86_64-AMD_Athlon-tm-_II_X4_640_Processor-with-gentoo-2.2
[debug] Proxy map: {}
[youtube] Setting language
[youtube] QGJuMBdaqIw: Downloading video webpage
[youtube] QGJuMBdaqIw: Downloading video info webpage
[youtube] QGJuMBdaqIw: Extracting video information
[youtube] QGJuMBdaqIw: Encrypted signatures detected.
[youtube] encrypted signature length 83 (41.41), itag 46, html5 player vfl1HXdPb
[youtube] encrypted signature length 83 (41.41), itag 37, html5 player vfl1HXdPb
[youtube] encrypted signature length 83 (41.41), itag 45, html5 player vfl1HXdPb
[youtube] encrypted signature length 83 (41.41), itag 22, html5 player vfl1HXdPb
[youtube] encrypted signature length 83 (41.41), itag 44, html5 player vfl1HXdPb
[youtube] encrypted signature length 83 (41.41), itag 35, html5 player vfl1HXdPb
[youtube] encrypted signature length 83 (41.41), itag 43, html5 player vfl1HXdPb
[youtube] encrypted signature length 83 (41.41), itag 34, html5 player vfl1HXdPb
[youtube] encrypted signature length 83 (41.41), itag 18, html5 player vfl1HXdPb
[youtube] encrypted signature length 83 (41.41), itag 5, html5 player vfl1HXdPb
[youtube] encrypted signature length 83 (41.41), itag 36, html5 player vfl1HXdPb
[youtube] encrypted signature length 83 (41.41), itag 17, html5 player vfl1HXdPb
ERROR: unable to download video
Traceback (most recent call last):
File "./youtube-dl/youtube_dl/YoutubeDL.py", line 573, in download
videos = self.extract_info(url)
File "./youtube-dl/youtube_dl/YoutubeDL.py", line 327, in extract_info
return self.process_ie_result(ie_result, download=download)
File "./youtube-dl/youtube_dl/YoutubeDL.py", line 410, in process_ie_result
for r in ie_result['entries']
File "./youtube-dl/youtube_dl/YoutubeDL.py", line 357, in process_ie_result
self.process_info(ie_result)
File "./youtube-dl/youtube_dl/YoutubeDL.py", line 550, in process_info
raise UnavailableVideoError(err)
UnavailableVideoError: HTTP Error 403: Forbidden

@phihag
Copy link
Contributor

@phihag phihag commented Aug 14, 2013

@gary9872 Nice bug report ;) . Fixed in youtube-dl v2013.08.14. Type

sudo youtube-dl -U

to update.

@amit9999
Copy link

@amit9999 amit9999 commented Mar 9, 2014

Hello every one Please send me the process by which i can find out proper function to decrypt youtube signature of all lenght. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
10 participants
You can’t perform that action at this time.