From 1a5086b2d78b2cf8d80a36e186d0c55cf67cd93f Mon Sep 17 00:00:00 2001 From: Nemo Date: Sat, 4 Apr 2020 01:10:11 +0530 Subject: [PATCH] Catch books with missing dates --- .gitignore | 3 +- spec/book_spec.cr | 6 + spec/fixtures/book-57833.html | 1914 +++++++++++++++++++++++++++++++++ src/infoparser.cr | 6 +- src/thing.cr | 2 +- 5 files changed, 1928 insertions(+), 3 deletions(-) create mode 100644 spec/fixtures/book-57833.html diff --git a/.gitignore b/.gitignore index f523f84..038b528 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ /.shards/ *.dwarf *.pdf -*.o \ No newline at end of file +*.o +muse-dl-static* \ No newline at end of file diff --git a/spec/book_spec.cr b/spec/book_spec.cr index d16425b..622f209 100644 --- a/spec/book_spec.cr +++ b/spec/book_spec.cr @@ -72,4 +72,10 @@ describe Muse::Dl::Book do book.formats.should contain :pdf book.formats.should contain :html end + + it "should note both formats for book/57833" do + html = File.new("spec/fixtures/book-57833.html").gets_to_end + book = Muse::Dl::Book.new html + book.formats.should contain :pdf + end end diff --git a/spec/fixtures/book-57833.html b/spec/fixtures/book-57833.html new file mode 100644 index 0000000..15a4077 --- /dev/null +++ b/spec/fixtures/book-57833.html @@ -0,0 +1,1914 @@ + + + + + + + + + + + + + + + + + + + + + + + + + Project MUSE - Updated Evidence and Policy Developments on Reducing Gun Violence in America + + + + + + + + + + + + + + + + + + + + + + + + + + + Article + + + + + + + + + + + + + + + +
+ +
+ +
+ + +
+
+
+ + + + + +
+

In this Book

+
+ +
+
+
+
+ + Updated Evidence and Policy Developments on Reducing Gun Violence in America + + + +
+
+ + + + + buy this book + Buy This Book in Print + + + + +
+ +
+
+ summary +
+
In 2013—in the wake of the tragic shooting at Sandy Hook Elementary School—Johns Hopkins University Press published Reducing Gun Violence in America, a collection of essays written by the world’s leading experts on gun violence. Updated Evidence and Policy Developments on Reducing Gun Violence in America follows up on the state of American gun violence by analyzing new data, research, and policy developments one year after Sandy Hook. + +Over the course of ten substantive chapter addendums, contributors bring readers up-to-date on such varied topics as mental illness, domestic violence, background checks, illegal gun sales, and personalized guns. They describe the recent policy measures that have been enacted and suggest additional approaches that may help stem the violence. + +An essential companion to Reducing Gun Violence in America, the reliable, empirical research and legal analysis in this e-book will help lawmakers, opinion leaders, and concerned citizens identify policy changes to address gun violence, which takes an average of more than 80 lives every day in the United States.
+ + + + + +
+ + + + + + +
+
+ + +
+ +
+
+
+
+

Table of Contents

+
+
+ +
+
+
+ + + + +
+
+
    + +
  1. Cover
  2. + + + + + + + +
  3. + + + + + +
    + + +open access + + +
      + + + + +
    • + + Download PDF + + + + Download + + + + +
    • + + + + + +
    • + + + + +
    • + + +
    + +
    + + + + +
    + +
  4. + + + +
+
+
+ + + + +
+
+
    + +
  1. Title Page, Copyright
  2. + +
  3. pp. ii-iv
  4. + + + + + +
  5. + + + + + +
    + + +open access + + +
      + + + + +
    • + + Download PDF + + + + Download + + + + +
    • + + + + + +
    • + + + + +
    • + + +
    + +
    + + + + +
    + +
  6. + + + +
+
+
+ + + + +
+
+
    + +
  1. Contents
  2. + +
  3. pp. v-vi
  4. + + + + + +
  5. + + + + + +
    + + +open access + + +
      + + + + +
    • + + Download PDF + + + + Download + + + + +
    • + + + + + +
    • + + + + +
    • + + +
    + +
    + + + + +
    + +
  6. + + + +
+
+
+ + + + +
+
+
    + +
  1. Introduction
  2. +
  3. Daniel W. Webster, Jon S. Vernick
  4. +
  5. pp. 1-3
  6. + + + + + +
  7. + + + + + +
    + + +open access + + +
      + + + + +
    • + + Download PDF + + + + Download + + + + +
    • + + + + + +
    • + + + + +
    • + + +
    + +
    + + + + +
    + +
  8. + + + +
+
+
+ + + + +
+
+
    + +
  1. Chapter 3 Update: Thinking Differently about Mental Illness, Violence Risk, and Gun Rights
  2. +
  3. Jeffrey W. Swanson, Allison G. Robertson
  4. +
  5. pp. 4-9
  6. + + + + + +
  7. + + + + + +
    + + +open access + + +
      + + + + +
    • + + Download PDF + + + + Download + + + + +
    • + + + + + +
    • + + + + +
    • + + +
    + +
    + + + + +
    + +
  8. + + + +
+
+
+ + + + +
+
+
    + +
  1. Chapter 4 Update: Enactment of Legislation to Protect Victims of Domestic Violence: A Story of State Successes
  2. +
  3. April M. Zeoli, Shannon Frattaroli
  4. +
  5. pp. 10-12
  6. + + + + + +
  7. + + + + + +
    + + +open access + + +
      + + + + +
    • + + Download PDF + + + + Download + + + + +
    • + + + + + +
    • + + + + +
    • + + +
    + +
    + + + + +
    + +
  8. + + + +
+
+
+ + + + +
+
+
    + +
  1. Chapter 6 Update: Broadening Denial Criteria: New Developments
  2. +
  3. Garen J. Wintemute
  4. +
  5. pp. 13-16
  6. + + + + + +
  7. + + + + + +
    + + +open access + + +
      + + + + +
    • + + Download PDF + + + + Download + + + + +
    • + + + + + +
    • + + + + +
    • + + +
    + +
    + + + + +
    + +
  8. + + + +
+
+
+ + + + +
+
+
    + +
  1. Chapter 7 Update: Comprehensive Background Checks: New Evidence and Rethinking “Comprehensive”
  2. +
  3. Garen J. Wintemute
  4. +
  5. pp. 17-19
  6. + + + + + +
  7. + + + + + +
    + + +open access + + +
      + + + + +
    • + + Download PDF + + + + Download + + + + +
    • + + + + + +
    • + + + + +
    • + + +
    + +
    + + + + +
    + +
  8. + + + +
+
+
+ + + + +
+
+
    + +
  1. Chapter 8 Update: Preventing the Diversion of Guns to Criminals through Effective Firearm Sales Laws
  2. +
  3. Daniel W. Webster, Jon S. Vernick, +Emma E. McGinty, Ted Alcorn
  4. +
  5. pp. 20-23
  6. + + + + + +
  7. + + + + + +
    + + +open access + + +
      + + + + +
    • + + Download PDF + + + + Download + + + + +
    • + + + + + +
    • + + + + +
    • + + +
    + +
    + + + + +
    + +
  8. + + + +
+
+
+ + + + +
+
+
    + +
  1. Chapter 10 Update: Adequate Oversight of Licensed Firearm Dealers Remains a Problem
  2. +
  3. Jon S. Vernick, Daniel W. Webster
  4. +
  5. pp. 24-26
  6. + + + + + +
  7. + + + + + +
    + + +open access + + +
      + + + + +
    • + + Download PDF + + + + Download + + + + +
    • + + + + + +
    • + + + + +
    • + + +
    + +
    + + + + +
    + +
  8. + + + +
+
+
+ + + + +
+
+
    + +
  1. Chapter 11 Update: Enforcing Federal Laws against Firearms Traffickers: Policy and Legislative Progress in 2013
  2. +
  3. Anthony A. Braga, Peter L. Gagliardi
  4. +
  5. pp. 27-28
  6. + + + + + +
  7. + + + + + +
    + + +open access + + +
      + + + + +
    • + + Download PDF + + + + Download + + + + +
    • + + + + + +
    • + + + + +
    • + + +
    + +
    + + + + +
    + +
  8. + + + +
+
+
+ + + + +
+
+
    + +
  1. Chapter 13 Update: Personalized Guns Progress Report
  2. +
  3. Stephen P. Teret
  4. +
  5. pp. 29-32
  6. + + + + + +
  7. + + + + + +
    + + +open access + + +
      + + + + +
    • + + Download PDF + + + + Download + + + + +
    • + + + + + +
    • + + + + +
    • + + +
    + +
    + + + + +
    + +
  8. + + + +
+
+
+ + + + +
+
+
    + +
  1. Chapter 18 Update: The Second Amendment
  2. +
  3. Lawrence E. Rosenthal, Adam Winkler
  4. +
  5. pp. 33-35
  6. + + + + + +
  7. + + + + + +
    + + +open access + + +
      + + + + +
    • + + Download PDF + + + + Download + + + + +
    • + + + + + +
    • + + + + +
    • + + +
    + +
    + + + + +
    + +
  8. + + + +
+
+
+ + + + +
+
+
    + +
  1. Chapter 19 Update: Public Opinion on Gun Policy Following the Newtown Mass Shooting and the Disconnect with Political Action
  2. +
  3. Emma E. McGinty, Daniel W. Webster, Jon S. Vernick, +Colleen L. Barry
  4. +
  5. pp. 36-39
  6. + + + + + +
  7. + + + + + +
    + + +open access + + +
      + + + + +
    • + + Download PDF + + + + Download + + + + +
    • + + + + + +
    • + + + + +
    • + + +
    + +
    + + + + +
    + +
  8. + + + +
+
+
+ + + + +
+
+
    + +
  1. Biographies of Contributors
  2. + +
  3. pp. 40-47
  4. + + + + + +
  5. + + + + + +
    + + +open access + + +
      + + + + +
    • + + Download PDF + + + + Download + + + + +
    • + + + + + +
    • + + + + +
    • + + +
    + +
    + + + + +
    + +
  6. + + + +
+
+
+ + +
+ + + + +
+
+ +
+
+ +
+
+ +
+
+
+

Additional Information

+
+
+ + + +
+
+ ISBN +
+
+ 9781421415222 +
+
+ + + +
+
+ DOI +
+ +
+ + +
+
+ MARC Record +
+
+ Download +
+
+ + +
+
+ OCLC +
+
+ 1027681538 +
+
+ + +
+
+ Pages +
+
+ 56 +
+
+ + +
+
+ Launched on MUSE +
+
+ 2018-03-22 +
+
+ + + +
+
+ Language +
+
+ English +
+
+ + +
+
+ Open Access +
+
+ + Yes + +
+
+ + + + +
+
+
+ + + + + + + +
+
+ +
+ + + + + + + + + +
+ Back To Top +
+ + + + + + + +
+

This website uses cookies to ensure you get the best experience on our website. Without cookies your experience may not be seamless.

+ + +
+ + + + + + + + + + + + + diff --git a/src/infoparser.cr b/src/infoparser.cr index 06eb43f..c28252a 100644 --- a/src/infoparser.cr +++ b/src/infoparser.cr @@ -39,7 +39,11 @@ module Muse::Dl end def self.date(myhtml : Myhtml::Parser) - myhtml.css("#book_about_info .date").map(&.inner_text).to_a[0].strip + begin + myhtml.css("#book_about_info .date").map(&.inner_text).to_a[0].strip + rescue e : Exception + nil + end end def self.publisher(myhtml : Myhtml::Parser) diff --git a/src/thing.cr b/src/thing.cr index e199956..96a105a 100644 --- a/src/thing.cr +++ b/src/thing.cr @@ -6,7 +6,7 @@ module Muse::Dl @info = Hash(String, String).new @title : String @author : String - @date : String + @date : String | Nil @publisher : String @summary : String @summary_html : String