Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Net;
- using System.Text;
- using System.Threading.Tasks;
- namespace Forking_Database
- {
- class Program
- {
- public static string UrlPrefix = "http://www.superanimes.com/";
- public static Dictionary<string, string> Episodios = new Dictionary<string, string>();
- static void Main(string[] args)
- {
- //using (WebClient Web = new WebClient())
- //{
- // Web.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
- // string Url = Web.UploadString("http://www.superanimes.com/pager.php", "id=eps&offset=4&acao=more&limit=3");
- // using (StringReader Ler = new StringReader(Url))
- // {
- // string Linha;
- // while ((Linha = Ler.ReadLine()) != null)
- // {
- // if (Linha.Contains("<a href="))
- // {
- // var Link = Linha.Split('"')[1].Split('/');
- // Console.WriteLine(Maiuscula(Link[3]));
- // Forking(UrlPrefix + Link[3]);
- // }
- // }
- // }
- // }
- //}
- for (int i = 1; i <= 70; i++)
- {
- ReadPage(i);
- }
- while (true) { }
- }
- public static void ReadPage(int Page)
- {
- using (WebClient Web = new WebClient())
- {
- Stream Site = Web.OpenRead("http://www.superanimes.com/lista?&video=legendado&pagina=" + Page);
- using (StreamReader Ler = new StreamReader(Site))
- {
- string Linha;
- List<string> Try = new List<string>();
- while ((Linha = Ler.ReadLine()) != null)
- {
- var L = Linha.Trim();
- if (L.StartsWith("<a href"))
- {
- if (L.Contains("lista") || L.Contains("mobile") || L.Contains("Pagina") || L.Contains("google"))
- {
- }
- else
- {
- Try.Add(Linha.Trim());
- }
- }
- }
- foreach (var T in Try)
- {
- var SpliT = T.Split('"');
- var Link = SpliT[1].Split('/');
- if (!Anime.Animes.Any(x => x.Link == UrlPrefix + Link[3]))
- {
- Anime.Animes.Add(new Anime
- {
- Nome = Maiuscula(Link[3]),
- Link = UrlPrefix + Link[3]
- });
- Forking(UrlPrefix + Link[3]);
- }
- }
- Console.WriteLine(Page + " Finalizada");
- }
- }
- }
- public static void Forking(string Url)
- {
- try
- {
- if (string.IsNullOrEmpty(Url))
- return;
- using (WebClient Web = new WebClient())
- {
- string Anime_ID = AnimeID(Url);
- if (!string.IsNullOrEmpty(Anime_ID))
- {
- Web.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
- string WebResposta = Web.UploadString("http://www.superanimes.com/epsAll.php", string.Format("anime={0}", Anime_ID));
- Episodios.Clear();
- using (StringReader Ler = new StringReader(WebResposta))
- {
- string Linha;
- while ((Linha = Ler.ReadLine()) != null)
- {
- if (Linha.Contains("<a href="))
- {
- var SiteSplit = Linha.Split('"');
- var Site = SiteSplit[1].Split('/');
- string Encode_ID = EncodeID(UrlPrefix + Site[3] + "/" + Site[4]);
- if (!string.IsNullOrEmpty(Encode_ID))
- {
- string Video = Link(Encode_ID);
- if (!string.IsNullOrEmpty(Video))
- {
- Console.WriteLine(Maiuscula(Site[4]));
- Anime.Animes.FirstOrDefault(x => x.Nome == Maiuscula(Site[3])).Episodes.Add(Site[4].Replace("episodio-", "Episodio_"), Video);
- }
- }
- }
- }
- }
- foreach (var Data in Anime.Animes)
- {
- if (!File.Exists(Path.Combine(Save.Pasta, Maiuscula(Data.Nome) + ".xml")))
- {
- new Save();
- }
- }
- }
- }
- }
- catch (Exception e)
- {
- Console.WriteLine("[Forking] - " + e.Message);
- }
- }
- public static string EncodeID(string Url)
- {
- using (WebClient Web = new WebClient())
- {
- Stream S = Web.OpenRead(Url);
- using (StreamReader Ler = new StreamReader(S))
- {
- string Linha;
- while ((Linha = Ler.ReadLine()) != null)
- {
- if (Linha.Contains("IDENCODE"))
- {
- string Data = Linha.Split('\'')[1];
- return Data;
- }
- }
- }
- }
- return null;
- }
- public static string Link(string EncodeID)
- {
- if (!string.IsNullOrEmpty(EncodeID))
- {
- using (WebClient Web = new WebClient())
- {
- Web.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
- string WebResposta = Web.UploadString("http://www.superanimes.com/inc/stream.inc.php", string.Format("id={0}&tipo=p1", EncodeID));
- using (StringReader Ler = new StringReader(WebResposta))
- {
- string Linha;
- while ((Linha = Ler.ReadLine()) != null)
- {
- if (Linha.Contains("<source"))
- {
- return Linha.Split('"')[1];
- }
- }
- }
- }
- }
- return null;
- }
- public static string AnimeID(string Anime)
- {
- using (WebClient Web = new WebClient())
- {
- Stream S = Web.OpenRead(Anime);
- using (StreamReader Ler = new StreamReader(S))
- {
- string Linha;
- while ((Linha = Ler.ReadLine()) != null)
- {
- if (Linha.Contains("IDANIME"))
- {
- return Linha.Split('\'')[1];
- }
- }
- Ler.Close();
- }
- }
- return null;
- }
- private static string Maiuscula(string M)
- {
- var palavras = new Queue<string>();
- foreach (var palavra in M.Split(' '))
- {
- if (!string.IsNullOrEmpty(palavra))
- {
- var emMinusculo = palavra.ToLower();
- var letras = emMinusculo.ToCharArray();
- letras[0] = char.ToUpper(letras[0]);
- palavras.Enqueue(new string(letras));
- }
- }
- return string.Join(" ", palavras);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement