{"id":13454652,"url":"https://github.com/nodeca/embedza","last_synced_at":"2025-04-12T02:38:49.187Z","repository":{"id":34648351,"uuid":"38612733","full_name":"nodeca/embedza","owner":"nodeca","description":"Create HTML snippets/embeds from URLs using info from oEmbed, Open Graph, meta tags.","archived":false,"fork":false,"pushed_at":"2023-06-19T02:48:28.000Z","size":956,"stargazers_count":65,"open_issues_count":3,"forks_count":5,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-12T02:38:39.156Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://embedza.herokuapp.com/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nodeca.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2015-07-06T10:40:31.000Z","updated_at":"2025-01-24T13:37:32.000Z","dependencies_parsed_at":"2022-07-13T01:30:31.386Z","dependency_job_id":null,"html_url":"https://github.com/nodeca/embedza","commit_stats":{"total_commits":134,"total_committers":3,"mean_commits":"44.666666666666664","dds":"0.31343283582089554","last_synced_commit":"1e3895e70e2de72857be0f2869f3eb7cd4edf06d"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nodeca%2Fembedza","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nodeca%2Fembedza/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nodeca%2Fembedza/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nodeca%2Fembedza/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nodeca","download_url":"https://codeload.github.com/nodeca/embedza/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248507181,"owners_count":21115551,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T08:00:56.389Z","updated_at":"2025-04-12T02:38:49.082Z","avatar_url":"https://github.com/nodeca.png","language":"JavaScript","readme":"embedza\n=======\n\n[![Build Status](https://img.shields.io/travis/nodeca/embedza/master.svg?style=flat)](https://travis-ci.org/nodeca/embedza)\n[![NPM version](https://img.shields.io/npm/v/embedza.svg?style=flat)](https://www.npmjs.org/package/embedza)\n[![Coverage Status](https://coveralls.io/repos/github/nodeca/embedza/badge.svg?branch=master)](https://coveralls.io/github/nodeca/embedza?branch=master)\n\n\u003e Create HTML snippets/embeds from URLs using info from oEmbed,\n\u003e Open Graph, meta tags.\n\nKey feature:\n\n- Supports both block \u0026 inline snippets (by default extracts data from oembed,\n  opengraph and meta tags).\n- Light placeholders for video players to load page without delays. Iframes are\n  loaded only after user clicks \"play\" button.\n- Cacheing.\n- Easy to customize and extend.\n- Dev server to test your changes.\n\n[**Live Demo**](https://embedza.herokuapp.com/)\n\n\nInstall\n-------\n\n```bash\nnpm install embedza --save\n```\n\nrun dev server (with debug messages):\n\n```bash\nDEBUG=embedza:* npm start\n```\n\n\nExample\n-------\n\nRender player for youtube video:\n\n```javascript\nconst Embedza = require('embedza');\nconst embedza = new Embedza();\n\nembedza.render('https://www.youtube.com/watch?v=JrZSfMiVC88', 'block')\n  .then(result =\u003e {\n    if (result) console.log(result.html, result.type);\n  });\n});\n```\n\n\nAPI\n---\n\n\n### new Embedza(options)\n\nCreates new `Embedza` instance with specified options:\n\n- __enabledProviders__ - array of enabled providers or `true` for all providers,\n  default `true`.\n- __cache__ - object with `.get(key) -\u003e Promise` and `.set(key, value) -\u003e Promise`\n  methods. Default stub does nothing.\n- __request__ (optional) - any options for external requests, as described\n  in [`got` docs](https://github.com/sindresorhus/got). For example, you can\n  customize user agent header.\n\n\n### .render(url, type) -\u003e Promise\n\nTry to create HTML snippet of requested type by URL.\n\n- __url__ (String|Object) - content url or result of `.info()`.\n- __type__ ([String]|String) - format name or list of suitable formats\n  by priority ('block', 'inline')\n\nReturns:\n\n- `result.html` - html code\n- `result.type` - matched format type\n\nIf url can not be rendered - returns null. On remote errors fails with\nerror info.\n\n\n### .info(url) -\u003e Promise\n\nSimilar to `.render()`, but returns object with full url description.\n\n- __url__ (String) - resource URL.\n\nReturns:\n\n- `result.domain` - domain plugin id ('youtube.com', 'vimeo.com', ...)\n- `result.src` - source url\n- `result.meta` - title, description, site\n- `result.snippets` - snippets data: type, tags, href, media, html\n\nIf url info does not exists - returns null. On remote errors fails with\nerror info.\n\n\n### .forEach(fn(rule))\n\nIterates through domains rules to modify those.\n\n\n### .rule(name)\n\nGet domain rule by name.\n\n\n### .addDomain(options)\n\nRerister new service. If `String` passed - enable domain with default rules.\nIf `Object` passed - create custom configuration:\n\n- __id__ (String) - provider ID (`youtube.com`)\n- __match__ ([RegExp]|RegExp) - patterns to match\n- __fetchers__ ([String|Function|Object]) - optional, array of fetchers dependency\n- __mixins__ ([String|Function]) - optional, array of mixins dependency\n- __mixinsAfter__ ([String|Function]) - optional, array of mixins after dependency\n- __config__ (Object) - additional config: autoplay parameter name, API key\n\n\n### .addFetcher(options)\n\nAdd add data fetcher. Options:\n\n- __id__ (String) - fetcher name.\n- __priority__ (Number) - optional, run priority, default - `0`.\n- __fn__ (Function) - fetcher handler, `async function (env)`.\n\n\n### .addMixin(options)\n\nAdd mixin (data handler). Options:\n\n- __id__ (String) - mixin name.\n- __fn__ (Function) - mixin handler, `async function (env)`.\n\n\n### .addMixinAfter(options)\n\nAdd post-processor \"after\" handler. The same as `.addMixin`, but handlers\nare axecuted after all mixins. Options:\n\n- __id__ (String) - post-processor name.\n- __fn__ (Function) - post-processor handler, `async function (env)`.\n\n\n## Advanced customization\n\n### .request()\n\nBy default it's a wrapper for [request](npmjs.com/packages/request). You can\noverride it. For example to force use cache only.\n\n\n### Templates\n\nManage available templates:\n\n```js\nconst _       = require('lodash');\nconst Embedza = require('embedza');\nconst embedza = new Embedza();\n\n// Customize templates\nembedza.templates['default_inline'] = _.template('...template code...', { variable: 'self' });\nembedza.templates['youtube.com_player'] = _.template('...template code...', { variable: 'self' });\n\n// Customize template aliases\nembedza.aliases.block = [ 'player', 'photo' ];\n```\n\n\nSimilar projects\n----------------\n\n- [iframely](https://github.com/itteco/iframely)\n- [onebox](https://github.com/discourse/onebox)\n\nEmbedza is inspired by projects above, but designed to satisfy our requirements.\nFor example, it supports inline output format.\n\n\nLicense\n-------\n\n[MIT](https://raw.github.com/nodeca/embedza/master/LICENSE)\n","funding_links":[],"categories":["Packages","JavaScript","包","目录","URL","Number"],"sub_categories":["URL"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnodeca%2Fembedza","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnodeca%2Fembedza","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnodeca%2Fembedza/lists"}