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

update parser az #817

Merged
merged 2 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
28 changes: 26 additions & 2 deletions az/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module.exports = new Parser(function analyseEC(parsedUrl, ec) {

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

let marginal;
//let match;

if (/^\/maf\/app\/delivery\/document$/i.test(path)) {
Expand All @@ -28,7 +28,7 @@ module.exports = new Parser(function analyseEC(parsedUrl, ec) {
result.db_id = param._;
result.unitid = param.docguid;

} else if (/^\/maf\/app\/document$/i.test(path)) {
} else if (/^\/maf\/app\/document$/i.test(path) && parsedUrl.hostname == 'aranzadi.aranzadidigital.es') {
if (param.marginal) {
// http://aranzadi.aranzadidigital.es/maf/app/document?startChunk=1&endChunk=2&stid=marginal_chunk&ds=ARZ_LEGIS_CS&infotype=arz_legis&marginal=RCL\2004\1466&version=&srguid=i0ad6adc60000018b4985c8a0c99bd9dd&lang=spa&src=withinResuts&spos=1&epos=1&mdfilter=mdlegisfilter
// http://aranzadi.aranzadidigital.es/maf/app/document?startChunk=1&endChunk=2&stid=marginal_chunk&ds=ARZ_LEGIS_CS&infotype=arz_legis&marginal=RCL\1979\2289&version=&srguid=i0ad6adc60000018b4985c8a0c99bd9dd&lang=spa&src=withinResuts&spos=10&epos=10&mdfilter=mdlegisfilter
Expand All @@ -52,6 +52,30 @@ module.exports = new Parser(function analyseEC(parsedUrl, ec) {
// http://aranzadi.aranzadidigital.es/maf/app/search/run/multi
result.rtype = 'SEARCH';
result.mime = 'HTML';
} else if (/^\/maf\/app\/document$/i.test(path) && (marginal = param.marginal) != undefined && (marginal.split('\\')[0] === 'RJ' || marginal.split('\\')[0] === 'RCL')) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can group several parsers into a single one by using lot of if or a switch.

} else if (/^\/maf\/app\/document$/i.test(path)) {
    // /maf/app/document?startChunk=1&mdfilter=mdlegisfilter&endChunk=2&stid=marginal_chunk&ds=ARZ_LEGIS_CS&infotype=arz_legis&subResult=i0ad6adc60000018ed0247a839bee5891&docguid=I6b664a40e83811db8079010000000000&marginal=RCL\1999\710&spos=1&epos=1&version=19990406&displayName=&lang=spa
    // /maf/app/document?srguid=i0ad6adc50000018ed0247dc8eb6fe26f&marginal=RJ\2017\1890&docguid=I03fcd8903aa011e79de2010000000000&ds=ARZ_LEGIS_CS&infotype=arz_doc-admin;&spos=1&epos=1&td=0&predefinedRelationshipsType=documentRetrieval&global-result-list=global&fromTemplate=&suggestScreen=&&selectedNodeName=&selec_mod=false&displayName=
    marginal = param.marginal
    
    if (marginal.split('\\')[0] === 'RJ' || marginal.split('\\')[0] === 'RCL') {
      // /maf/app/document?startChunk=1&mdfilter=mdlegisfilter&endChunk=2&stid=marginal_chunk&ds=ARZ_LEGIS_CS&infotype=arz_legis&subResult=i0ad6adc60000018ed0247a839bee5891&docguid=I6b664a40e83811db8079010000000000&marginal=RCL\1999\710&spos=1&epos=1&version=19990406&displayName=&lang=spa
      // /maf/app/document?srguid=i0ad6adc50000018ed0247dc8eb6fe26f&marginal=RJ\2017\1890&docguid=I03fcd8903aa011e79de2010000000000&ds=ARZ_LEGIS_CS&infotype=arz_doc-admin;&spos=1&epos=1&td=0&predefinedRelationshipsType=documentRetrieval&global-result-list=global&fromTemplate=&suggestScreen=&&selectedNodeName=&selec_mod=false&displayName=
      result.rtype    = 'ARTICLE';
      result.mime     = 'HTML';
      result.unitid   = marginal;
    }

    if (marginal.split('\\')[0] === 'BIB') {
      // /maf/app/document?srguid=i0ad6adc50000018ed0247a19ba6a7861&marginal=BIB\2021\1098&docguid=I2e8fecd0a23611ebaf9ae70e1612b1e3&ds=ARZ_LEGIS_CS&infotype=arz_biblos;&spos=1&epos=1&td=0&predefinedRelationshipsType=documentRetrieval&fromTemplate=&suggestScreen=&&selectedNodeName=&selec_mod=false&displayName=
      // /maf/app/document?srguid=i0ad6adc50000018ed0247a19ba6a7861&marginal=BIB\2015\322&docguid=Idbdd5360a82c11e4b065010000000000&ds=ARZ_LEGIS_CS&infotype=arz_biblos;&spos=5&epos=5&td=0&predefinedRelationshipsType=documentRetrieval&fromTemplate=&suggestScreen=&&selectedNodeName=&selec_mod=false&displayName=
      result.rtype    = 'BOOK';
      result.mime     = 'HTML';
      result.unitid   = marginal;
    }

    if (marginal.split('\\')[0] === 'FOR') {
      // /maf/app/document?srguid=i0ad6adc50000018ed0247c23d3a4bb99&marginal=FOR\2012\839&docguid=I0eb20050b1e111e1847d010000000000&ds=ARZ_LEGIS_CS&infotype=arz_formularios;&spos=1&epos=1&td=0&predefinedRelationshipsType=documentRetrieval&fromTemplate=&suggestScreen=&&selectedNodeName=&selec_mod=false&displayName=
      // /maf/app/document?srguid=i0ad6adc50000018ed0247c23d3a4bb99&marginal=FOR\2011\924&docguid=I55351570de7f11e0a788010000000000&ds=ARZ_LEGIS_CS&infotype=arz_formularios;&spos=8&epos=8&td=0&predefinedRelationshipsType=documentRetrieval&fromTemplate=&suggestScreen=&&selectedNodeName=&selec_mod=false&displayName=
      result.rtype    = 'FORMULES';
      result.mime     = 'HTML';
      result.unitid   = marginal;
    }

    if (marginal.split('\\')[0] === 'MIX') {
      // /maf/app/document?srguid=i0ad6adc50000018ed0247b3d15b13605&marginal=MIX\2023\211717&docguid=Id421ff501ef611eeba5fb46f48ac422d&ds=ARZ_LEGIS_CS&infotype=arz_cuadros;&spos=1&epos=1&td=0&predefinedRelationshipsType=documentRetrieval&fromTemplate=&suggestScreen=&&selectedNodeName=&selec_mod=false&displayName=
      // /maf/app/document?srguid=i0ad6adc50000018ed0247b3d15b13605&marginal=MIX\2004\583&docguid=I4aa5994075a211dba338010000000000&ds=ARZ_LEGIS_CS&infotype=arz_cuadros;&spos=2&epos=2&td=0&predefinedRelationshipsType=documentRetrieval&fromTemplate=&suggestScreen=&&selectedNodeName=&selec_mod=false&displayName=#
      result.rtype    = 'IMAGE';
      result.mime     = 'PDF';
      result.unitid   = marginal;
    }
  }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,
I have modified the code. Please check.
Thanks!

// https://insignis.aranzadidigital.es/maf/app/document?startChunk=1&mdfilter=mdlegisfilter&endChunk=2&stid=marginal_chunk&ds=ARZ_LEGIS_CS&infotype=arz_legis&subResult=i0ad6adc60000018ed0247a839bee5891&docguid=I6b664a40e83811db8079010000000000&marginal=RCL\1999\710&spos=1&epos=1&version=19990406&displayName=&lang=spa
// https://insignis.aranzadidigital.es/maf/app/document?srguid=i0ad6adc50000018ed0247dc8eb6fe26f&marginal=RJ\2017\1890&docguid=I03fcd8903aa011e79de2010000000000&ds=ARZ_LEGIS_CS&infotype=arz_doc-admin;&spos=1&epos=1&td=0&predefinedRelationshipsType=documentRetrieval&global-result-list=global&fromTemplate=&suggestScreen=&&selectedNodeName=&selec_mod=false&displayName=
result.rtype = 'ARTICLE';
result.mime = 'HTML';
result.unitid = marginal;
} else if (/^\/maf\/app\/document$/i.test(path) && (marginal = param.marginal) != undefined && marginal.split('\\')[0] == 'BIB') {
// https://insignis.aranzadidigital.es/maf/app/document?srguid=i0ad6adc50000018ed0247a19ba6a7861&marginal=BIB\2021\1098&docguid=I2e8fecd0a23611ebaf9ae70e1612b1e3&ds=ARZ_LEGIS_CS&infotype=arz_biblos;&spos=1&epos=1&td=0&predefinedRelationshipsType=documentRetrieval&fromTemplate=&suggestScreen=&&selectedNodeName=&selec_mod=false&displayName=
// https://insignis.aranzadidigital.es/maf/app/document?srguid=i0ad6adc50000018ed0247a19ba6a7861&marginal=BIB\2015\322&docguid=Idbdd5360a82c11e4b065010000000000&ds=ARZ_LEGIS_CS&infotype=arz_biblos;&spos=5&epos=5&td=0&predefinedRelationshipsType=documentRetrieval&fromTemplate=&suggestScreen=&&selectedNodeName=&selec_mod=false&displayName=
result.rtype = 'BOOK';
result.mime = 'HTML';
result.unitid = marginal;
} else if (/^\/maf\/app\/document$/i.test(path) && (marginal = param.marginal) != undefined && marginal.split('\\')[0] == 'FOR') {
// https://insignis.aranzadidigital.es/maf/app/document?srguid=i0ad6adc50000018ed0247c23d3a4bb99&marginal=FOR\2012\839&docguid=I0eb20050b1e111e1847d010000000000&ds=ARZ_LEGIS_CS&infotype=arz_formularios;&spos=1&epos=1&td=0&predefinedRelationshipsType=documentRetrieval&fromTemplate=&suggestScreen=&&selectedNodeName=&selec_mod=false&displayName=
// https://insignis.aranzadidigital.es/maf/app/document?srguid=i0ad6adc50000018ed0247c23d3a4bb99&marginal=FOR\2011\924&docguid=I55351570de7f11e0a788010000000000&ds=ARZ_LEGIS_CS&infotype=arz_formularios;&spos=8&epos=8&td=0&predefinedRelationshipsType=documentRetrieval&fromTemplate=&suggestScreen=&&selectedNodeName=&selec_mod=false&displayName=
result.rtype = 'FORMULES';
result.mime = 'HTML';
result.unitid = marginal;
} else if (/^\/maf\/app\/document$/i.test(path) && (marginal = param.marginal) != undefined && marginal.split('\\')[0] == 'MIX') {
// https://insignis.aranzadidigital.es/maf/app/document?srguid=i0ad6adc50000018ed0247b3d15b13605&marginal=MIX\2023\211717&docguid=Id421ff501ef611eeba5fb46f48ac422d&ds=ARZ_LEGIS_CS&infotype=arz_cuadros;&spos=1&epos=1&td=0&predefinedRelationshipsType=documentRetrieval&fromTemplate=&suggestScreen=&&selectedNodeName=&selec_mod=false&displayName=
// https://insignis.aranzadidigital.es/maf/app/document?srguid=i0ad6adc50000018ed0247b3d15b13605&marginal=MIX\2004\583&docguid=I4aa5994075a211dba338010000000000&ds=ARZ_LEGIS_CS&infotype=arz_cuadros;&spos=2&epos=2&td=0&predefinedRelationshipsType=documentRetrieval&fromTemplate=&suggestScreen=&&selectedNodeName=&selec_mod=false&displayName=#
result.rtype = 'IMAGE';
result.mime = 'PDF';
result.unitid = marginal;
}

return result;
Expand Down
16 changes: 16 additions & 0 deletions az/test/AZ.2024-04-19.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
out-db_id;out-unitid;out-rtype;out-mime;in-url
;MIX\2004\583;IMAGE;PDF;"https://insignis.aranzadidigital.es/maf/app/document?srguid=i0ad6adc50000018ed0247b3d15b13605&marginal=MIX\2004\583&docguid=I4aa5994075a211dba338010000000000&ds=ARZ_LEGIS_CS&infotype=arz_cuadros;&spos=2&epos=2&td=0&predefinedRelationshipsType=documentRetrieval&fromTemplate=&suggestScreen=&&selectedNodeName=&selec_mod=false&displayName=#"
;MIX\2023\211717;IMAGE;PDF;"https://insignis.aranzadidigital.es/maf/app/document?srguid=i0ad6adc50000018ed0247b3d15b13605&marginal=MIX\2023\211717&docguid=Id421ff501ef611eeba5fb46f48ac422d&ds=ARZ_LEGIS_CS&infotype=arz_cuadros;&spos=1&epos=1&td=0&predefinedRelationshipsType=documentRetrieval&fromTemplate=&suggestScreen=&&selectedNodeName=&selec_mod=false&displayName="
;FOR\2011\924;FORMULES;HTML;"https://insignis.aranzadidigital.es/maf/app/document?srguid=i0ad6adc50000018ed0247c23d3a4bb99&marginal=FOR\2011\924&docguid=I55351570de7f11e0a788010000000000&ds=ARZ_LEGIS_CS&infotype=arz_formularios;&spos=8&epos=8&td=0&predefinedRelationshipsType=documentRetrieval&fromTemplate=&suggestScreen=&&selectedNodeName=&selec_mod=false&displayName="
;FOR\2012\839;FORMULES;HTML;"https://insignis.aranzadidigital.es/maf/app/document?srguid=i0ad6adc50000018ed0247c23d3a4bb99&marginal=FOR\2012\839&docguid=I0eb20050b1e111e1847d010000000000&ds=ARZ_LEGIS_CS&infotype=arz_formularios;&spos=1&epos=1&td=0&predefinedRelationshipsType=documentRetrieval&fromTemplate=&suggestScreen=&&selectedNodeName=&selec_mod=false&displayName="
;BIB\2015\322;BOOK;HTML;"https://insignis.aranzadidigital.es/maf/app/document?srguid=i0ad6adc50000018ed0247a19ba6a7861&marginal=BIB\2015\322&docguid=Idbdd5360a82c11e4b065010000000000&ds=ARZ_LEGIS_CS&infotype=arz_biblos;&spos=5&epos=5&td=0&predefinedRelationshipsType=documentRetrieval&fromTemplate=&suggestScreen=&&selectedNodeName=&selec_mod=false&displayName="
;BIB\2021\1098;BOOK;HTML;"https://insignis.aranzadidigital.es/maf/app/document?srguid=i0ad6adc50000018ed0247a19ba6a7861&marginal=BIB\2021\1098&docguid=I2e8fecd0a23611ebaf9ae70e1612b1e3&ds=ARZ_LEGIS_CS&infotype=arz_biblos;&spos=1&epos=1&td=0&predefinedRelationshipsType=documentRetrieval&fromTemplate=&suggestScreen=&&selectedNodeName=&selec_mod=false&displayName="
;RJ\2017\1890;ARTICLE;HTML;"https://insignis.aranzadidigital.es/maf/app/document?srguid=i0ad6adc50000018ed0247dc8eb6fe26f&marginal=RJ\2017\1890&docguid=I03fcd8903aa011e79de2010000000000&ds=ARZ_LEGIS_CS&infotype=arz_doc-admin;&spos=1&epos=1&td=0&predefinedRelationshipsType=documentRetrieval&global-result-list=global&fromTemplate=&suggestScreen=&&selectedNodeName=&selec_mod=false&displayName="
;RCL\1999\710;ARTICLE;HTML;https://insignis.aranzadidigital.es/maf/app/document?startChunk=1&mdfilter=mdlegisfilter&endChunk=2&stid=marginal_chunk&ds=ARZ_LEGIS_CS&infotype=arz_legis&subResult=i0ad6adc60000018ed0247a839bee5891&docguid=I6b664a40e83811db8079010000000000&marginal=RCL\1999\710&spos=1&epos=1&version=19990406&displayName=&lang=spa
;;SEARCH;HTML;https://insignis.aranzadidigital.es/maf/app/search/run/multi
;I0661f5f02b8a11e1936b010000000000;FORMULES;HTML;http://aranzadi.aranzadidigital.es/maf/app/document?docguid=I0661f5f02b8a11e1936b010000000000&srguid=i0ad6adc60000018b49ab472c81fff954&src=withinResuts&spos=4&epos=4
;I0aabd1b05e2a11e8a041010000000000;FORMULES;HTML;http://aranzadi.aranzadidigital.es/maf/app/document?docguid=I0aabd1b05e2a11e8a041010000000000&srguid=i0ad6adc60000018b49ab472c81fff954&src=withinResuts&spos=1&epos=1
1697747395452;I3407bf608eb111ea98abc16d771da8bc;ARTICLE;PDF;http://aranzadi.aranzadidigital.es/maf/app/delivery/document?_=1697747395452&deliveryTarget=save&deliveryType=document&infoType=arz_legis&typeTitle=Legislaci%C3%B3n&magazines=&srguid=i0ad6adc60000018b49a00a26fc754444&td=0&docTitle=Desarrolla+el+Estatuto+del+Trabajo+Aut%C3%B3nomo++(RCL+2007%5C1354)+en+materia+de+contrato+del+trabajador+aut%C3%B3n...&label=Real+Decreto+n%C3%BAm.+197%2F2009%2C+de+23+febrero&docguid=I3407bf608eb111ea98abc16d771da8bc
;RCL\1979\2289;ARTICLE;HTML;http://aranzadi.aranzadidigital.es/maf/app/document?startChunk=1&endChunk=2&stid=marginal_chunk&ds=ARZ_LEGIS_CS&infotype=arz_legis&marginal=RCL\1979\2289&version=&srguid=i0ad6adc60000018b4985c8a0c99bd9dd&lang=spa&src=withinResuts&spos=10&epos=10&mdfilter=mdlegisfilter
;RCL\2004\1466;ARTICLE;HTML;http://aranzadi.aranzadidigital.es/maf/app/document?startChunk=1&endChunk=2&stid=marginal_chunk&ds=ARZ_LEGIS_CS&infotype=arz_legis&marginal=RCL\2004\1466&version=&srguid=i0ad6adc60000018b4985c8a0c99bd9dd&lang=spa&src=withinResuts&spos=1&epos=1&mdfilter=mdlegisfilter
;;SEARCH;HTML;http://aranzadi.aranzadidigital.es/maf/app/search/run/multi
9 changes: 0 additions & 9 deletions az/test/az.2023-11-01.csv

This file was deleted.

Loading