Пример #1
0
        private Book UseIsbn(StorageFile storageFile, Book book)
        {
            var outBook = new Book
            {
                Title               = Path.GetFileNameWithoutExtension(storageFile.Name),
                Source              = book.Source,
                FileName            = book.FileName,
                FullPathAndFileName = book.FullPathAndFileName
            };
            var parser = new PdfParser();
            var s      = parser.Extract(storageFile, 1, 10).Result;
            var isbn   = PdfIsbnParser.FindIsbn(s);

            if (IsNullOrEmpty(isbn))
            {
                return(outBook);
            }
            outBook.Isbn = isbn;
            var scraper = new Scraper.Scraper();
            var results = scraper.Scrape(outBook.Isbn).Result;

            if (results.items == null || results.items.Count <= 0)
            {
                return(outBook);
            }
            outBook.Title    = results.items[0].volumeInfo.title;
            outBook.Abstract = results.items[0].volumeInfo.description;
            outBook.Pages    = results.items[0].volumeInfo.pageCount;
            outBook.Scraped  = true;
            if (results.items[0].volumeInfo.authors != null)
            {
                outBook.Author = Join(",", results.items[0].volumeInfo.authors.ToArray());
            }
            outBook.Publisher = results.items[0].volumeInfo.publisher;
            return(outBook);
        }
Пример #2
0
 private Book UseIsbn(StorageFile storageFile, Book book)
 {
     var outBook = new Book
     {
         Title = Path.GetFileNameWithoutExtension(storageFile.Name),
         Source = book.Source,
         FileName = book.FileName,
         FullPathAndFileName = book.FullPathAndFileName
     };
     var parser = new PdfParser();
     var s = parser.Extract(storageFile, 1, 10).Result;
     var isbn = PdfIsbnParser.FindIsbn(s);
     if (IsNullOrEmpty(isbn)) return outBook;
     outBook.Isbn = isbn;
     var scraper = new Scraper.Scraper();
     var results = scraper.Scrape(outBook.Isbn).Result;
     if (results.items == null || results.items.Count <= 0) return outBook;
     outBook.Title = results.items[0].volumeInfo.title;
     outBook.Abstract = results.items[0].volumeInfo.description;
     outBook.Pages = results.items[0].volumeInfo.pageCount;
     outBook.Scraped = true;
     if (results.items[0].volumeInfo.authors != null)
     {
         outBook.Author = Join(",", results.items[0].volumeInfo.authors.ToArray());
     }
     outBook.Publisher = results.items[0].volumeInfo.publisher;
     return outBook;
 }