This repository was archived by the owner on Sep 28, 2020. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -89,7 +89,9 @@ private static void DownloadVideo(IEnumerable<VideoInfo> videoInfos)
8989 private static void Main ( )
9090 {
9191 // Our test youtube link
92- const string link = "https://www.youtube.com/watch?v=YQHsXMglC9A" ;
92+ //const string link = "https://www.youtube.com/watch?v=D92-DmVmB8Y"; // -> needs deciphering
93+
94+ const string link = "https://www.youtube.com/watch?v=2a4Uxdy9TQY" ; // -> needs no deciphering
9395
9496 /*
9597 * Get the available video formats.
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ public static string DecipherWithVersion(string cipher, string cipherVersion)
1313 string js = HttpHelper . DownloadString ( jsUrl ) ;
1414
1515 //Find "yv" in this: c&&a.set(b,encodeURIComponent(yv(
16- string functNamePattern = @"\b[cs]\s*&&\s*[adf]\.set\([^,]+\s*,\s*encodeURIComponent\s*\(\s*([\w$]+)\( " ; //Regex Formed To Find Word or DollarSign
16+ string functNamePattern = @"(\w+)=function\(\w+\){(\w+)=\2\.split\(\x22{2}\);.*?return\s+\2\.join\(\x22{2}\)} " ; //Regex Formed To Find Word or DollarSign
1717
1818 var funcName = Regex . Match ( js , functNamePattern ) . Groups [ 1 ] . Value ;
1919
@@ -22,7 +22,7 @@ public static string DecipherWithVersion(string cipher, string cipherVersion)
2222 funcName = "\\ " + funcName ; //Due To Dollar Sign Introduction, Need To Escape
2323 }
2424
25- string funcPattern = @"(?!h\.)" + @funcName + @"=function\(\w+\)\{.*?\}" ; //Escape funcName string
25+ string funcPattern = @"(?!h\.)" + @funcName + @"=function\(\w+\)\{( .*?) \}" ; //Escape funcName string
2626 var funcBody = Regex . Match ( js , funcPattern , RegexOptions . Singleline ) . Value ; //Entire sig function
2727 var lines = funcBody . Split ( ';' ) ; //Each line in sig function
2828
Original file line number Diff line number Diff line change @@ -187,13 +187,21 @@ private static IEnumerable<ExtractionInfo> ExtractDownloadUrls(JObject json)
187187 if ( queries . ContainsKey ( "s" ) || queries . ContainsKey ( "sig" ) )
188188 {
189189 requiresDecryption = queries . ContainsKey ( "s" ) ;
190- string signature = queries . ContainsKey ( "s" ) ? queries [ "s" ] : queries [ "sig" ] ;
191190
192- url = string . Format ( "{0}&{1}={2}" , queries [ "url" ] , SignatureQuery , signature ) ;
191+ if ( requiresDecryption )
192+ {
193+ string signature = queries . ContainsKey ( "s" ) ? queries [ "s" ] : queries [ "sig" ] ;
194+
195+ url = string . Format ( "{0}&{1}={2}" , queries [ "url" ] , SignatureQuery , signature ) ;
193196
194- string fallbackHost = queries . ContainsKey ( "fallback_host" ) ? "&fallback_host=" + queries [ "fallback_host" ] : String . Empty ;
197+ string fallbackHost = queries . ContainsKey ( "fallback_host" ) ? "&fallback_host=" + queries [ "fallback_host" ] : String . Empty ;
195198
196- url += fallbackHost ;
199+ url += fallbackHost ;
200+ }
201+ else
202+ {
203+ url = NormalizeUrl ( s ) ;
204+ }
197205 }
198206
199207 else
@@ -347,5 +355,10 @@ private class ExtractionInfo
347355
348356 public Uri Uri { get ; set ; }
349357 }
358+
359+ private static string NormalizeUrl ( string url )
360+ {
361+ return url . Replace ( "\" " , "" ) . Replace ( "url=" , "" ) ;
362+ }
350363 }
351364}
You can’t perform that action at this time.
0 commit comments