{"record":{"id":"866a73ee2dbfdf58","repo":"jackwener/OpenCLI","slug":"zlibrary-search","errorCode":null,"errorMessage":"zlibrary search","messagePattern":"zlibrary search","errorType":"error_code","errorClass":"EmptyResultError","httpStatus":null,"severity":"error","filePath":"clis/zlibrary/search.js","lineNumber":39,"sourceCode":"    {\n      name: 'limit',\n      type: 'int',\n      default: 10,\n      help: 'Max results (1–25)',\n    },\n  ],\n  columns: ['rank', 'title', 'author', 'url'],\n  func: async (page, args) => {\n    const limit = Math.max(1, Math.min(Number(args.limit) || 10, 25));\n    const searchUrl = buildSearchUrl(args.query);\n\n    await page.goto(searchUrl, { waitUntil: 'load', settleMs: 3000 });\n    await page.wait({ time: 5 });\n\n    const results = await extractSearchResults(page, limit);\n\n    if (!results.length) {\n      throw new EmptyResultError(\n        'zlibrary search',\n        'No books found. Try a different keyword or check that you are logged into Z-Library.',\n      );\n    }\n\n    return results;\n  },\n});\n","sourceCodeStart":21,"sourceCodeEnd":48,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/zlibrary/search.js#L21-L48","documentation":"The zlibrary search command throws EmptyResultError (code EMPTY_RESULT, exit 66) when extractSearchResults returns zero results for the query. This distinguishes a successful run with no matches (or an invisible results page due to login state) from a hard failure.","triggerScenarios":"Searching a keyword with no matches, running while logged out so Z-Library hides/suppresses results, or Z-Library changing its search-results markup so the extractor finds nothing.","commonSituations":"Overly specific query strings, typos in the search term, expired login session, bot challenge page replacing results, or site layout changes after an update.","solutions":["Retry with a broader or different keyword","Log in to Z-Library in the controlled browser and retry","Check the rendered page manually for a captcha/login wall and resolve it","Update the zlibrary adapter if the results markup changed"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if (!query || !query.trim()) throw new Error('search query required');","typeGuard":null,"tryCatchPattern":"try {\n  results = await zlibrarySearch({ query, limit });\n} catch (e) {\n  if (e?.code === 'EMPTY_RESULT') {\n    // widen the query or check login state\n  }\n  throw e;\n}","preventionTips":["Use broader keywords on first attempt, then refine","Confirm Z-Library login before searching","Treat exit code 66 as \"try another keyword\" in automation","Watch for captcha/login-wall pages replacing results"],"tags":["scraping","empty-result","zlibrary","search"],"backgroundTag":"empty-scrape-result","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}