YePpHa / YouTubeCenter

YouTube Center is a userscript designed to expand the functionality of YouTube. It includes the ability to download the video you're watching, auto selecting your preferred video quality and much more.
MIT License
2.89k stars 520 forks source link

Certain videos unable to be downloaded? #2098

Open ROMaster2 opened 8 years ago

ROMaster2 commented 8 years ago

Example: https://www.youtube.com/watch?v=Lq6rEPBN7aA

I think it has something to do with Music videos; I have a harder time being able to download them. When I try to I just get a blank page.

wiki84user commented 8 years ago

Your link downloads for me, I tested WebM, MP4 and Audio formats. I'm using Build 533, with no Flash plugin (in fact I have zero Adobe products on my PC in any case).

However, there are videos that refuse to download starting two days ago with YTC: for example all of xisumavoid's recent uploads, Click on download and a new tab opens starting with a very long URL https://r5---sn-1gi7zn7y.googlevideo.com/videoplayback?requiressl= ... BD53. (920 bytes in total) xisuma's second channel videos are not affected.

When I switch to the Greasemonkey-compatible userscript "Download YouTube Videos as MP4", they download fine.

I've done the usual, such as clear all cookies, history, fresh Firefox profiles, reboot PC, and the problem is repeatable.

raszpl commented 8 years ago

its not music, this obscure doc from 2011 is also affected https://www.youtube.com/watch?v=s4A0Lc6DI7A

checked youtube-dl and same thing youtube-dl.exe https://www.youtube.com/watch?v=s4A0Lc6DI7A --no-check-certificate [youtube] s4A0Lc6DI7A: Downloading webpage [youtube] s4A0Lc6DI7A: Downloading video info webpage [youtube] s4A0Lc6DI7A: Extracting video information ERROR: Signature extraction failed: Traceback (most recent call last): File "youtube_dl\extractor\youtube.pyo", line 817, in _decrypt_signature File "youtube_dl\extractor\youtube.pyo", line 709, in _extract_signature_function ExtractorError: Cannot identify player u'https://s.ytimg.com/yts/jsbin/player-en_US-vflJENbn4/base.js'; please

updated youtube-dl to newest version and works again, so YT updated something and is rolling it out slowly Ill look into the code and will try to find a way to fix it while YePpHa is absent

raszpl commented 8 years ago

https://github.com/rg3/youtube-dl/issues/7362

raszpl commented 8 years ago

nope, that was red herring problem is in signature decoding. I extracted correct signature from a random non working video using "Download YouTube Videos as MP4" :

signature=0AAA855F10FB9DF7DE9F628130341C8AD258167A.0EF6AB3CD60BC9A3A894E6895408CCE83CF8AF

and using YTCenter:

signature=33A8FC38ECC8045986E498A3A9CB06DCFBA6FE0.A761852DA8C143031826F9ED7FD9BF01F558AAA0

and another one good:95219782317C624F7344C55553777E550EA6FB1E.0266FC1BF77E79ED80046EC1212FFED3E9192092 baad:FF902919E3DEFF2121CE64008DE97E772B1CF6620.E1BF6AE055E77735555C4437F426C71328791259

its remarkably similar, mirror image with 1 byte too many and last byte wrong

Nuriell commented 8 years ago

Video that do not download have special characters in their name that break the download link for some reasons, i happened on similar video different times, i have found an alternative download method in JDownloader for those vides.

raszpl commented 8 years ago

I have videos with no weird characters that dont download, like https://www.youtube.com/watch?v=X7VwNDbfAhI

Spend an hour hacking at this, but those regexes and sphagetti of js code is beyond me :/ The best I could do was to grab "Download YouTube Videos as MP4" decoder function outright and force it in the YTcenter at 12511 line, in this spot: } else { con.error("[updateSignatureDecipher] Couldn't retrieve the signatureDecipher!"); }

that way signatures not decoded by YTcenter were decoded by code from other plugin, but my inability to understand YTcenter way of handling signatures broke all the other videos :/ at the end I just gave up, disabled downloads and started using "Download YouTube Videos as MP4" :/

Yonezpt commented 8 years ago

YouTube recently released a vastly different iteration of their HTML5 player source code. The script itself is also no longer named "html5player/html5player" but "player/base" instead, with its respective file being at the moment for me:

https://s.ytimg.com/yts/jsbin/www-en_US-vfliCtAF-/base.js

The algorithm remains the same (structure wise) as far as I can see. It is more spaced out, half more on top, the other half further down:

var ar = {
    JY: function(a, b) {
        var c = a[0];
        a[0] = a[b % a.length];
        a[b] = c
    },
    lM: function(a, b) {
        a.splice(0, b)
    },
    LB: function(a) {
        a.reverse()
    }
};

var $q = function(a) {
    a = a.split("");
    ar.lM(a, 1);
    ar.JY(a, 31);
    ar.LB(a, 47);
    return a.join("")
};

So what is happening is that the regex match YTC uses for the first half is very outdated, given by this line in YTC source code:

regex2 = /function [a-zA-Z$0-9]+\(a\){a=a\.split\(""\);(((a=([a-zA-Z$0-9]+)\(a,([0-9]+)\);)|(a=a\.slice\([0-9]+\);)|(a=a\.reverse\(\);)|(var b=a\[0\];a\[0\]=a\[[0-9]+%a\.length\];a\[[0-9]+\]=b;)))*return a\.join\(""\)}/g;

YouTube's algorithm hasn't used a.split or a.slice for quite some time and replaced it with a.splice instead, so there's no way YTC can generate a valid signature for videos that require it in order to download.

The solution should be as simple as updating that regex. I don't think the other one needs to be updated as well, looks like it is still working, but in case it doesn't just update it too.

All other videos that have been downloaded with YTC with no issues are all videos that didn't require the signature.

muyte commented 8 years ago

Since today I can't download a lot of videos. It saves an empty file called videoplayback.txt

LittleVulpix commented 8 years ago

Yeah, most of the videos just open a white page instead of giving a download :+1: to having this fixed @YePpHa ! Also gj on your new job! :)