Advertisement
Guest User

vBTeam.xml

a guest
Mar 12th, 2010
1,110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 6.46 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="Hyperz">
  7.     <Settings>
  8.         <SiteName>vBTeam</SiteName>
  9.         <BaseUrl>http://www.vbteam.info</BaseUrl>
  10.         <TopicsPerPage>0</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="vB 4.0 Releases" id="79" />
  26.         <Section title="vB 4.0 Addons &amp; Template Modifications" id="80" />
  27.         <Section title="vB 4.0 Free Styles" id="82" />
  28.         <Section title="vB 4.0 Premium Styles" id="83" />
  29.         <Section title="vB 4.0 AdminCP Styles" id="84" />
  30.         <Section title="vB 3.8.X Releases" id="68" />
  31.         <Section title="vB 3.8.X Addons &amp; Template Modifications" id="69" />
  32.         <Section title="vB 3.8.x Free Styles" id="71" />
  33.         <Section title="vB 3.8.x Premium Styles" id="72" />
  34.         <Section title="vB 3.8.x AdminCP Styles" id="73" />
  35.         <Section title="vB 3.7.X Releases" id="61" />
  36.         <Section title="vB 3.7.X Addons &amp; Template Modifications" id="62" />
  37.         <Section title="vB 3.7.x Free Styles" id="64" />
  38.         <Section title="vB 3.7.x Premium Styles" id="65" />
  39.         <Section title="vB 3.7.x AdminCP Styles" id="66" />
  40.         <Section title="vB 3.6.X Releases" id="13" />
  41.         <Section title="vB 3.6.X Addons &amp; Template Modifications" id="14" />
  42.         <Section title="vB 3.6.x Free Styles" id="16" />
  43.         <Section title="vB 3.6.x Premium Styles" id="17" />
  44.         <Section title="vB 3.6.x AdminCP Styles" id="18" />
  45.         <Section title="Compatible Scripts" id="20" />
  46.         <Section title="Arcade Games" id="21" />
  47.         <Section title="Language Packs" id="22" />
  48.         <Section title="vB Graphics" id="23" />
  49.     </Sections>
  50.    
  51.     <!-- Edit this when the site requires custom parsing -->
  52.     <Code>
  53.         <![CDATA[
  54.        
  55.        protected override void Init()
  56.        {
  57.            base.Init();
  58.        }
  59.  
  60.        public override void LoginUser(string username, string password)
  61.        {
  62.            base.LoginUser(username, password);
  63.        }
  64.  
  65.        public override void LogoutUser()
  66.        {
  67.            base.LogoutUser();
  68.        }
  69.  
  70.        public override string[] GetTopicUrls(string html)
  71.        {
  72.            return base.GetTopicUrls(html);
  73.        }
  74.  
  75.        // vBTeam hosts the downloads on their site.
  76.        // Quietly sneak in and grab the attachment link(s).
  77.        public override SiteTopic GetTopic(string url)
  78.        {
  79.            if (!this.Type.User.IsLoggedIn) return null;
  80.  
  81.            HtmlDocument doc = new HtmlDocument();
  82.            HttpWebRequest req;
  83.            HttpResult result;
  84.  
  85.            req = Http.Prepare(url);
  86.            req.Method = "GET";
  87.            req.Referer = url;
  88.  
  89.            try
  90.            {
  91.                result = this.Type.AllowRedirects ? Http.HandleRedirects(Http.Request(req), false) : Http.Request(req);
  92.                doc.LoadHtml(result.Data);
  93.  
  94.                if (result.HasError) throw result.Error;
  95.  
  96.                HtmlNodeCollection nodes = doc.DocumentNode.SelectNodes("//img[@alt='Reply With Quote']");
  97.                string link = HttpUtility.HtmlDecode(nodes[0].ParentNode.GetAttributeValue("href", String.Empty));
  98.  
  99.                nodes = doc.DocumentNode.SelectNodes("//div[@class='smallfont']");
  100.                string title = (from n in nodes
  101.                                where n.ParentNode.InnerHtml.Contains("<!-- icon and title -->")
  102.                                select HttpUtility.HtmlDecode(n.InnerText).Trim()).ToArray()[0];
  103.                
  104.                // Grab attachments
  105.                nodes = doc.DocumentNode.SelectNodes("//a");
  106.                var attachments = from n in nodes
  107.                                  where n.GetAttributeValue("href", String.Empty).Contains("vbteam.info/attachments/")
  108.                                  select n.GetAttributeValue("href", String.Empty);
  109.  
  110.                req = Http.Prepare((link.StartsWith("http:")) ? link : this.Type.BaseUrl + "/" + link);
  111.                req.Method = "GET";
  112.                req.Referer = url;
  113.  
  114.                result = this.Type.AllowRedirects ? Http.HandleRedirects(Http.Request(req), false) : Http.Request(req);
  115.                doc.LoadHtml(result.Data);
  116.  
  117.                if (result.HasError) throw result.Error;
  118.  
  119.                string content = doc.DocumentNode.SelectNodes("//textarea[@name='message']")[0].InnerText;
  120.  
  121.                content = HttpUtility.HtmlDecode(content.Substring(content.IndexOf(']') + 1)).Trim();
  122.                content = content.Substring(0, content.Length - "[/quote]".Length);
  123.                
  124.                // Add attachments...
  125.                if (attachments.ToArray().Length > 0)
  126.                {
  127.                    content += "\n\n[b]Download:[/b]\n[code]";
  128.                    foreach (string attachment in attachments) content += HttpUtility.HtmlDecode(attachment) + "\n";
  129.                    content += "[/code]";
  130.                }
  131.  
  132.                return new SiteTopic(
  133.                    title.Trim(),
  134.                    content.Trim(),
  135.                    0, 0, url
  136.                );
  137.            }
  138.            catch (Exception error)
  139.            {
  140.                // TODO: log error...
  141.                return null;
  142.            }
  143.        }
  144.  
  145.        public override SiteTopic GetTopic(int topicId)
  146.        {
  147.            string url = this.Type.BaseUrl + String.Format(this.Type.TopicPath, topicId);
  148.            return this.GetTopic(url);
  149.        }
  150.        
  151.        public override HttpWebRequest GetPage(int sectionId, int page, int siteTopicsPerPage)
  152.        {
  153.            return base.GetPage(sectionId, page, siteTopicsPerPage);
  154.        }
  155.  
  156.        public override void MakeReady(int sectionId)
  157.        {
  158.            base.MakeReady(sectionId);
  159.        }
  160.        
  161.        ]]>
  162.     </Code>
  163. </SiteReader>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement