Skip to content

Commit

Permalink
Merge pull request #840 from OCLC-Developer-Network/APhA
Browse files Browse the repository at this point in the history
develop apha parser
  • Loading branch information
felixleo22 authored Aug 27, 2024
2 parents 1774cd1 + 3058884 commit 174d42d
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 0 deletions.
14 changes: 14 additions & 0 deletions apha/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"longname": "APhA Pharmacy Library",
"name": "apha",
"describe": "Recognizes the accesses to the platform APhA Pharmacy Library",
"contact": "Violita Kovchegov",
"pkb": false,
"docurl": "https://analyses.ezpaarse.org/platforms/66b279634aa96e614c74a4bf",
"domains": [
"pharmacylibrary.com",
"pharmacylibrary-com.jerome.stjohns.edu"
],
"version": "2024-08-09",
"status": "beta"
}
72 changes: 72 additions & 0 deletions apha/parser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/usr/bin/env node

'use strict';
const Parser = require('../.lib/parser.js');

/**
* Recognizes the accesses to the platform APhA Pharmacy Library
* @param {Object} parsedUrl an object representing the URL to analyze
* main attributes: pathname, query, hostname
* @param {Object} ec an object representing the EC whose URL is being analyzed
* @return {Object} the result
*/
module.exports = new Parser(function analyseEC(parsedUrl, ec) {
let result = {};
let path = parsedUrl.pathname;
// uncomment this line if you need parameters
// let param = parsedUrl.query || {};

// use console.error for debuging
// console.error(parsedUrl);

let match;

if (/^\/action\/doSearch$/i.test(path)) {
// https://pharmacylibrary.com/action/doSearch?AllField=Acid+reflux
// https://pharmacylibrary.com/action/doSearch?AllField=HIV
result.rtype = 'SEARCH';
result.mime = 'HTML';

} else if ((match = /^\/do\/[0-9.]+\/([a-zA-Z0-9._]+)\/full\/?$/i.exec(path)) !== null) {
// https://pharmacylibrary-com.jerome.stjohns.edu/do/10.21019/hap_vap_table_cap_dsm/full
// https://pharmacylibrary.com/do/10.21019/pharmacotherapyfirst.hiv_overview_table1/full
result.rtype = 'TABLE';
result.mime = 'HTML';
result.title_id = match[1];
result.unitid = match[1];

} else if ((match = /^\/topic\/([a-zA-Z]+)$/i.exec(path)) !== null) {
// https://pharmacylibrary.com/topic/pfcbl
// https://pharmacylibrary.com/topic/multimedia
result.rtype = 'TOC';
result.mime = 'HTML';
result.unitid = match[1];
} else if ((match = /^\/doi\/full\/([0-9.]+)\/([a-zA-Z0-9_.-]+)$/i.exec(path)) !== null) {
// https://pharmacylibrary.com/doi/full/10.21019/culturaltoolkit-diverse.cross-cultural_communication
result.rtype = 'BOOK';
result.mime = 'HTML';
result.title_id = match[2];
result.unitid = `${match[1]}/${match[2]}`;

} else if ((match = /^\/doi\/([0-9.]+)\/([a-zA-Z0-9_.-]+)$/i.exec(path)) !== null) {
// https://pharmacylibrary.com/doi/10.21019/culturaltoolkit-healthdisp.define_health-disp
// https://pharmacylibrary.com/doi/10.21019/ALE.2000.1
result.rtype = 'BOOK';
result.mime = 'HTML';
result.title_id = match[2];
result.unitid = `${match[1]}/${match[2]}`;

} else if ((match = /^\/doi\/epub\/([0-9.]+)\/([0-9]+)$/i.exec(path)) !== null) {
// https://pharmacylibrary.com/doi/epub/10.21019/9781582122168
// https://pharmacylibrary.com/doi/epub/10.21019/9781582122861
result.rtype = 'BOOK';
result.mime = 'EPUB';
result.unitid = `${match[1]}/${match[2]}`;
} else if ((match = /^\/doi\/epdf\/([0-9.]+)\/([0-9]+)$/i.exec(path)) !== null) {
// https://pharmacylibrary.com/doi/epdf/10.21019/9781582121444
result.rtype = 'BOOK';
result.mime = 'PDF';
result.unitid = `${match[1]}/${match[2]}`;
}
return result;
});
13 changes: 13 additions & 0 deletions apha/test/apha.2024-08-09.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
out-title_id;out-doi;out-unitid;out-rtype;out-mime;in-url
;;10.21019/9781582122861;BOOK;EPUB;https://pharmacylibrary.com/doi/epub/10.21019/9781582122861
;;10.21019/9781582121444;BOOK;PDF;https://pharmacylibrary.com/doi/epdf/10.21019/9781582121444
;;10.21019/9781582122168;BOOK;EPUB;https://pharmacylibrary.com/doi/epub/10.21019/9781582122168
ALE.2000.1;;10.21019/ALE.2000.1;BOOK;HTML;https://pharmacylibrary.com/doi/10.21019/ALE.2000.1
culturaltoolkit-diverse.cross-cultural_communication;;10.21019/culturaltoolkit-diverse.cross-cultural_communication;BOOK;HTML;https://pharmacylibrary.com/doi/full/10.21019/culturaltoolkit-diverse.cross-cultural_communication
culturaltoolkit-healthdisp.define_health-disp;;10.21019/culturaltoolkit-healthdisp.define_health-disp;BOOK;HTML;https://pharmacylibrary.com/doi/10.21019/culturaltoolkit-healthdisp.define_health-disp
;;pfcbl;TOC;HTML;https://pharmacylibrary.com/topic/pfcbl
;;multimedia;TOC;HTML;https://pharmacylibrary.com/topic/multimedia
hap_vap_table_cap_dsm;;hap_vap_table_cap_dsm;TABLE;HTML;https://pharmacylibrary-com.jerome.stjohns.edu/do/10.21019/hap_vap_table_cap_dsm/full/
pharmacotherapyfirst.hiv_overview_table1;;pharmacotherapyfirst.hiv_overview_table1;TABLE;HTML;https://pharmacylibrary.com/do/10.21019/pharmacotherapyfirst.hiv_overview_table1/full/
;;;SEARCH;HTML;https://pharmacylibrary.com/action/doSearch?AllField=Acid+reflux
;;;SEARCH;HTML;https://pharmacylibrary.com/action/doSearch?AllField=HIV

0 comments on commit 174d42d

Please sign in to comment.