Skip to content
This repository was archived by the owner on Sep 28, 2020. It is now read-only.

Commit edd6487

Browse files
committed
Fix decipher
1 parent 4045f90 commit edd6487

2 files changed

Lines changed: 5 additions & 8 deletions

File tree

YoutubeExtractor/ExampleApplication/Program.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,19 +89,16 @@ 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=D92-DmVmB8Y";
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.
9698
* We'll work with them in the video and audio download examples.
9799
*/
98100
IEnumerable<VideoInfo> videoInfos = DownloadUrlResolver.GetDownloadUrls(link, false);
99101

100-
foreach (var x in videoInfos)
101-
{
102-
Console.WriteLine(x.DownloadUrl);
103-
}
104-
105102
//DownloadAudio(videoInfos);
106103
DownloadVideo(videoInfos);
107104
}

YoutubeExtractor/YoutubeExtractor/Decipherer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)