Skip to content

Commit

Permalink
Merge pull request #326 from ttys0dev/audio
Browse files Browse the repository at this point in the history
Add support for audio file PDFs and alternate transcript receipt format
  • Loading branch information
mlissner committed Jun 29, 2023
2 parents c6bb50b + 21cca2d commit 05a7821
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
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';
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();
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

0 comments on commit 05a7821

Please sign in to comment.