Skip to content

Instantly share code, notes, and snippets.

@Subtixx
Last active January 13, 2022 17:58
Show Gist options
  • Save Subtixx/adbeb96edcbe5f825ee50877a635346b to your computer and use it in GitHub Desktop.
Save Subtixx/adbeb96edcbe5f825ee50877a635346b to your computer and use it in GitHub Desktop.
Zippyshare download c#
public class WebClientEx : WebClient
{
public WebClientEx()
{
}
public WebClientEx(CookieContainer container)
{
this.container = container;
}
public CookieContainer CookieContainer
{
get { return container; }
set { container= value; }
}
private CookieContainer container = new CookieContainer();
protected override WebRequest GetWebRequest(Uri address)
{
WebRequest r = base.GetWebRequest(address);
var request = r as HttpWebRequest;
if (request != null)
{
request.CookieContainer = container;
}
return r;
}
protected override WebResponse GetWebResponse(WebRequest request, IAsyncResult result)
{
WebResponse response = base.GetWebResponse(request, result);
ReadCookies(response);
return response;
}
protected override WebResponse GetWebResponse(WebRequest request)
{
WebResponse response = base.GetWebResponse(request);
ReadCookies(response);
return response;
}
private void ReadCookies(WebResponse r)
{
var response = r as HttpWebResponse;
if (response != null)
{
CookieCollection cookies = response.Cookies;
container.Add(cookies);
}
}
}
public class Zippyshare
{
public static void Downloadfile(string fileUrl)
{
Match m = Regex.Match(fileUrl, @"https?://((?:[\w\-]+))\.*zippyshare\.com/\w/(\w+)", RegexOptions.IgnoreCase);
if(!m.Success)
{
Console.WriteLine("Invalid zippyshare link!");
return;
}
var server = m.Groups[1].Captures[0].Value;
var fid = m.Groups[2].Captures[0].Value;
using(WebClientEx client = new WebClientEx())
{
string website = client.DownloadString(fileUrl);
string regex = "File does not exist on this server";
Match match = Regex.Match(website, regex, RegexOptions.IgnoreCase);
regex = "File has expired and does not exist anymore on this server";
Match match2 = Regex.Match(website, regex, RegexOptions.IgnoreCase);
if(match.Success || match2.Success)
{
Console.WriteLine("File doesn't exist!");
return;
}
var match = Regex.Match(website, @"document\.getElementById\('dlbutton'\)\.href = ""/(pd|d)/(.*)/"" \+ \(([0-9]+) % ([0-9]+) \+ ([0-9]+) % ([0-9]+)\) \+ ""/(.*)"";", RegexOptions.IgnoreCase);
if (!match.Success)
return;
if (match.Groups.Count != 6)
return;
var fileId = match.Groups[1].Captures[0].Value;
var a = int.Parse(match.Groups[2].Captures[0].Value);
var b = int.Parse(match.Groups[3].Captures[0].Value);
var c = int.Parse(match.Groups[4].Captures[0].Value);
var d = int.Parse(match.Groups[5].Captures[0].Value);
var fileName = match.Groups[6].Captures[0].Value;
var num = a % b + c % d;
client.DownloadFile("http://"+server+".zippyshare.com/d/"+fileId+"/" + num + "/"+fileName, fileName);
}
Console.WriteLine("Downloading: " + "http://"+server+".zippyshare.com/d/"+fid+"/" + finalDivide + "/"+fileName);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment