summaryrefslogtreecommitdiff
path: root/includes/external/addressbook/node_modules/open-graph-scraper/dist/index.js
diff options
context:
space:
mode:
authorRaindropsSys <contact@minteck.org>2023-04-06 22:18:28 +0200
committerRaindropsSys <contact@minteck.org>2023-04-06 22:18:28 +0200
commit83354b2b88218090988dd6e526b0a2505b57e0f1 (patch)
treee3c73c38a122a78bb7e66fbb99056407edd9d4b9 /includes/external/addressbook/node_modules/open-graph-scraper/dist/index.js
parent47b8f2299a483024c4a6a8876af825a010954caa (diff)
downloadpluralconnect-83354b2b88218090988dd6e526b0a2505b57e0f1.tar.gz
pluralconnect-83354b2b88218090988dd6e526b0a2505b57e0f1.tar.bz2
pluralconnect-83354b2b88218090988dd6e526b0a2505b57e0f1.zip
Updated 5 files and added 1110 files (automated)
Diffstat (limited to 'includes/external/addressbook/node_modules/open-graph-scraper/dist/index.js')
-rw-r--r--includes/external/addressbook/node_modules/open-graph-scraper/dist/index.js56
1 files changed, 56 insertions, 0 deletions
diff --git a/includes/external/addressbook/node_modules/open-graph-scraper/dist/index.js b/includes/external/addressbook/node_modules/open-graph-scraper/dist/index.js
new file mode 100644
index 0000000..fca5cab
--- /dev/null
+++ b/includes/external/addressbook/node_modules/open-graph-scraper/dist/index.js
@@ -0,0 +1,56 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+/* eslint-disable max-len, import/no-import-module-exports */
+const openGraphScraper_1 = require("./lib/openGraphScraper");
+/**
+ * `open-graph-scraper` uses [got](https://github.com/sindresorhus/got) for requests and most of
+ * [got's options](https://github.com/sindresorhus/got/blob/main/documentation/2-options.md)
+ * should work as `open-graph-scraper` options.
+ *
+ * @param {object} options - The options used by Open Graph Scraper
+ * @param {string} options.url - URL of the site. (Required)
+ * @param {string} [options.html] - You can pass in an HTML string to run ogs on it. (use without options.url)
+ * @param {string[]} [options.blacklist] - Pass in an array of sites you don't want ogs to run on.
+ * @param {boolean} [options.onlyGetOpenGraphInfo] - Only fetch open graph info and don't fall back on anything else.
+ * @param {boolean} [options.ogImageFallback] - Fetch other images if no open graph ones are found.
+ * @param {object} [options.customMetaTags] - Here you can define custom meta tags you want to scrape.
+ * @param {boolean} [options.allMedia] - By default, OGS will only send back the first image/video it finds.
+ * @param {number | false} [options.downloadLimit] - Maximum size of the content downloaded from the server, in bytes.
+ * @param {object} [options.ValidatorSettings] - Sets the options used by validator.js for testing the URL
+ * @param {boolean} [options.decompress] - Set the accept-encoding to `gzip, deflate, br` (default: `true`).
+ * @param {boolean} [options.followRedirect] - Defines if redirect responses should be followed automatically. (default: `true`).
+ * @param {Object<string, string>} [options.headers] - An object containing request headers. Useful for setting the user-agent.
+ * @param {number} [options.maxRedirects] - If exceeded, the request will be aborted and a MaxRedirectsError will be thrown. (default: `10`).
+ * @param {object} [options.retry] - Number of times `og`s will retry the request (default: `2`).
+ * @param {object} [options.timeout] - Timeout of the request.
+ * @returns {Promise} Promise Object with the Open Graph results
+ */
+async function run(options) {
+ let results;
+ try {
+ results = await (0, openGraphScraper_1.default)(options);
+ }
+ catch (error) {
+ const exception = error;
+ const returnError = {
+ error: true,
+ result: {
+ success: false,
+ requestUrl: options.url,
+ error: exception.message,
+ errorDetails: exception,
+ },
+ response: undefined,
+ };
+ // eslint-disable-next-line @typescript-eslint/no-throw-literal
+ throw returnError;
+ }
+ const returnSuccess = {
+ error: false,
+ result: results.ogObject,
+ response: results.response,
+ };
+ return returnSuccess;
+}
+exports.default = run;
+module.exports = run;