Пример #1
0
 public static ListViewItem ScrapeData(ListViewItem item)
 {
     try
     {
         if (BiblioUpTik.Properties.Settings.Default.GetCover || BiblioUpTik.Properties.Settings.Default.GetDescription || BiblioUpTik.Properties.Settings.Default.GetPublisher || BiblioUpTik.Properties.Settings.Default.GetPages)
         {
             GoogleBook googleBook = string.IsNullOrWhiteSpace(item.SubItems[6].Text) ? new GoogleBook(item, false) : new GoogleBook(item, true);
             bool       flag       = googleBook.VolumeInfo() != null;
             if (flag)
             {
                 if (BiblioUpTik.Properties.Settings.Default.GetDescription)
                 {
                     item.SubItems[7].Text = googleBook.Description() ?? item.SubItems[7].Text;
                 }
                 if (BiblioUpTik.Properties.Settings.Default.GetPublisher)
                 {
                     item.SubItems[4].Text = googleBook.Publisher() ?? item.SubItems[4].Text;
                 }
                 if (BiblioUpTik.Properties.Settings.Default.GetPages)
                 {
                     item.SubItems[8].Text = googleBook.PageCount() ?? item.SubItems[8].Text;
                 }
             }
             if (BiblioUpTik.Properties.Settings.Default.GetCover)
             {
                 if (!string.IsNullOrWhiteSpace(item.SubItems[6].Text))
                 {
                     item.SubItems[9].Text = Book.AzCoverLink(Book.ConvertToISBN10(item.SubItems[6].Text));
                     if (string.IsNullOrWhiteSpace(item.SubItems[9].Text))
                     {
                         item.SubItems[9].Text = Book.GrCoverLink(item.SubItems[6].Text);
                     }
                 }
                 if (string.IsNullOrWhiteSpace(item.SubItems[9].Text))
                 {
                     item.SubItems[9].Text = Book.GrCoverLink(item.SubItems[3].Text.Split('(')[0].Trim().Replace(' ', '+'));
                 }
             }
             if (!string.IsNullOrWhiteSpace(item.SubItems[6].Text) && flag)
             {
                 if (string.IsNullOrWhiteSpace(item.SubItems[5].Text))
                 {
                     item.SubItems[5].Text = googleBook.PublishDate() ?? "";
                 }
                 if (string.IsNullOrWhiteSpace(item.SubItems[2].Text))
                 {
                     item.SubItems[2].Text = googleBook.Author() ?? "";
                 }
                 if (string.IsNullOrWhiteSpace(item.SubItems[3].Text))
                 {
                     item.SubItems[3].Text = googleBook.Title() ?? "";
                 }
             }
         }
         return(item);
     }
     catch (Exception ex)
     {
         return(item);
     }
 }
Пример #2
0
 public static ListViewItem ScrapeMobiData(ListViewItem item)
 {
     try
     {
         string          query = item.Tag.ToString().Split('|')[2].Trim();
         BiblioUpTik.Web web   = new BiblioUpTik.Web();
         try
         {
             Uri url = new Uri(new Uri("http://www.amazon.com/dp/").ToString() + query);
             if (BiblioUpTik.Properties.Settings.Default.GetPublisher || BiblioUpTik.Properties.Settings.Default.GetPages)
             {
                 string strSource = web.BookRequest(url);
                 if (BiblioUpTik.Properties.Settings.Default.GetPublisher)
                 {
                     item.SubItems[4].Text = web.GetStringBetween(strSource, "<b>Publisher:</b>", ";", 0).Replace(",", "").Trim();
                 }
                 if (BiblioUpTik.Properties.Settings.Default.GetPages && int.Parse(item.SubItems[8].Text) <= 0)
                 {
                     item.SubItems[8].Text = web.GetStringBetween(strSource, "<b>Print Length:</b>", " pages", 0).Trim();
                 }
             }
         }
         catch (Exception ex)
         {
             Console.WriteLine((object)ex);
         }
         if (BiblioUpTik.Properties.Settings.Default.GetCover || BiblioUpTik.Properties.Settings.Default.GetDescription)
         {
             GoogleBook googleBook = string.IsNullOrWhiteSpace(item.SubItems[6].Text) ? new GoogleBook(item, false) : new GoogleBook(item, true);
             bool       flag       = googleBook.VolumeInfo() != null;
             if (BiblioUpTik.Properties.Settings.Default.GetDescription && flag)
             {
                 item.SubItems[7].Text = googleBook.Description() ?? item.SubItems[7].Text;
             }
             if (BiblioUpTik.Properties.Settings.Default.GetCover)
             {
                 if (query != "")
                 {
                     item.SubItems[9].Text = Book.AzCoverLink(query);
                 }
                 else if (!string.IsNullOrWhiteSpace(item.SubItems[6].Text))
                 {
                     item.SubItems[9].Text = Book.AzCoverLink(Book.ConvertToISBN10(item.SubItems[6].Text));
                 }
                 if (string.IsNullOrWhiteSpace(item.SubItems[9].Text) && query != "")
                 {
                     item.SubItems[9].Text = Book.GrCoverLink(query);
                 }
             }
             if (!string.IsNullOrWhiteSpace(item.SubItems[6].Text) && flag)
             {
                 if (string.IsNullOrWhiteSpace(item.SubItems[5].Text))
                 {
                     item.SubItems[5].Text = googleBook.PublishDate() ?? "";
                 }
                 if (string.IsNullOrWhiteSpace(item.SubItems[2].Text))
                 {
                     item.SubItems[2].Text = googleBook.Author() ?? "";
                 }
                 if (string.IsNullOrWhiteSpace(item.SubItems[3].Text))
                 {
                     item.SubItems[3].Text = googleBook.Title() ?? "";
                 }
             }
         }
         return(item);
     }
     catch (Exception ex)
     {
         return(item);
     }
 }