-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #838 from OCLC-Developer-Network/chilton
develop parser chilton
- Loading branch information
Showing
3 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"longname": "Chilton", | ||
"name": "chilton", | ||
"describe": "Recognizes the accesses to the platform Chilton", | ||
"contact": "Violita Kovchegov", | ||
"pkb": false, | ||
"docurl": "http://analyses.ezpaarse.org/platforms/6688515723b4aef40b1b8fb3", | ||
"domains": [ | ||
"app.chiltonlibrary.com", | ||
"appcontent.chiltonlibrary.com" | ||
], | ||
"version": "2024-07-15", | ||
"status": "beta" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/usr/bin/env node | ||
|
||
'use strict'; | ||
const Parser = require('../.lib/parser.js'); | ||
|
||
/** | ||
* Recognizes the accesses to the platform Chilton | ||
* @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 (/^\/search\/[a-zA-Z0-9]+$/i.test(path)) { | ||
// https://app.chiltonlibrary.com/search/bulletins | ||
// https://app.chiltonlibrary.com/search/repair | ||
result.rtype = 'SEARCH'; | ||
result.mime = 'HTML'; | ||
|
||
} else if ((match = /^\/TSBs\/GM\/([0-9]+)\.pdf$/i.exec(path)) !== null) { | ||
// https://appcontent.chiltonlibrary.com/TSBs/GM/6523447.pdf | ||
// https://appcontent.chiltonlibrary.com/TSBs/GM/6520490.pdf | ||
result.rtype = 'REPORT'; | ||
result.mime = 'PDF'; | ||
result.unitid = match[1]; | ||
} else if ((match = /^\/Videos_Animations\/VideoLibrary\/([0-9]+)\/([a-zA-Z0-9\s%]+)\.mp4$/i.exec(path)) !== null) { | ||
// https://appcontent.chiltonlibrary.com/Videos_Animations/VideoLibrary/05/Installation of the brakes.mp4 | ||
// https://appcontent.chiltonlibrary.com/Videos_Animations/VideoLibrary/09/Sensor inputs help the PCM establish the engine operating conditions.mp4 | ||
result.rtype = 'VIDEO'; | ||
result.mime = 'MISC'; | ||
let decoded_title = decodeURI(match[2]); | ||
result.title_id = decoded_title; | ||
result.unitid = `${match[1]}/${decoded_title}`; | ||
} else if ((match = /^\/testprepquiz\/([a-zA-Z0-9]+)$/i.exec(path)) !== null) { | ||
// https://app.chiltonlibrary.com/testprepquiz/a1 | ||
// https://app.chiltonlibrary.com/testprepquiz/a10 | ||
result.rtype = 'EXERCISE'; | ||
result.mime = 'HTML'; | ||
result.unitid = match[1]; | ||
} | ||
|
||
return result; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
out-title_id;out-unitid;out-rtype;out-mime;in-url | ||
;;SEARCH;HTML;https://app.chiltonlibrary.com/search/repair | ||
;6523447;REPORT;PDF;https://appcontent.chiltonlibrary.com/TSBs/GM/6523447.pdf | ||
;6520490;REPORT;PDF;https://appcontent.chiltonlibrary.com/TSBs/GM/6520490.pdf | ||
Installation of the brakes;05/Installation of the brakes;VIDEO;MISC;https://appcontent.chiltonlibrary.com/Videos_Animations/VideoLibrary/05/Installation of the brakes.mp4 | ||
Sensor inputs help the PCM establish the engine operating conditions;09/Sensor inputs help the PCM establish the engine operating conditions;VIDEO;MISC;https://appcontent.chiltonlibrary.com/Videos_Animations/VideoLibrary/09/Sensor inputs help the PCM establish the engine operating conditions.mp4 | ||
;a1;EXERCISE;HTML;https://app.chiltonlibrary.com/testprepquiz/a1 | ||
;a10;EXERCISE;HTML;https://app.chiltonlibrary.com/testprepquiz/a10 | ||
;;SEARCH;HTML;https://app.chiltonlibrary.com/search/bulletins |