Skip to content

Commit

Permalink
Merge pull request #1309 from freelawproject/feat-refines-download-me…
Browse files Browse the repository at this point in the history
…thod-for-appellate-docs

feat(appellate): Handle Attachment Pages in download_pdf
  • Loading branch information
albertisfu authored Jan 28, 2025
2 parents abfc940 + c6d1953 commit ca39567
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions juriscraper/pacer/appellate_docket.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,14 +329,23 @@ def download_pdf(
)
r = self.session.get(self.url, params=query_params)
r.raise_for_status()
if is_pdf(r):
logger.info(
"Got PDF binary data for document #%s in court %s",
pacer_doc_id,
self.court_id,

if b"Documents are attached to this filing" in r.content:
error_message = (
"Unable to download PDF. "
"An attachment page was returned instead."
)
return r, ""
return None, "Unable to download PDF."
return None, error_message

if not is_pdf(r):
return None, "Unable to download PDF."

logger.info(
"Got PDF binary data for document #%s in court %s",
pacer_doc_id,
self.court_id,
)
return r, ""

@property
def metadata(self):
Expand Down

0 comments on commit ca39567

Please sign in to comment.