Advertisement
Guest User

WarezScene Plugin

a guest
Apr 27th, 2010
778
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.88 KB | None | 0 0
  1. <?xml version="1.0" encoding="utf-8" ?>
  2.  
  3. <!-- SharpLeech 2.x.x SiteReader Plugin -->
  4.  
  5. <!-- Version MUST be in x.x.x.x format! -->
  6. <SiteReader pluginVersion="2.0.0.0" pluginAuthor="Last Word">
  7. <Settings>
  8. <SiteName>WarezScene</SiteName>
  9. <BaseUrl>http://www.warezscene.org</BaseUrl>
  10. <TopicsPerPage>20</TopicsPerPage>
  11.  
  12. <!-- Supported type values are: IP.Board 3.x.x, IP.Board 2.x.x,
  13. vBulletin 4.x.x, vBulletin 3.x.x, phpBB 3.x.x, phpBB 2.x.x -->
  14. <Type>vBulletin 3.x.x</Type>
  15.  
  16. <!-- If unsure choose ISO-8859-1. Except for phpBB 3 boards, they use UTF-8 by default. -->
  17. <DefaultEncoding>ISO-8859-1</DefaultEncoding>
  18.  
  19. <!-- Set to true if the site uses SEO urls, otherwise false. -->
  20. <AllowRedirects>true</AllowRedirects>
  21. <UseFriendlyLinks>true</UseFriendlyLinks>
  22. </Settings>
  23.  
  24. <Sections>
  25. <Section title="Applications" id="3" />
  26. <Section title="Games" id="9" />
  27. <Section title="Console Games" id="43" />
  28. <Section title="PSP Games" id="311" />
  29. <Section title="Movies / TV Shows" id="2" />
  30. <Section title="TV Shows" id="312" />
  31. <Section title="Music / Albums" id="18" />
  32. <Section title="Music Videos" id="325" />
  33. <Section title="Scripts, Templates, and Web Downloads" id="4" />
  34. <Section title="Non-Windows Downloads" id="19" />
  35. <Section title="Mac Applications and Games" id="236" />
  36. <Section title="Mobile Downloads" id="342" />
  37. <Section title="Adult Warez" id="238" />
  38. <Section title="eBooks / Tutorials" id="36" />
  39. <Section title="File Servers (FTP)" id="239" />
  40. <Section title="Guest Downloads" id="41" />
  41. </Sections>
  42.  
  43. <!-- Edit this when the site requires custom parsing -->
  44. <Code>
  45. <![CDATA[
  46.  
  47. protected override void Init()
  48. {
  49. base.Init();
  50. }
  51.  
  52. public override void LoginUser(string username, string password)
  53. {
  54. base.LoginUser(username, password);
  55. }
  56.  
  57. public override void LogoutUser()
  58. {
  59. base.LogoutUser();
  60. }
  61.  
  62. public override string[] GetTopicUrls(string html)
  63. {
  64. return base.GetTopicUrls(html);
  65. }
  66.  
  67. // vBTeam hosts the downloads on their site.
  68. // Quietly sneak in and grab the attachment link(s).
  69. public override SiteTopic GetTopic(string url)
  70. {
  71. if (!this.Type.User.IsLoggedIn) return null;
  72.  
  73. HtmlDocument doc = new HtmlDocument();
  74. HttpWebRequest req;
  75. HttpResult result;
  76.  
  77. req = Http.Prepare(url);
  78. req.Method = "GET";
  79. req.Referer = url;
  80.  
  81. try
  82. {
  83. result = this.Type.AllowRedirects ? Http.HandleRedirects(Http.Request(req), false) : Http.Request(req);
  84. doc.LoadHtml(result.Data);
  85.  
  86. if (result.HasError) throw result.Error;
  87.  
  88. HtmlNodeCollection nodes = doc.DocumentNode.SelectNodes("//img[@alt='Reply With Quote']");
  89. string link = HttpUtility.HtmlDecode(nodes[0].ParentNode.GetAttributeValue("href", String.Empty));
  90.  
  91. nodes = doc.DocumentNode.SelectNodes("//div[@class='smallfont']");
  92. string title = (from n in nodes
  93. where n.ParentNode.InnerHtml.Contains("<!-- icon and title -->")
  94. select HttpUtility.HtmlDecode(n.InnerText).Trim()).ToArray()[0];
  95.  
  96. // Grab attachments
  97. nodes = doc.DocumentNode.SelectNodes("//a");
  98. var attachments = from n in nodes
  99. where n.GetAttributeValue("href", String.Empty).Contains("itbux.com/attachments/")
  100. select n.GetAttributeValue("href", String.Empty);
  101.  
  102. req = Http.Prepare((link.StartsWith("http:")) ? link : this.Type.BaseUrl + "/" + link);
  103. req.Method = "GET";
  104. req.Referer = url;
  105.  
  106. result = this.Type.AllowRedirects ? Http.HandleRedirects(Http.Request(req), false) : Http.Request(req);
  107. doc.LoadHtml(result.Data);
  108.  
  109. if (result.HasError) throw result.Error;
  110.  
  111. string content = doc.DocumentNode.SelectNodes("//textarea[@name='message']")[0].InnerText;
  112.  
  113. content = HttpUtility.HtmlDecode(content.Substring(content.IndexOf(']') + 1)).Trim();
  114. content = content.Substring(0, content.Length - "[/quote]".Length);
  115.  
  116. // Add attachments...
  117. if (attachments.ToArray().Length > 0)
  118. {
  119. content += "\n\n[b]Download:[/b]\n[code]";
  120. foreach (string attachment in attachments) content += HttpUtility.HtmlDecode(attachment) + "\n";
  121. content += "[/code]";
  122. }
  123.  
  124. return new SiteTopic(
  125. title.Trim(),
  126. content.Trim(),
  127. 0, 0, url
  128. );
  129. }
  130. catch (Exception error)
  131. {
  132. // TODO: log error...
  133. return null;
  134. }
  135. }
  136.  
  137. public override SiteTopic GetTopic(int topicId)
  138. {
  139. string url = this.Type.BaseUrl + String.Format(this.Type.TopicPath, topicId);
  140. return this.GetTopic(url);
  141. }
  142.  
  143. public override HttpWebRequest GetPage(int sectionId, int page, int siteTopicsPerPage)
  144. {
  145. return base.GetPage(sectionId, page, siteTopicsPerPage);
  146. }
  147.  
  148. public override void MakeReady(int sectionId)
  149. {
  150. base.MakeReady(sectionId);
  151. }
  152.  
  153. ]]>
  154. </Code>
  155. </SiteReader>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement