Advertisement
Guest User

Untitled

a guest
Mar 24th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.65 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Net;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8.  
  9. namespace Forking_Database
  10. {
  11. class Program
  12. {
  13. public static string UrlPrefix = "http://www.superanimes.com/";
  14. public static Dictionary<string, string> Episodios = new Dictionary<string, string>();
  15.  
  16. static void Main(string[] args)
  17. {
  18. //using (WebClient Web = new WebClient())
  19. //{
  20. // Web.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
  21. // string Url = Web.UploadString("http://www.superanimes.com/pager.php", "id=eps&offset=4&acao=more&limit=3");
  22.  
  23. // using (StringReader Ler = new StringReader(Url))
  24. // {
  25. // string Linha;
  26.  
  27. // while ((Linha = Ler.ReadLine()) != null)
  28. // {
  29. // if (Linha.Contains("<a href="))
  30. // {
  31. // var Link = Linha.Split('"')[1].Split('/');
  32.  
  33.  
  34.  
  35. // Console.WriteLine(Maiuscula(Link[3]));
  36.  
  37. // Forking(UrlPrefix + Link[3]);
  38. // }
  39. // }
  40. // }
  41. // }
  42. //}
  43.  
  44. for (int i = 1; i <= 70; i++)
  45. {
  46. ReadPage(i);
  47. }
  48.  
  49. while (true) { }
  50. }
  51.  
  52.  
  53. public static void ReadPage(int Page)
  54. {
  55. using (WebClient Web = new WebClient())
  56. {
  57. Stream Site = Web.OpenRead("http://www.superanimes.com/lista?&video=legendado&pagina=" + Page);
  58.  
  59. using (StreamReader Ler = new StreamReader(Site))
  60. {
  61. string Linha;
  62. List<string> Try = new List<string>();
  63.  
  64. while ((Linha = Ler.ReadLine()) != null)
  65. {
  66. var L = Linha.Trim();
  67.  
  68. if (L.StartsWith("<a href"))
  69. {
  70. if (L.Contains("lista") || L.Contains("mobile") || L.Contains("Pagina") || L.Contains("google"))
  71. {
  72.  
  73. }
  74. else
  75. {
  76. Try.Add(Linha.Trim());
  77. }
  78. }
  79. }
  80.  
  81. foreach (var T in Try)
  82. {
  83. var SpliT = T.Split('"');
  84. var Link = SpliT[1].Split('/');
  85.  
  86. if (!Anime.Animes.Any(x => x.Link == UrlPrefix + Link[3]))
  87. {
  88. Anime.Animes.Add(new Anime
  89. {
  90. Nome = Maiuscula(Link[3]),
  91. Link = UrlPrefix + Link[3]
  92. });
  93.  
  94. Forking(UrlPrefix + Link[3]);
  95. }
  96. }
  97.  
  98. Console.WriteLine(Page + " Finalizada");
  99. }
  100. }
  101. }
  102.  
  103. public static void Forking(string Url)
  104. {
  105. try
  106. {
  107. if (string.IsNullOrEmpty(Url))
  108. return;
  109.  
  110. using (WebClient Web = new WebClient())
  111. {
  112. string Anime_ID = AnimeID(Url);
  113.  
  114. if (!string.IsNullOrEmpty(Anime_ID))
  115. {
  116. Web.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
  117. string WebResposta = Web.UploadString("http://www.superanimes.com/epsAll.php", string.Format("anime={0}", Anime_ID));
  118.  
  119. Episodios.Clear();
  120.  
  121. using (StringReader Ler = new StringReader(WebResposta))
  122. {
  123. string Linha;
  124.  
  125. while ((Linha = Ler.ReadLine()) != null)
  126. {
  127. if (Linha.Contains("<a href="))
  128. {
  129. var SiteSplit = Linha.Split('"');
  130. var Site = SiteSplit[1].Split('/');
  131.  
  132. string Encode_ID = EncodeID(UrlPrefix + Site[3] + "/" + Site[4]);
  133. if (!string.IsNullOrEmpty(Encode_ID))
  134. {
  135. string Video = Link(Encode_ID);
  136.  
  137. if (!string.IsNullOrEmpty(Video))
  138. {
  139. Console.WriteLine(Maiuscula(Site[4]));
  140. Anime.Animes.FirstOrDefault(x => x.Nome == Maiuscula(Site[3])).Episodes.Add(Site[4].Replace("episodio-", "Episodio_"), Video);
  141. }
  142. }
  143. }
  144. }
  145. }
  146.  
  147. foreach (var Data in Anime.Animes)
  148. {
  149. if (!File.Exists(Path.Combine(Save.Pasta, Maiuscula(Data.Nome) + ".xml")))
  150. {
  151. new Save();
  152. }
  153. }
  154. }
  155. }
  156. }
  157. catch (Exception e)
  158. {
  159. Console.WriteLine("[Forking] - " + e.Message);
  160. }
  161. }
  162.  
  163. public static string EncodeID(string Url)
  164. {
  165. using (WebClient Web = new WebClient())
  166. {
  167. Stream S = Web.OpenRead(Url);
  168.  
  169. using (StreamReader Ler = new StreamReader(S))
  170. {
  171. string Linha;
  172.  
  173. while ((Linha = Ler.ReadLine()) != null)
  174. {
  175. if (Linha.Contains("IDENCODE"))
  176. {
  177. string Data = Linha.Split('\'')[1];
  178. return Data;
  179. }
  180. }
  181. }
  182. }
  183.  
  184. return null;
  185. }
  186.  
  187. public static string Link(string EncodeID)
  188. {
  189. if (!string.IsNullOrEmpty(EncodeID))
  190. {
  191. using (WebClient Web = new WebClient())
  192. {
  193. Web.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
  194. string WebResposta = Web.UploadString("http://www.superanimes.com/inc/stream.inc.php", string.Format("id={0}&tipo=p1", EncodeID));
  195.  
  196. using (StringReader Ler = new StringReader(WebResposta))
  197. {
  198. string Linha;
  199.  
  200. while ((Linha = Ler.ReadLine()) != null)
  201. {
  202. if (Linha.Contains("<source"))
  203. {
  204. return Linha.Split('"')[1];
  205. }
  206. }
  207. }
  208. }
  209. }
  210.  
  211. return null;
  212. }
  213.  
  214. public static string AnimeID(string Anime)
  215. {
  216. using (WebClient Web = new WebClient())
  217. {
  218. Stream S = Web.OpenRead(Anime);
  219.  
  220. using (StreamReader Ler = new StreamReader(S))
  221. {
  222. string Linha;
  223.  
  224. while ((Linha = Ler.ReadLine()) != null)
  225. {
  226. if (Linha.Contains("IDANIME"))
  227. {
  228. return Linha.Split('\'')[1];
  229. }
  230. }
  231.  
  232. Ler.Close();
  233. }
  234. }
  235.  
  236. return null;
  237. }
  238.  
  239. private static string Maiuscula(string M)
  240. {
  241. var palavras = new Queue<string>();
  242. foreach (var palavra in M.Split(' '))
  243. {
  244. if (!string.IsNullOrEmpty(palavra))
  245. {
  246. var emMinusculo = palavra.ToLower();
  247. var letras = emMinusculo.ToCharArray();
  248. letras[0] = char.ToUpper(letras[0]);
  249. palavras.Enqueue(new string(letras));
  250. }
  251. }
  252. return string.Join(" ", palavras);
  253. }
  254. }
  255. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement