Coder Social home page Coder Social logo

oai-pmh's People

Contributors

andrenarchy avatar jmaferreira avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

oai-pmh's Issues

Error runinng sample code.

I am getting the following error running the sample code.
My Node version is v10.5.0 and npm 6.1.0

(function (exports, require, module, __filename, __dirname) { import { OaiPmh } from 'oai-pmh'
^

SyntaxError: Unexpected token {
at new Script (vm.js:74:7)
at createScript (vm.js:246:10)
at Object.runInThisContext (vm.js:298:10)
at Module._compile (internal/modules/cjs/loader.js:670:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
at Module.load (internal/modules/cjs/loader.js:612:32)
at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
at Function.Module._load (internal/modules/cjs/loader.js:543:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:744:10)
at startup (internal/bootstrap/node.js:240:19)

multiple set use

Can I use an array like: ['cs', 'stat'] to 'set' param when call listRecords function?

GetRecord async error

From this script

import { OaiPmh } from 'oai-pmh'

async function main () {
const oaiPmh = new OaiPmh('http://www.culturaitalia.it/oaiProviderCI/OAIHandler')
const identifierIterator = oaiPmh.getRecord({
metadataPrefix: 'oai_dc',
identifier:'oai:culturaitalia.it:oai:www.michael-culture.it:pub-it/dcollection/IT-DC-e555496e'
})
for await (const identifier of identifierIterator) {
console.log(identifier)
}
}

main().catch(console.error)

Running the command getRecord I got this error(s)

TypeError: identifierIterator is not async iterable
at main (/Users/matteo/vsProject/OAI-PMH/richiesta_terminale.js:9:34)
at Object. (/Users/matteo/vsProject/OAI-PMH/richiesta_terminale.js:14:1)
at Cl (/Users/matteo/node_modules/esm/esm.js:1:210825)
at Object.run (/Users/matteo/node_modules/esm/esm.js:1:209532)
at Object. (/Users/matteo/vsProject/OAI-PMH/richiesta_terminale.js:1:86)
at Object. (/Users/matteo/node_modules/esm/esm.js:1:223819)
at eu (/Users/matteo/node_modules/esm/esm.js:1:217938)
at /Users/matteo/node_modules/esm/esm.js:1:219136
at ou (/Users/matteo/node_modules/esm/esm.js:1:219372)
at Object.g (/Users/matteo/node_modules/esm/esm.js:1:230080)
(node:23762) UnhandledPromiseRejectionWarning: OaiPmhError: OAI-PMH provider returned an error: The request includes illegal arguments, is missing required arguments, includes a repeated argument, or values for arguments have an illegal syntax.
at new OaiPmhError (/Users/matteo/node_modules/oai-pmh/src/errors.js:8:11)
at parseOaiPmhXml (/Users/matteo/node_modules/oai-pmh/src/oai-pmh-xml.js:24:11)
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:23762) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:23762) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

TypeError: initialResult[field] is not iterable - when only 1 item is returned from site.

How to reproduce.

oai-pmh list-sets https://oai.mikromarc.no/OAI/mic 

The reason is that the result will not be an array because of the option to parseString explicitArray: false,. This results in that you can't iterate on it.

There is two ways to solve this in oai-pmh-list.js

Concat returned item into an array in both locations.

// Line 33
for (const item of [].concat(initialResult[field])) {
// Line 49
for (const item of [].concat(result[field])) {

A alternative is to check if the returned object if it is iterable.

if (typeof initialResult[field][Symbol.iterator] === 'function') {
  for (const item of initialResult[field]) {
    yield item
  }
}
else {
  yield  initialResult[field]
}
if (typeof result[field][Symbol.iterator] === 'function') {
  for (const item of result[field]) {
    yield item
  }
}
else {
  yield  result[field]
}

Error: OAI-PMH provider returned an error: ListRecords verb must receive the metadataPrefix parameter

(node:17832) UnhandledPromiseRejectionWarning: Error: OAI-PMH provider returned an error: ListRecords verb must receive the metadataPrefix parameter
    at new OaiPmhError (/Users/mferreira/git/ipca-pw/oai-pmh-harvester/node_modules/oai-pmh/dist/utils.js:40:11)
    at _parseOaiPmhXml (/Users/mferreira/git/ipca-pw/oai-pmh-harvester/node_modules/oai-pmh/dist/utils.js:66:11)
    at _parseOaiPmhXml.next (<anonymous>)
    at onFulfilled (/Users/mferreira/git/ipca-pw/oai-pmh-harvester/node_modules/co/index.js:65:19)
    at tryCatcher (/Users/mferreira/git/ipca-pw/oai-pmh-harvester/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/mferreira/git/ipca-pw/oai-pmh-harvester/node_modules/bluebird/js/release/promise.js:512:31)
    at Promise._settlePromise (/Users/mferreira/git/ipca-pw/oai-pmh-harvester/node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromiseCtx (/Users/mferreira/git/ipca-pw/oai-pmh-harvester/node_modules/bluebird/js/release/promise.js:606:10)
    at Async._drainQueue (/Users/mferreira/git/ipca-pw/oai-pmh-harvester/node_modules/bluebird/js/release/async.js:138:12)
    at Async._drainQueues (/Users/mferreira/git/ipca-pw/oai-pmh-harvester/node_modules/bluebird/js/release/async.js:143:10)
    at Immediate.Async.drainQueues [as _onImmediate] (/Users/mferreira/git/ipca-pw/oai-pmh-harvester/node_modules/bluebird/js/release/async.js:17:14)
    at runCallback (timers.js:794:20)
    at tryOnImmediate (timers.js:752:5)
    at processImmediate [as _immediateCallback] (timers.js:729:5)
(node:17832) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3)
(node:17832) UnhandledPromiseRejectionWarning: Error: OAI-PMH provider returned an error: ListRecords verb must receive the metadataPrefix parameter
    at new OaiPmhError (/Users/mferreira/git/ipca-pw/oai-pmh-harvester/node_modules/oai-pmh/dist/utils.js:40:11)
    at _parseOaiPmhXml (/Users/mferreira/git/ipca-pw/oai-pmh-harvester/node_modules/oai-pmh/dist/utils.js:66:11)
    at _parseOaiPmhXml.next (<anonymous>)
    at onFulfilled (/Users/mferreira/git/ipca-pw/oai-pmh-harvester/node_modules/co/index.js:65:19)
    at tryCatcher (/Users/mferreira/git/ipca-pw/oai-pmh-harvester/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/mferreira/git/ipca-pw/oai-pmh-harvester/node_modules/bluebird/js/release/promise.js:512:31)
    at Promise._settlePromise (/Users/mferreira/git/ipca-pw/oai-pmh-harvester/node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromiseCtx (/Users/mferreira/git/ipca-pw/oai-pmh-harvester/node_modules/bluebird/js/release/promise.js:606:10)
    at Async._drainQueue (/Users/mferreira/git/ipca-pw/oai-pmh-harvester/node_modules/bluebird/js/release/async.js:138:12)
    at Async._drainQueues (/Users/mferreira/git/ipca-pw/oai-pmh-harvester/node_modules/bluebird/js/release/async.js:143:10)
    at Immediate.Async.drainQueues [as _onImmediate] (/Users/mferreira/git/ipca-pw/oai-pmh-harvester/node_modules/bluebird/js/release/async.js:17:14)
    at runCallback (timers.js:794:20)
    at tryOnImmediate (timers.js:752:5)
    at processImmediate [as _immediateCallback] (timers.js:729:5)
(node:17832) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 4)

When trying to harvest "http://arca.igc.gulbenkian.pt/oaiextended/request"

Compiling error

Do you know why is getting me this compiling error?
I'm just using the code in the example
I run using "node -r esm" like in the example and it run perfectly
**`import { OaiPmh } from 'oai-pmh'

async function main () {
const oaiPmh = new OaiPmh('http://export.arxiv.org/oai2')
const identifierIterator = oaiPmh.listIdentifiers({
metadataPrefix: 'oai_dc',
from: '2015-01-01',
until: '2015-01-04'
})
for await (const identifier of identifierIterator) {
console.log(identifier)
}
}

main().catch(console.error)`**
but when i tried to use in normal code compilng an app it gets me the following error:
image

Resumption token not read

When I tried to list records (or identifiers), I got

Error: OAI-PMH provider returned an error: The request is missing required arguments.

after the first batch. Testing a little bit confirmed that the error was caused by the resumption token being null. When I had a look at the code to try to understand why, I was puzzled by line 39 in index.js:

          resumptionToken: self.currentResult.resumptionToken._,

If I remove ._ it sends the resumption token correctly. But since the ._ has been there for so long, I assume it must have some intention? I'm only working with Node occasionally, so I'm not able to figure out what, though :)

To reproduce: With Node 8.6.0:

oai-pmh list-records -p marc21 -s oai_komplett http://bibsys-k.alma.exlibrisgroup.com/view/oai/47BIBSYS_UBO/request

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.