diff --git a/README.md b/README.md index bf78948..b3f4d64 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Extract oEmbed content from given URL. ## Demo - [Give it a try!](https://demos.pwshub.com/oembed-parser) -- [Example FaaS](https://extractor.pwshub.com/oembed/parse?url=https://www.youtube.com/watch?v=8jPQjjsBbIc&apikey=demo-orePhhidnWKWPvF8EYKap7z55cN) +- [Example FaaS](https://extractor.pwshub.com/oembed/parse?url=https://www.instagram.com/tv/CVlR5GFqF68/&apikey=demo-TEyRycuuMCiGBiBocbLGSpagfj7gOF8AMyAWfEgP) ## Setup @@ -169,7 +169,7 @@ Default option: ```js { headers: { - 'user-agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:95.0) Gecko/20100101 Firefox/95.0', + 'user-agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Firefox/102.0', accept: 'application/json; charset=utf-8' }, responseType: 'json', @@ -182,20 +182,18 @@ Default option: ## Facebook and Instagram -Since October 24 2020, Facebook have deprecated their legacy urls and applied a new Facebook oEmbed endpoints. +In order to work with the links from Facebook and Instagram, you need a [reviewed Facebook's app](https://developers.facebook.com/docs/app-review) with [oEmbed Read](https://developers.facebook.com/docs/features-reference/oembed-read) permission. -Technically, now we have to use Facebook Graph API, with the access token from a valid and live Facebook app. `oembed-parser` will try to get these values from environment variables, so please define them, for example: +When seeing a link from Facebook or Instagram, `oembed-parser` will look for environment variables `FACEBOOK_APP_ID` and `FACEBOOK_CLIENT_TOKEN` to retrieve oembed data using your app credentials. + +For example: ```bash export FACEBOOK_APP_ID=your_app_id export FACEBOOK_CLIENT_TOKEN=your_client_token -``` -References: - -- [oEmbed Read](https://developers.facebook.com/docs/features-reference/oembed-read) -- [Facebook oEmbed](https://developers.facebook.com/docs/plugins/oembed) -- [Facebook Graph API](https://developers.facebook.com/docs/graph-api/overview) +npm run eval https://www.instagram.com/tv/CVlR5GFqF68/ +``` ## Test diff --git a/dist/cjs/oembed-parser.js b/dist/cjs/oembed-parser.js index 1144b33..e16a915 100644 --- a/dist/cjs/oembed-parser.js +++ b/dist/cjs/oembed-parser.js @@ -1,5 +1,5 @@ "use strict"; -// oembed-parser@3.0.5, by @ndaidong - built with esbuild at 2022-06-23T07:21:16.535Z - published under MIT license +// oembed-parser@3.0.6, by @ndaidong - built with esbuild at 2022-07-04T04:41:14.012Z - published under MIT license var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; @@ -12600,7 +12600,7 @@ var import_axios = __toESM(require_axios2(), 1); var import_bellajs = __toESM(require_bella(), 1); var requestOptions = { headers: { - "user-agent": "Mozilla/5.0 (X11; Linux i686; rv:100.0) Gecko/20100101 Firefox/100.0", + "user-agent": "Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Firefox/102.0", accept: "application/json; charset=utf-8" }, responseType: "json", @@ -13143,6 +13143,20 @@ var providers = [ } ] }, + { + "provider_name": "Cardinal Blue", + "provider_url": "https://minesweeper.today/", + "endpoints": [ + { + "schemes": [ + "http://minesweeper.today/*", + "https://minesweeper.today/*" + ], + "url": "https://minesweeper.today/api/oembed", + "discovery": true + } + ] + }, { "provider_name": "Catapult", "provider_url": "https://www.catapult.app/", @@ -14162,6 +14176,21 @@ var providers = [ } ] }, + { + "provider_name": "Heyzine", + "provider_url": "https://heyzine.com", + "endpoints": [ + { + "schemes": [ + "https://heyzine.com/flip-book/*", + "https://*.hflip.co/*", + "https://*.aflip.in/*" + ], + "url": "https://heyzine.com/api1/oembed", + "discovery": true + } + ] + }, { "provider_name": "hihaho", "provider_url": "https://www.hihaho.com", @@ -14283,6 +14312,23 @@ var providers = [ } ] }, + { + "provider_name": "iMenuPro", + "provider_url": "https://imenupro.com", + "endpoints": [ + { + "schemes": [ + "http://qr.imenupro.com/*", + "https://qr.imenupro.com/*" + ], + "url": "https://qr.imenupro.com/api/oembed", + "formats": [ + "json" + ], + "discovery": true + } + ] + }, { "provider_name": "Incredible", "provider_url": "https://incredible.dev", @@ -14643,6 +14689,18 @@ var providers = [ } ] }, + { + "provider_name": "Line Place", + "provider_url": "https://place.line.me", + "endpoints": [ + { + "schemes": [ + "https://place.line.me/businesses/*" + ], + "url": "https://place.line.me/oembed" + } + ] + }, { "provider_name": "Livestream", "provider_url": "https://livestream.com/", @@ -15218,6 +15276,20 @@ var providers = [ } ] }, + { + "provider_name": "Picturelfy", + "provider_url": "https://www.picturelfy.com/", + "endpoints": [ + { + "schemes": [ + "http://www.picturelfy.com/p/*", + "https://www.picturelfy.com/p/*" + ], + "url": "https://api.picturelfy.com/service/oembed/", + "discovery": false + } + ] + }, { "provider_name": "PingVP", "provider_url": "https://www.pingvp.com/", @@ -15289,6 +15361,24 @@ var providers = [ } ] }, + { + "provider_name": "Plusdocs", + "provider_url": "http://plusdocs.com", + "endpoints": [ + { + "schemes": [ + "https://app.plusdocs.com/*/snapshots/*", + "https://app.plusdocs.com/*/pages/edit/*", + "https://app.plusdocs.com/*/pages/share/*" + ], + "url": "https://app.plusdocs.com/oembed", + "discovery": true, + "formats": [ + "json" + ] + } + ] + }, { "provider_name": "Podbean", "provider_url": "http://podbean.com", @@ -15752,6 +15842,19 @@ var providers = [ } ] }, + { + "provider_name": "Slate App", + "provider_url": "https://slateapp.com", + "endpoints": [ + { + "schemes": [ + "https://*.slateapp.com/work/*" + ], + "url": "https://*.slateapp.com/api/v2/oembed", + "discovery": true + } + ] + }, { "provider_name": "SlideShare", "provider_url": "http://www.slideshare.net/", diff --git a/dist/cjs/package.json b/dist/cjs/package.json index 0b2fd3f..a0e710f 100644 --- a/dist/cjs/package.json +++ b/dist/cjs/package.json @@ -1,5 +1,5 @@ { "name": "oembed-parser-cjs", - "version": "3.0.5", + "version": "3.0.6", "main": "./oembed-parser.js" } \ No newline at end of file diff --git a/dist/cjs/providers.latest.js b/dist/cjs/providers.latest.js index e399141..2e3ac07 100644 --- a/dist/cjs/providers.latest.js +++ b/dist/cjs/providers.latest.js @@ -1,4 +1,4 @@ -// provider data, synchronized at 2022-05-23T15:07:41.370Z +// provider data, synchronized at 2022-07-04T04:38:20.547Z /* eslint-disable */ @@ -445,6 +445,20 @@ export const providers = [ } ] }, + { + "provider_name": "Cardinal Blue", + "provider_url": "https://minesweeper.today/", + "endpoints": [ + { + "schemes": [ + "http://minesweeper.today/*", + "https://minesweeper.today/*" + ], + "url": "https://minesweeper.today/api/oembed", + "discovery": true + } + ] + }, { "provider_name": "Catapult", "provider_url": "https://www.catapult.app/", @@ -1464,6 +1478,21 @@ export const providers = [ } ] }, + { + "provider_name": "Heyzine", + "provider_url": "https://heyzine.com", + "endpoints": [ + { + "schemes": [ + "https://heyzine.com/flip-book/*", + "https://*.hflip.co/*", + "https://*.aflip.in/*" + ], + "url": "https://heyzine.com/api1/oembed", + "discovery": true + } + ] + }, { "provider_name": "hihaho", "provider_url": "https://www.hihaho.com", @@ -1585,6 +1614,23 @@ export const providers = [ } ] }, + { + "provider_name": "iMenuPro", + "provider_url": "https://imenupro.com", + "endpoints": [ + { + "schemes": [ + "http://qr.imenupro.com/*", + "https://qr.imenupro.com/*" + ], + "url": "https://qr.imenupro.com/api/oembed", + "formats": [ + "json" + ], + "discovery": true + } + ] + }, { "provider_name": "Incredible", "provider_url": "https://incredible.dev", @@ -1945,6 +1991,18 @@ export const providers = [ } ] }, + { + "provider_name": "Line Place", + "provider_url": "https://place.line.me", + "endpoints": [ + { + "schemes": [ + "https://place.line.me/businesses/*" + ], + "url": "https://place.line.me/oembed" + } + ] + }, { "provider_name": "Livestream", "provider_url": "https://livestream.com/", @@ -2520,6 +2578,20 @@ export const providers = [ } ] }, + { + "provider_name": "Picturelfy", + "provider_url": "https://www.picturelfy.com/", + "endpoints": [ + { + "schemes": [ + "http://www.picturelfy.com/p/*", + "https://www.picturelfy.com/p/*" + ], + "url": "https://api.picturelfy.com/service/oembed/", + "discovery": false + } + ] + }, { "provider_name": "PingVP", "provider_url": "https://www.pingvp.com/", @@ -2591,6 +2663,24 @@ export const providers = [ } ] }, + { + "provider_name": "Plusdocs", + "provider_url": "http://plusdocs.com", + "endpoints": [ + { + "schemes": [ + "https://app.plusdocs.com/*/snapshots/*", + "https://app.plusdocs.com/*/pages/edit/*", + "https://app.plusdocs.com/*/pages/share/*" + ], + "url": "https://app.plusdocs.com/oembed", + "discovery": true, + "formats": [ + "json" + ] + } + ] + }, { "provider_name": "Podbean", "provider_url": "http://podbean.com", @@ -3054,6 +3144,19 @@ export const providers = [ } ] }, + { + "provider_name": "Slate App", + "provider_url": "https://slateapp.com", + "endpoints": [ + { + "schemes": [ + "https://*.slateapp.com/work/*" + ], + "url": "https://*.slateapp.com/api/v2/oembed", + "discovery": true + } + ] + }, { "provider_name": "SlideShare", "provider_url": "http://www.slideshare.net/", diff --git a/package.json b/package.json index 9e5be02..88084d7 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "version": "3.0.5", + "version": "3.0.6", "name": "oembed-parser", "description": "Get oEmbed data from given URL.", "homepage": "https://www.npmjs.com/package/oembed-parser", @@ -38,9 +38,9 @@ ] }, "devDependencies": { - "esbuild": "^0.14.47", - "jest": "^28.1.1", - "nock": "^13.2.7" + "esbuild": "^0.14.48", + "jest": "^28.1.2", + "nock": "^13.2.8" }, "keywords": [ "oembed", diff --git a/src/config.js b/src/config.js index bae272a..065bd77 100644 --- a/src/config.js +++ b/src/config.js @@ -4,7 +4,7 @@ import { clone, copies } from 'bellajs' const requestOptions = { headers: { - 'user-agent': 'Mozilla/5.0 (X11; Linux i686; rv:100.0) Gecko/20100101 Firefox/100.0', + 'user-agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Firefox/102.0', accept: 'application/json; charset=utf-8' }, responseType: 'json', diff --git a/src/main.test.js b/src/main.test.js index 280c506..f075e40 100644 --- a/src/main.test.js +++ b/src/main.test.js @@ -269,7 +269,7 @@ test('Testing setRequestOptions()', () => { const actual = getRequestOptions() const expectedHeader = { authorization: 'bearer ', - 'user-agent': 'Mozilla/5.0 (X11; Linux i686; rv:100.0) Gecko/20100101 Firefox/100.0', + 'user-agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Firefox/102.0', accept: 'application/json; charset=utf-8' } diff --git a/src/utils/providers.latest.js b/src/utils/providers.latest.js index e399141..2e3ac07 100644 --- a/src/utils/providers.latest.js +++ b/src/utils/providers.latest.js @@ -1,4 +1,4 @@ -// provider data, synchronized at 2022-05-23T15:07:41.370Z +// provider data, synchronized at 2022-07-04T04:38:20.547Z /* eslint-disable */ @@ -445,6 +445,20 @@ export const providers = [ } ] }, + { + "provider_name": "Cardinal Blue", + "provider_url": "https://minesweeper.today/", + "endpoints": [ + { + "schemes": [ + "http://minesweeper.today/*", + "https://minesweeper.today/*" + ], + "url": "https://minesweeper.today/api/oembed", + "discovery": true + } + ] + }, { "provider_name": "Catapult", "provider_url": "https://www.catapult.app/", @@ -1464,6 +1478,21 @@ export const providers = [ } ] }, + { + "provider_name": "Heyzine", + "provider_url": "https://heyzine.com", + "endpoints": [ + { + "schemes": [ + "https://heyzine.com/flip-book/*", + "https://*.hflip.co/*", + "https://*.aflip.in/*" + ], + "url": "https://heyzine.com/api1/oembed", + "discovery": true + } + ] + }, { "provider_name": "hihaho", "provider_url": "https://www.hihaho.com", @@ -1585,6 +1614,23 @@ export const providers = [ } ] }, + { + "provider_name": "iMenuPro", + "provider_url": "https://imenupro.com", + "endpoints": [ + { + "schemes": [ + "http://qr.imenupro.com/*", + "https://qr.imenupro.com/*" + ], + "url": "https://qr.imenupro.com/api/oembed", + "formats": [ + "json" + ], + "discovery": true + } + ] + }, { "provider_name": "Incredible", "provider_url": "https://incredible.dev", @@ -1945,6 +1991,18 @@ export const providers = [ } ] }, + { + "provider_name": "Line Place", + "provider_url": "https://place.line.me", + "endpoints": [ + { + "schemes": [ + "https://place.line.me/businesses/*" + ], + "url": "https://place.line.me/oembed" + } + ] + }, { "provider_name": "Livestream", "provider_url": "https://livestream.com/", @@ -2520,6 +2578,20 @@ export const providers = [ } ] }, + { + "provider_name": "Picturelfy", + "provider_url": "https://www.picturelfy.com/", + "endpoints": [ + { + "schemes": [ + "http://www.picturelfy.com/p/*", + "https://www.picturelfy.com/p/*" + ], + "url": "https://api.picturelfy.com/service/oembed/", + "discovery": false + } + ] + }, { "provider_name": "PingVP", "provider_url": "https://www.pingvp.com/", @@ -2591,6 +2663,24 @@ export const providers = [ } ] }, + { + "provider_name": "Plusdocs", + "provider_url": "http://plusdocs.com", + "endpoints": [ + { + "schemes": [ + "https://app.plusdocs.com/*/snapshots/*", + "https://app.plusdocs.com/*/pages/edit/*", + "https://app.plusdocs.com/*/pages/share/*" + ], + "url": "https://app.plusdocs.com/oembed", + "discovery": true, + "formats": [ + "json" + ] + } + ] + }, { "provider_name": "Podbean", "provider_url": "http://podbean.com", @@ -3054,6 +3144,19 @@ export const providers = [ } ] }, + { + "provider_name": "Slate App", + "provider_url": "https://slateapp.com", + "endpoints": [ + { + "schemes": [ + "https://*.slateapp.com/work/*" + ], + "url": "https://*.slateapp.com/api/v2/oembed", + "discovery": true + } + ] + }, { "provider_name": "SlideShare", "provider_url": "http://www.slideshare.net/", diff --git a/src/utils/providers.prev.js b/src/utils/providers.prev.js index 77cb90d..e399141 100644 --- a/src/utils/providers.prev.js +++ b/src/utils/providers.prev.js @@ -1,4 +1,4 @@ -// provider data, synchronized at 2022-05-23T08:52:22.296Z +// provider data, synchronized at 2022-05-23T15:07:41.370Z /* eslint-disable */