Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for audio file PDFs and alternate transcript receipt format #326

Merged
merged 1 commit into from
Jun 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions spec/PacerSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ describe('The PACER module', function () {
const noTrailingSlashUrl = 'https://ecf.canb.uscourts.gov';
const docketReportURL = 'https://ecf.canb.uscourts.gov/cgi-bin/DktRpt.pl';
const singleDocUrl = 'https://ecf.canb.uscourts.gov/doc1/034031424909';
const singleDocAudioUrl = 'https://ecf.canb.audio.uscourts.gov/doc1/034031424909';
ERosendo marked this conversation as resolved.
Show resolved Hide resolved
const docketQueryUrl = 'https://ecf.canb.uscourts.gov/cgi-bin/' + 'HistDocQry.pl?531316';
const docketQueryUrlFromAppellate =
'https://ecf.canb.uscourts.gov/cgi-bin/' + 'DktRpt.pl?caseNumber=2:16-cv-01129-RFB-DJA';
Expand Down Expand Up @@ -38,6 +39,10 @@ describe('The PACER module', function () {
expect(PACER.getCourtFromUrl(singleDocUrl)).toBe('canb');
});

it('matches a valid single doc audio URL', function () {
expect(PACER.getCourtFromUrl(singleDocAudioUrl)).toBe('canb');
});

it('ignores patent nonsense', function () {
expect(PACER.getCourtFromUrl(nonsenseUrl)).toBe(null);
});
Expand Down
15 changes: 11 additions & 4 deletions src/pacer.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ let PACER = {
// RECAP are being used outside of PACER. Be sure tests pass appropriately
// before tweaking this regex.
let match = (url || '').toLowerCase().match(
/^\w+:\/\/(ecf|pacer)\.(\w+)\.uscourts\.gov(?:\/.*)?$/);
/^\w+:\/\/(ecf|pacer)\.(\w+)(?:\.audio)?\.uscourts\.gov(?:\/.*)?$/);
return match ? match[2] : null;
},

Expand Down Expand Up @@ -355,14 +355,17 @@ let PACER = {
isSingleDocumentPage: function (url, document) {
let inputs = document.getElementsByTagName('input');
let lastInput = inputs.length && inputs[inputs.length - 1].value;
// If the receipt doesn't say "Image" we don't yet support it on the server.
// If the receipt doesn't say "AUDIO", "Image" or "TRANSCRIPT"
// we don't yet support it on the server.
// So far, this only appears to apply to bankruptcy claims. This CSS
// selector is duplicated in onDocumentViewSubmit.
let hasAudioReceipt = !!$('td:contains(AUDIO)').length;
let hasImageReceipt = !!$('td:contains(Image)').length;
let hasTranscriptReceipt = !!$('td:contains(TRANSCRIPT)').length;


let pageCheck = (PACER.isDocumentUrl(url) &&
hasImageReceipt &&
(hasAudioReceipt || hasImageReceipt || hasTranscriptReceipt) &&
(lastInput === 'View Document') ||
(lastInput === 'Accept Charges and Retrieve'));
debug(4,` lastInput ${lastInput}`);
Expand Down Expand Up @@ -586,9 +589,13 @@ let PACER = {
// - doc_number
// - att_number

let audio_string = $('td:contains(AUDIO)').text();
ERosendo marked this conversation as resolved.
Show resolved Hide resolved
let image_string = $('td:contains(Image)').text();
let transcript_string = $('td:contains(TRANSCRIPT)').text();

let receipt_description = image_string || audio_string || transcript_string;
let regex = /(\d+)-(\d+)/;
let matches = regex.exec(image_string);
let matches = regex.exec(receipt_description);
if (!matches) {
return null;
}
Expand Down