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

develop parser chilton #838

Merged
merged 1 commit into from
Jul 16, 2024
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
14 changes: 14 additions & 0 deletions chilton/manifest.json
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"
}
53 changes: 53 additions & 0 deletions chilton/parser.js
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;
});
9 changes: 9 additions & 0 deletions chilton/test/chilton.2024-07-15.csv
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
Loading