Open kelvinRosa opened 5 years ago
Can't play some videos: https://www.youtube.com/watch?v=uy3KFOykGQc for example
If someone knows about regex, i saw this operation in youtubedl
(r'(["\'])signature\1\s,\s(?P
I Fixed it
When i did the funcPattern Match, there wasn't only one result.
so I have appended all Matches value to val funcbody
DecipherWithVersion Method in Decipher.cs line 18 string funcPattern = @"(?!h.)" + @funcName + @"=function(\w+){.*?};"; var funcBody = Regex.Match(js, funcPattern, RegexOptions.Singleline).Value; var lines = funcBody.Split(';'); funcBody = ""; foreach (Match m in Regex.Matches(js, funcPattern, RegexOptions.Singleline)) { funcBody += m.Value +";"; } lines = funcBody.Split(';');
Did you changed some other line? can you update with your code, i tried that you said with no sucess, the video still cant play.
What about your GetHtml5PlayerVersion function, that video in question i can't play it: https://www.youtube.com/watch?v=uy3KFOykGQc
@dgesc217 its happening with some music videos.
Maybe youtubedl changed something related that too: https://github.com/ytdl-org/youtube-dl/commit/63529e935cf5f87e6080607ef9d9196fe435e092#diff-bd8242a0122c5207531954b67e6e51f0
I think that commit is too long ago in order to apply to latest Youtube change
I have a custom version here, was working until yesterday
My GetHtml5PlayerVersion look like that:
private static string GetHtml5PlayerVersion(JObject json) { var regex = new Regex(@"player_ias-(.+?).js");
string js = json["assets"]["js"].ToString();
Match match = regex.Match(js);
if (match.Success) return match.Result("$1");
regex = new Regex(@"player-(.+?).js");
return regex.Match(js).Result("$1");
}
Still works for normal youtube videos, but some music videos is not working i think is something in decipher.
Seems that almost all music related videos can't work also on my end.
It works fine with videos that don't require Decipher. The problem is the Decipher.. In DecipherWithVersion method,
var funcName = Regex.Match(js, functNamePattern).Groups[1].Value;
always returns an empty string.
funcNamePattern is obvious the problem.
This is the funcname from youtubedl:
funcname = self._search_regex(
(r'(["\'])signature\1\s,\s(?P
Looks like it working on their side.
the funcnamepattern that i have on my side is: string functNamePattern = @"(\w+)\s=\sfunction(\s(\w+)\s)\s{\s\2\s=\s\2.split(\""\"")\s;(.+)return\s\2.join(\""\"")\s}\s;";
@superfly71 I noticed that my funcName is returning "u"
Someone knows how to convert this regex from python to c#? funcname = self._search_regex( (r'(["'])signature\1\s,\s(?P[a-zA-Z0-9$]+)(', r'.sig||(?P[a-zA-Z0-9$]+)(', r'yt.akamaized.net/)\s||\s.?\sc\s&&\sd.set([^,]+\s,\s(?:encodeURIComponent\s()?(?P[a-zA-Z0-9$]+)(', r'\bc\s&&\sd.set([^,]+\s,\s(?:encodeURIComponent\s()?\s(?P[a-zA-Z0-9$]+)(', r'\bc\s&&\sd.set([^,]+\s,\s([^)])\s(\s(?P[a-zA-Z0-9$]+)('), jscode, 'Initial JS player signature function name', group='sig')
LoL, back to work here for me.
You can use RegexHero to prototype a C# regex http://regexhero.net/tester/
@jzabroski thank you, i'll take a look and try.
also not working for me. I'm getting "Could not find the entry function for signature deciphering." Music Box is counting on you guys. Help me bring free happiness to people :)
Yoirgl
@kelvinRosa Your python regex is malformed. I didn't download the source code for youtube-dl so I don;t know what's going on in there..
@superfly71 i saw that regex here: https://github.com/ytdl-org/youtube-dl/commit/fa4ac365f69cbd51e4c9801984ebea49a12825b7#diff-bd8242a0122c5207531954b67e6e51f0
@kelvinRosa I have tested all the regex's (Individually) in the link you provided but nope, none of the regex matches the current js code.
The js code (js) I'm using is:
string jsUrl = string.Format("http://s.ytimg.com/yts/jsbin/player_ias-{0}.js", cipherVersion);
string js = HttpHelper.DownloadString(jsUrl);
I think this link might be helpful. It doesn't give you the code you need but it does explain how youtube-dl deciphers.
https://www.quora.com/How-can-I-make-a-YouTube-video-downloader-web-application-from-scratch
The link says youtube-dl uses a Javascript interpreter.
I'm currently doing a POC using Jint https://github.com/sebastienros/jint but it doesn't have a good Javascript debugger.
@kelvinRosa I cloned the Python source code for youtube-dl. Downloaded PyCharm and started debugging with breakpoints.
The function with the regex's in your link does not even execute when youtbe-dl is run.
Here is the python function which is not even executed:
def _parse_sig_js(self, jscode): funcname = self._search_regex( (r'(["\'])signature\1\s,\s(?P
[a-zA-Z0-9$]+)(', r'.sig||(?P [a-zA-Z0-9$]+)(', r'yt.akamaized.net/)\s||\s.?\sc\s&&\sd.set([^,]+\s,\s(?:encodeURIComponent\s()?(?P [a-zA-Z0-9$]+)(', r'\bc\s &&\sd.set([^,]+\s,\s(?:encodeURIComponent\s()?\s(?P[a-zA-Z0-9$]+)(', r'\bc\s &&\sd.set([^,]+\s,\s([^)])\s(\s(?P[a-zA-Z0-9$]+)('), jscode, 'Initial JS player signature function name', group='sig') jsi = JSInterpreter(jscode) initial_function = jsi.extract_function(funcname) return lambda s: initial_function([s])
Try stepping through youtube-dl and see why it is working.
funcname is not even relevant now.
Hi, today stopped again, anyone is having this issue ?, 403.