Skip to content

Commit

Permalink
Merge pull request #810 from OCLC-Developer-Network/morning
Browse files Browse the repository at this point in the history
update parser morning
  • Loading branch information
felixleo22 authored Mar 29, 2024
2 parents 7dc1404 + 821d88f commit fb1fa5f
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 9 deletions.
3 changes: 2 additions & 1 deletion morning/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"domains": [
"library.morningstar.com",
"datanalysis.morningstar.com.au",
"ar.morningstar.com"
"ar.morningstar.com",
"research.morningstar.com"
],
"version": "2021-01-15",
"status": "beta"
Expand Down
29 changes: 27 additions & 2 deletions morning/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ module.exports = new Parser(function analyseEC(parsedUrl, ec) {
// http://library.morningstar.com/ArticleSuppot/article?id=1016715
result.rtype = 'ARTICLE';
result.mime = 'HTML';
result.unitid = param.id;

result.unitid = param.id;
} else if ((match = /^\/videos\/$/i.exec(path)) !== null) {
// http://library.morningstar.com/videos/?id=1017223
result.rtype = 'VIDEO';
Expand All @@ -46,6 +45,32 @@ module.exports = new Parser(function analyseEC(parsedUrl, ec) {
result.rtype = 'REPORT';
result.mime = 'PDF';
result.unitid = match[1];
} else if (/^\/home$/i.test(path) && parsedUrl.hostname === 'research.morningstar.com') {
// https://research.morningstar.com/home
result.rtype = 'SESSION';
result.mime = 'HTML';
} else if (/^\/chart$/i.test(path) && parsedUrl.hostname === 'research.morningstar.com') {
// https://research.morningstar.com/chart
result.rtype = 'DATASET';
result.mime = 'HTML';
} else if (/^\/calendar$/i.test(path) && parsedUrl.hostname === 'research.morningstar.com') {
// https://research.morningstar.com/calendar
result.rtype = 'TOOL';
result.mime = 'HTML';
} else if ((match = /^\/articles\/([0-9a-zA-Z]+)\/([a-zA-Z0-9-]+)$/i.exec(path)) !== null) {
// https://research.morningstar.com/articles/1190828/charging-the-future-unleashing-the-power-of-battery-technology
// https://research.morningstar.com/articles/1189996/inflation-still-expected-to-plummet
result.rtype = 'ARTICLE';
result.mime = 'HTML';
result.title_id = match[2];
result.db_id = match[1];
result.unitid = `${match[1]}/${match[2]}`;
} else if ((match = /^\/api\/v1\/articles\/([0-9]+)\/file$/i.exec(path)) !== null) {
// https://research.morningstar.com/api/v1/articles/1189179/file?type=AnalystClientResearch
// https://research.morningstar.com/api/v1/articles/20151/file?type=CommonArticle
result.rtype = 'ARTICLE';
result.mime = 'PDF';
result.unitid = match[1];
}

return result;
Expand Down
13 changes: 13 additions & 0 deletions morning/test/Morning.2024-03-26.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
out-title_id;out-db_id;out-unitid;out-rtype;out-mime;in-url
;;20151;ARTICLE;PDF;https://research.morningstar.com/api/v1/articles/20151/file?type=CommonArticle
;;1189179;ARTICLE;PDF;https://research.morningstar.com/api/v1/articles/1189179/file?type=AnalystClientResearch
inflation-still-expected-to-plummet;1189996;1189996/inflation-still-expected-to-plummet;ARTICLE;HTML;https://research.morningstar.com/articles/1189996/inflation-still-expected-to-plummet
charging-the-future-unleashing-the-power-of-battery-technology;1190828;1190828/charging-the-future-unleashing-the-power-of-battery-technology;ARTICLE;HTML;https://research.morningstar.com/articles/1190828/charging-the-future-unleashing-the-power-of-battery-technology
;;;TOOL;HTML;https://research.morningstar.com/calendar
;;;DATASET;HTML;https://research.morningstar.com/chart
;;;SESSION;HTML;https://research.morningstar.com/home
;;Consumer_Cyclical_Q4_2020;REPORT;PDF;http://library.morningstar.com/Returns/Consumer_Cyclical_Q4_2020.pdf
;;;REPORT;HTML;http://library.morningstar.com/Returns/CategoryReturns.html
;;0P0001KOSA;REPORT;HTML;http://library.morningstar.com/v2/quote?id=0P0001KOSA&typeid=ST
;;1017223;VIDEO;MISC;http://library.morningstar.com/videos/?id=1017223
;;1016715;ARTICLE;HTML;http://library.morningstar.com/ArticleSuppot/article?id=1016715
6 changes: 0 additions & 6 deletions morning/test/morning.2021-01-15.csv

This file was deleted.

0 comments on commit fb1fa5f

Please sign in to comment.