YoutubeExtractor icon indicating copy to clipboard operation
YoutubeExtractor copied to clipboard

Parse exception

Open gen3vra opened this issue 7 years ago • 39 comments

It's broken again. What do we change this time?

gen3vra avatar Dec 16 '18 03:12 gen3vra

Please look at pull request #333 , I hope it will solve your problems.

anilgit90 avatar Dec 17 '18 08:12 anilgit90

Not working. Issue exposed is "Could not decipher signature" but specific exception is 404 not found reported by ex variable. This after new EU law of copyright started on 13 dec. screenshot

SoftwareMagicIT avatar Dec 17 '18 09:12 SoftwareMagicIT

Ohh So the issue is country specific. My issue got resolved after I used the above fix in the pull request. Maybe I will try using VPN to test your specific case.

anilgit90 avatar Dec 17 '18 18:12 anilgit90

Hi Could you please post the link of the video you are trying to download, because today i tried to download using VPN, By connecting to France Server, and i did not get any 404 error.

anilgit90 avatar Dec 18 '18 06:12 anilgit90

Couldn't use your solution @anilgit90 because your fork doesn't build the "Full" version of it, just the "Portable" one for some reason. And the portable one doesn't include the VideoDownloader class. Additionally, applying your changes to this repo results in a lot of YoutubeParseExceptions anyway. Does this work for you?

gen3vra avatar Dec 19 '18 08:12 gen3vra

All the changes that have done has been tested then I have raised the pull request. I tried to recreate your issue by using a VPN but, the issue that you are facing is not being recreated. Could we maybe co-ordinate over teamviewer to resolve the issue you are facing?

anilgit90 avatar Dec 19 '18 13:12 anilgit90

Please you can contact me over email, I can use anydesk and load source code for seeing issue in my computer.

SoftwareMagicIT avatar Dec 19 '18 15:12 SoftwareMagicIT

Yeah Sure. I will get back to you, Just Gimme some time. Meanwhile i was able to recreate the issue, seems like it occurs in some youtube videos but not all @GMR516 mentioned the parseException, I was able to re-create that issue with one youtube link, seem to me like a regex matching isssue. Let me see if I can fix or pinpoint what seems to be the issue. I will get back to you @GMR516 and @SoftwareMagicIT once I have something concrete.

anilgit90 avatar Dec 19 '18 18:12 anilgit90

@anilgit90 Thank you very much. Greatly appreciated.

gen3vra avatar Dec 20 '18 08:12 gen3vra

I investigate: don't found this: http://s.ytimg.com/yts/jsbin/player-ias-vflSzU_20/it_IT/base.js

ok, solved: I changed player-{0} in decipher with player_{0} and now work

SoftwareMagicIT avatar Dec 25 '18 22:12 SoftwareMagicIT

Your link doesn't seem to work @SoftwareMagicIT

gen3vra avatar Jan 01 '19 23:01 gen3vra

I chaned to "Solved" my previous comment. The link http://s.ytimg.com/yts/jsbin/player-ias-vflSzU_20/it_IT/base.js not working but the link is generated from http://s.ytimg.com/yts/jsbin/player-{0}.js getting part of page passed by argument. I changed with http://s.ytimg.com/yts/jsbin/player_{0}.js and now this work

SoftwareMagicIT avatar Jan 02 '19 06:01 SoftwareMagicIT

@SoftwareMagicIT that was the fix I was pushing for. Sorry for the delay. I was busy due to the new year.

anilgit90 avatar Jan 04 '19 05:01 anilgit90

No problem and happy 2019 xD

SoftwareMagicIT avatar Jan 04 '19 07:01 SoftwareMagicIT

I hope the latest pull request solved the problem @GMR516 @SoftwareMagicIT. Could you guys check it and let me know. @SoftwareMagicIT the pull request contains the fix that you discovered.

anilgit90 avatar Jan 04 '19 13:01 anilgit90

I tested, work fine.

SoftwareMagicIT avatar Jan 04 '19 14:01 SoftwareMagicIT

The decryption seems to be failing for this url - "https://www.youtube.com/watch?v=YQHsXMglC9A". The decryption method fails to decrypt the signature, so on trying to access the 'decrypted' url, it gives 403. Can you guys give it a try?

ac-lap avatar Jan 05 '19 05:01 ac-lap

I try and in my version work fine

SoftwareMagicIT avatar Jan 05 '19 07:01 SoftwareMagicIT

@SoftwareMagicIT, were you able to access the video from the decrypted URL? For me the encrypted and decrypted signature are same.

I am assuming in your version, you didn't do any change in the public static string DecipherWithVersion(string cipher, string cipherVersion) method in Decipherer.cs My jsUrl looks something like this - "http://s.ytimg.com/yts/jsbin/player_ias-vflWb9AD2/en_US/base.js"

ac-lap avatar Jan 05 '19 07:01 ac-lap

  1. replace http with https in all http url of project (this speedup download because skip redirect)
  2. this is my decipherwithversion:

`public static string DecipherWithVersion(string cipher, string cipherVersion) { string jsUrl = string.Format("https://s.ytimg.com/yts/jsbin/player_{0}.js", cipherVersion);

		string js = HttpHelper.DownloadString(jsUrl);

		//Find "C" in this: var A = B.sig||C (B.s)
		string functNamePattern = @"\""signature"",\s?([a-zA-Z0-9\$]+)\(";

		var funcName = Regex.Match(js, functNamePattern).Groups[1].Value;

		if (funcName.Contains("$"))
		{
			funcName = "\\" + funcName; //Due To Dollar Sign Introduction, Need To Escape
		}

		string funcPattern = @"(?!h\.)" + @funcName + @"(\w+)\s*=\s*function\(\s*(\w+)\s*\)\s*{\s*\2\s*=\s*\2\.split\(\""\""\)\s*;(.+)return\s*\2\.join\(\""\""\)\s*}\s*;"; //Escape funcName string
		var funcBody = Regex.Match(js, funcPattern, RegexOptions.Singleline).Value; //Entire sig function
		var lines = funcBody.Split(';'); //Each line in sig function

		string idReverse = "", idSlice = "", idCharSwap = ""; //Hold name for each cipher method
		string functionIdentifier = "";
		string operations = "";

		foreach (var line in lines.Skip(1).Take(lines.Length - 2)) //Matches the funcBody with each cipher method. Only runs till all three are defined.
		{
			if (!string.IsNullOrEmpty(idReverse) && !string.IsNullOrEmpty(idSlice) &&
				!string.IsNullOrEmpty(idCharSwap))
			{
				break; //Break loop if all three cipher methods are defined
			}

			functionIdentifier = GetFunctionFromLine(line);
			string reReverse = string.Format(@"{0}:\bfunction\b\(\w+\)", functionIdentifier); //Regex for reverse (one parameter)
			string reSlice = string.Format(@"{0}:\bfunction\b\([a],b\).(\breturn\b)?.?\w+\.", functionIdentifier); //Regex for slice (return or not)
			string reSwap = string.Format(@"{0}:\bfunction\b\(\w+\,\w\).\bvar\b.\bc=a\b", functionIdentifier); //Regex for the char swap.

			if (Regex.Match(js, reReverse).Success)
			{
				idReverse = functionIdentifier; //If def matched the regex for reverse then the current function is a defined as the reverse
			}

			if (Regex.Match(js, reSlice).Success)
			{
				idSlice = functionIdentifier; //If def matched the regex for slice then the current function is defined as the slice.
			}

			if (Regex.Match(js, reSwap).Success)
			{
				idCharSwap = functionIdentifier; //If def matched the regex for charSwap then the current function is defined as swap.
			}
		}

		foreach (var line in lines.Skip(1).Take(lines.Length - 2))
		{
			Match m;
			functionIdentifier = GetFunctionFromLine(line);

			if ((m = Regex.Match(line, @"\(\w+,(?<index>\d+)\)")).Success && functionIdentifier == idCharSwap)
			{
				operations += "w" + m.Groups["index"].Value + " "; //operation is a swap (w)
			}

			if ((m = Regex.Match(line, @"\(\w+,(?<index>\d+)\)")).Success && functionIdentifier == idSlice)
			{
				operations += "s" + m.Groups["index"].Value + " "; //operation is a slice
			}

			if (functionIdentifier == idReverse) //No regex required for reverse (reverse method has no parameters)
			{
				operations += "r "; //operation is a reverse
			}
		}

		operations = operations.Trim();

		return DecipherWithOperations(cipher, operations);
	}`

SoftwareMagicIT avatar Jan 05 '19 08:01 SoftwareMagicIT