Skip to content

Commit

Permalink
Merge pull request #869 from OCLC-Developer-Network/r4l
Browse files Browse the repository at this point in the history
added parser for r4l
  • Loading branch information
felixleo22 authored Jan 10, 2025
2 parents 8ce7910 + a4b56b5 commit 323f1de
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 0 deletions.
14 changes: 14 additions & 0 deletions r4l/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"longname": "Research4Life",
"name": "r4l",
"describe": "Recognizes the accesses to the platform Research4Life",
"contact": "Violita Kovchegov",
"pkb": false,
"docurl": "https://analyses.ezpaarse.org/platforms/6750a00a10a95d13398078b5",
"domains": [
"hinari.summon.serialssolutions.com",
"login.research4life.org"
],
"version": "2025-01-08",
"status": "beta"
}
65 changes: 65 additions & 0 deletions r4l/parser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/usr/bin/env node

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

/**
* Recognizes the accesses to the platform Research4Life
* @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 ((/^\//i.test(path) && parsedUrl.hash != null) || /^\/search\/?/i.test(path)) {
// https://hinari.summon.serialssolutions.com/#!/search?pn=1&ho=t&include.ft.matches=f&l=en&q=food
// https://hinari.summon.serialssolutions.com/#!/search?pn=1&ho=t&include.ft.matches=f&l=en&q=applied%20economics
result.rtype = 'SEARCH';
result.mime = 'HTML';

} else if ((match = /^\/(tacsgr1pubs_acs_org|tacsgr1cdnsciencepub_com)\/doi\/pdf\/([0-9.]+)\/([.A-Za-z0-9-]+)$/i.exec(path)) !== null) {
// https://login.research4life.org/tacsgr1pubs_acs_org/doi/pdf/10.1021/acs.jafc.8b05215
// https://login.research4life.org/tacsgr1cdnsciencepub_com/doi/pdf/10.1139/apnm-2021-0400
result.rtype = 'ARTICLE';
result.mime = 'PDF';
result.doi = `${match[2]}/${match[3]}`;
result.unitid = `${match[2]}/${match[3]}`;

} else if ((match = /^\/(tacsgr1pubs_acs_org|tacsgr1cdnsciencepub_com)\/(doi|doi\/full)\/([0-9.]+)\/([.A-Za-z0-9-]+)$/i.exec(path)) !== null) {
// https://login.research4life.org/tacsgr1pubs_acs_org/doi/10.1021/acs.jafc.8b05215
// https://login.research4life.org/tacsgr1cdnsciencepub_com/doi/full/10.1139/apnm-2021-0400
result.rtype = 'RECORD';
result.mime = 'HTML';
result.doi = `${match[3]}/${match[4]}`;
result.unitid = `${match[3]}/${match[4]}`;

} else if ((match = /^\/tacsgr1onlinelibrary_wiley_com\/doi\/pdf\/([0-9.]+)\/([A-Za-z0-9.-]+)$/i.exec(path)) !== null) {
// https://login.research4life.org/tacsgr1onlinelibrary_wiley_com/doi/pdf/10.1002/9781118663233.ch17
// https://login.research4life.org/tacsgr1onlinelibrary_wiley_com/doi/pdf/10.1002/9780470768150.ch12
result.rtype = 'BOOK_SECTION';
result.mime = 'PDF';
result.doi = `${match[1]}/${match[2]}`;
result.unitid = `${match[1]}/${match[2]}`;

} else if ((match = /^\/tacsgr1www_spiedigitallibrary_org\/[A-Za-z0-9-]+\/([0-9]+)\/[0-9]+\/[A-Za-z0-9-]+\/([0-9.]+)\/([0-9.]+)(.full)?$/i.exec(path)) !== null) {
// https://login.research4life.org/tacsgr1www_spiedigitallibrary_org/conference-proceedings-of-spie/12941/3011848/Research-on-fresh-food-delivery-path-optimization-based-on-genetic/10.1117/12.3011848.full
// https://login.research4life.org/tacsgr1www_spiedigitallibrary_org/conference-proceedings-of-spie/11915/2605916/Research-on-classification-method-of-food-packaging-character-defects/10.1117/12.2605916.full
result.rtype = 'ARTICLE';
result.mime = 'HTML';
result.vol = match[1];
result.doi = `${match[2]}/${match[3]}`;
result.unitid = `${match[2]}/${match[3]}`;
}

return result;
});
11 changes: 11 additions & 0 deletions r4l/test/r4l.2025-01-08.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
out-vol;out-doi;out-unitid;out-rtype;out-mime;in-url
;;;SEARCH;HTML;"https://hinari.summon.serialssolutions.com/#!/search?pn=1&ho=t&include.ft.matches=f&l=en&q=food"
;;;SEARCH;HTML;https://hinari.summon.serialssolutions.com/#!/search?pn=1&ho=t&include.ft.matches=f&l=en&q=applied%20economics
;10.1021/acs.jafc.8b05215;10.1021/acs.jafc.8b05215;ARTICLE;PDF;https://login.research4life.org/tacsgr1pubs_acs_org/doi/pdf/10.1021/acs.jafc.8b05215
;10.1139/apnm-2021-0400;10.1139/apnm-2021-0400;ARTICLE;PDF;https://login.research4life.org/tacsgr1cdnsciencepub_com/doi/pdf/10.1139/apnm-2021-0400
;10.1021/acs.jafc.8b05215;10.1021/acs.jafc.8b05215;RECORD;HTML;https://login.research4life.org/tacsgr1pubs_acs_org/doi/10.1021/acs.jafc.8b05215
;10.1139/apnm-2021-0400;10.1139/apnm-2021-0400;RECORD;HTML;https://login.research4life.org/tacsgr1cdnsciencepub_com/doi/full/10.1139/apnm-2021-0400
;10.1002/9781118663233.ch17;10.1002/9781118663233.ch17;BOOK_SECTION;PDF;https://login.research4life.org/tacsgr1onlinelibrary_wiley_com/doi/pdf/10.1002/9781118663233.ch17
;10.1002/9780470768150.ch12;10.1002/9780470768150.ch12;BOOK_SECTION;PDF;https://login.research4life.org/tacsgr1onlinelibrary_wiley_com/doi/pdf/10.1002/9780470768150.ch12
12941;10.1117/12.3011848;10.1117/12.3011848;ARTICLE;HTML;https://login.research4life.org/tacsgr1www_spiedigitallibrary_org/conference-proceedings-of-spie/12941/3011848/Research-on-fresh-food-delivery-path-optimization-based-on-genetic/10.1117/12.3011848.full
11915;10.1117/12.2605916;10.1117/12.2605916;ARTICLE;HTML;https://login.research4life.org/tacsgr1www_spiedigitallibrary_org/conference-proceedings-of-spie/11915/2605916/Research-on-classification-method-of-food-packaging-character-defects/10.1117/12.2605916.full

0 comments on commit 323f1de

Please sign in to comment.