From 14f29a59fa33494d339f5c56b9387af505d177a0 Mon Sep 17 00:00:00 2001 From: Oscar Otero Date: Mon, 6 Jul 2020 23:31:40 +0200 Subject: [PATCH] new version --- CHANGELOG.md | 6 +++ README.md | 12 +++--- src/ApiTrait.php | 7 +++- src/QueryResult.php | 7 +++- src/resources/oembed.php | 91 +++++++++++++++++++++++++++++++++------- 5 files changed, 100 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9563d48d..e6ef61f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [4.2.4] - 2020-07-06 +### Fixed +- Ignore invalid urls instead throw an exception +- Updated oembed list of endpoints + ## [4.2.3] - 2020-06-12 ### Fixed - Suppport for other non-latin alphabets such Persian or Arabic [#366] @@ -70,6 +75,7 @@ Full library refactoring. [#357]: https://github.com/oscarotero/Embed/issues/357 [#366]: https://github.com/oscarotero/Embed/issues/366 +[4.2.4]: https://github.com/oscarotero/Embed/compare/v4.2.3...v4.2.4 [4.2.3]: https://github.com/oscarotero/Embed/compare/v4.2.2...v4.2.3 [4.2.2]: https://github.com/oscarotero/Embed/compare/v4.2.1...v4.2.2 [4.2.1]: https://github.com/oscarotero/Embed/compare/v4.2.0...v4.2.1 diff --git a/README.md b/README.md index 67e15e5a..c3deb43c 100644 --- a/README.md +++ b/README.md @@ -9,19 +9,19 @@ [![Software License][ico-license]](LICENSE) [![SensioLabs Insight][ico-sensiolabs]][link-sensiolabs] -> Note: If you're using version 3, use [`v3.x` branch](https://github.com/oscarotero/Embed/tree/v3.x) - PHP library to get information from any web page (using oembed, opengraph, twitter-cards, scrapping the html, etc). It's compatible with any web service (youtube, vimeo, flickr, instagram, etc) and has adapters to some sites like (archive.org, github, facebook, etc). Requirements: * PHP 7.4+ * Curl library installed -* PSR-7 implementation. By default [these popular libraries](https://github.com/middlewares/awesome-psr15-middlewares#psr-7-implementations) are detected automatically +* PSR-17 implementation. By default these libraries are detected automatically: + * [laminas/laminas-diactoros](https://github.com/laminas/laminas-diactoros) + * [guzzle/psr7](https://github.com/guzzle/psr7) (Only the unreleased version 2.x, installed as `dev-master`) + * [nyholm/psr7](https://github.com/Nyholm/psr7) + * [sunrise/http-message](https://github.com/sunrise-php/http-message) -> * If you need PHP 5.3 support, use the 1.x version -> * If you need PHP 5.4 support, use the 2.x version -> * If you need PHP 5.5-7.3 support, [use the 3.x version](https://github.com/oscarotero/Embed/tree/v3.x) +> If you need PHP 5.5-7.3 support, [use the 3.x version](https://github.com/oscarotero/Embed/tree/v3.x) ## Online demo diff --git a/src/ApiTrait.php b/src/ApiTrait.php index c5425769..4409c888 100644 --- a/src/ApiTrait.php +++ b/src/ApiTrait.php @@ -5,6 +5,7 @@ use Datetime; use Psr\Http\Message\UriInterface; +use Throwable; trait ApiTrait { @@ -83,7 +84,11 @@ public function url(string ...$keys): ?UriInterface { $url = $this->str(...$keys); - return $url ? $this->extractor->resolveUri($url) : null; + try { + return $url ? $this->extractor->resolveUri($url) : null; + } catch (Throwable $error) { + return null; + } } public function time(string ...$keys): ?Datetime diff --git a/src/QueryResult.php b/src/QueryResult.php index 3fd75c0a..41212e83 100644 --- a/src/QueryResult.php +++ b/src/QueryResult.php @@ -7,6 +7,7 @@ use DOMElement; use DOMNodeList; use Psr\Http\Message\UriInterface; +use Throwable; class QueryResult { @@ -86,7 +87,11 @@ public function url(string $attribute = null): ?UriInterface return null; } - return $this->extractor->resolveUri($value); + try { + return $this->extractor->resolveUri($value); + } catch (Throwable $error) { + return null; + } } private static function getAttribute(DOMElement $node, string $name): ?string diff --git a/src/resources/oembed.php b/src/resources/oembed.php index c4244a0d..f8992810 100644 --- a/src/resources/oembed.php +++ b/src/resources/oembed.php @@ -15,8 +15,9 @@ '|^https?://alpha\\.app\\.net/.*/post/.*$|i', '|^https?://photos\\.app\\.net/.*/.*$|i', ], - 'https://api.altrulabs.com/social/oembed' => [ + 'https://api.altrulabs.com/api/v1/social/oembed' => [ '|^https?://app\\.altrulabs\\.com/.*/.*\\?answer_id\\=.*$|i', + '|^https?://app\\.altrulabs\\.com/player/.*$|i', ], 'https://live.amcharts.com/oembed' => [ '|^https?://live\\.amcharts\\.com/.*$|i', @@ -38,6 +39,7 @@ '|^https?://app\\.archivos\\.digital/app/view/.*$|i', ], 'https://audioboom.com/publishing/oembed/v4.json' => [ + '|^https?://audioboom\\.com/channels/.*$|i', '|^https?://audioboom\\.com/channel/.*$|i', '|^https?://audioboom\\.com/posts/.*$|i', ], @@ -45,10 +47,10 @@ '|^https?://audioclip\\.naver\\.com/channels/.*/clips/.*$|i', '|^https?://audioclip\\.naver\\.com/audiobooks/.*$|i', ], - 'https://www.audiomack.com/oembed' => [ - '|^https?://www\\.audiomack\\.com/song/.*$|i', - '|^https?://www\\.audiomack\\.com/album/.*$|i', - '|^https?://www\\.audiomack\\.com/playlist/.*$|i', + 'https://audiomack.com/oembed' => [ + '|^https?://audiomack\\.com/.*/song/.*$|i', + '|^https?://audiomack\\.com/.*/album/.*$|i', + '|^https?://audiomack\\.com/.*/playlist/.*$|i', ], 'http://audiosnaps.com/service/oembed' => [ '|^https?://audiosnaps\\.com/k/.*$|i', @@ -56,6 +58,9 @@ 'https://stage-embed.avocode.com/api/oembed' => [ '|^https?://app\\.avocode\\.com/view/.*$|i', ], + 'http://axiom.ninja/oembed/' => [ + '|^https?://axiom\\.ninja/.*$|i', + ], 'https://backtracks.fm/oembed' => [ '|^https?://backtracks\\.fm/.*/.*/e/.*$|i', '|^https?://backtracks\\.fm/.*/s/.*/.*$|i', @@ -113,6 +118,9 @@ '|^https?://clyp\\.it/.*$|i', '|^https?://clyp\\.it/playlist/.*$|i', ], + 'https://app.ilovecoco.video/api/oembed.json' => [ + '|^https?://app\\.ilovecoco\\.video/.*/embed$|i', + ], 'https://codehs.com/api/sharedprogram/*/oembed/' => [ '|^https?://codehs\\.com/editor/share_abacus/.*$|i', ], @@ -150,6 +158,9 @@ 'https://www.dailymotion.com/services/oembed' => [ '|^https?://www\\.dailymotion\\.com/video/.*$|i', ], + 'https://api.datawrapper.de/v3/oembed/' => [ + '|^https?://datawrapper\\.dwcdn\\.net/.*$|i', + ], 'https://embed.deseret.com/' => [ '|^https?://.*\\.deseret\\.com/.*$|i', ], @@ -176,6 +187,7 @@ 'https://www.docdroid.net/api/oembed' => [ '|^https?://.*\\.docdroid\\.net/.*$|i', '|^https?://docdro\\.id/.*$|i', + '|^https?://.*\\.docdroid\\.com/.*$|i', ], 'http://dotsub.com/services/oembed' => [ '|^https?://dotsub\\.com/view/.*$|i', @@ -198,6 +210,9 @@ 'http://embedarticles.com/oembed/' => [ '|^https?://embedarticles\\.com/.*$|i', ], + 'https://embedery.com/api/oembed' => [ + '|^https?://embedery\\.com/widget/.*$|i', + ], 'http://api.embed.ly/1/oembed' => [ '|^https?://api\\.embed\\.ly/.*$|i', ], @@ -311,6 +326,9 @@ '|^https?://hearthis\\.at/.*/.*/$|i', '|^https?://hearthis\\.at/.*/set/.*/$|i', ], + 'https://player.hihaho.com/services/oembed/*' => [ + '|^https?://player\\.hihaho\\.com/.*$|i', + ], 'https://homey.app/api/oembed/flow' => [ '|^https?://homey\\.app/f/.*$|i', '|^https?://homey\\.app/.*/flow/.*$|i', @@ -401,6 +419,9 @@ 'https://jdr.knacki.info/oembed' => [ '|^https?://jdr\\.knacki\\.info/meuh/.*$|i', ], + 'https://api.spoonacular.com/knowledge/oembed' => [ + '|^https?://knowledgepad\\.co/\\#/knowledge/.*$|i', + ], 'http://learningapps.org/oembed.php' => [ '|^https?://learningapps\\.org/.*$|i', ], @@ -450,6 +471,10 @@ 'https://api.microlink.io' => [ '|^https?://api\\.microlink\\.io.*$|i', ], + 'https://web.microsoftstream.com/oembed' => [ + '|^https?://.*\\.microsoftstream\\.com/video/.*$|i', + '|^https?://.*\\.microsoftstream\\.com/channel/.*$|i', + ], 'https://www.mixcloud.com/oembed/' => [ '|^https?://www\\.mixcloud\\.com/.*/.*/$|i', ], @@ -496,6 +521,15 @@ '|^https?://www\\.odds\\.com\\.au/.*$|i', '|^https?://odds\\.com\\.au/.*$|i', ], + 'https://song.link/oembed' => [ + '|^https?://song\\.link/.*$|i', + '|^https?://album\\.link/.*$|i', + '|^https?://artist\\.link/.*$|i', + '|^https?://playlist\\.link/.*$|i', + '|^https?://pods\\.link/.*$|i', + '|^https?://mylink\\.page/.*$|i', + '|^https?://odesli\\.co/.*$|i', + ], 'http://official.fm/services/oembed.json' => [ '|^https?://official\\.fm/tracks/.*$|i', '|^https?://official\\.fm/playlists/.*$|i', @@ -529,6 +563,9 @@ 'https://core.oz.com/oembed' => [ '|^https?://www\\.oz\\.com/.*/video/.*$|i', ], + 'https://padlet.com/oembed/' => [ + '|^https?://padlet\\.com/.*$|i', + ], 'https://www.pastery.net/oembed' => [ '|^https?://pastery\\.net/.*$|i', '|^https?://www\\.pastery\\.net/.*$|i', @@ -536,6 +573,9 @@ 'https://beta.pingvp.com.kpnis.nl/p/oembed.php' => [ '|^https?://www\\.pingvp\\.com/.*$|i', ], + 'https://tools.pinpoll.com/oembed' => [ + '|^https?://tools\\.pinpoll\\.com/.*$|i', + ], 'https://store.pixdor.com/oembed' => [ '|^https?://store\\.pixdor\\.com/place\\-marker\\-widget/.*/show$|i', '|^https?://store\\.pixdor\\.com/map/.*/show$|i', @@ -561,12 +601,21 @@ '|^https?://posixion\\.com/question/.*$|i', '|^https?://posixion\\.com/.*/question/.*$|i', ], + 'https://oembed.qualifio.com/' => [ + '|^https?://qualifio\\.com/.*$|i', + ], 'http://www.quiz.biz/api/oembed' => [ '|^https?://www\\.quiz\\.biz/quizz\\-.*\\.html$|i', ], 'http://www.quizz.biz/api/oembed' => [ '|^https?://www\\.quizz\\.biz/quizz\\-.*\\.html$|i', ], + 'https://oembed.radiopublic.com/oembed' => [ + '|^https?://play\\.radiopublic\\.com/.*$|i', + '|^https?://radiopublic\\.com/.*$|i', + '|^https?://www\\.radiopublic\\.com/.*$|i', + '|^https?://.*\\.radiopublic\\.com/.*\'$|i', + ], 'https://rapidengage.com/api/oembed' => [ '|^https?://rapidengage\\.com/s/.*$|i', ], @@ -600,6 +649,9 @@ 'https://rumble.com/api/Media/oembed.json' => [ '|^https?://rumble\\.com/.*$|i', ], + 'https://embed.runkit.com/oembed' => [ + '|^https?://embed\\.runkit\\.com/.*,$|i', + ], 'http://videos.sapo.pt/oembed' => [ '|^https?://videos\\.sapo\\.pt/.*$|i', ], @@ -664,9 +716,6 @@ '|^https?://www\\.socialexplorer\\.com/.*/edit$|i', '|^https?://www\\.socialexplorer\\.com/.*/embed$|i', ], - 'https://song.link/oembed' => [ - '|^https?://song\\.link/.*$|i', - ], 'https://soundcloud.com/oembed' => [ '|^https?://soundcloud\\.com/.*$|i', ], @@ -721,6 +770,10 @@ '|^https?://www\\.tickcounter\\.com/ticker/.*$|i', '|^https?://www\\.tickcounter\\.com/worldclock/.*$|i', ], + 'https://www.tiktok.com/oembed' => [ + '|^https?://www\\.tiktok\\.com/.*/video/.*$|i', + '|^https?://.*\\.tiktok\\.com/.*$|i', + ], 'https://widget.toornament.com/oembed' => [ '|^https?://www\\.toornament\\.com/tournaments/.*/information$|i', '|^https?://www\\.toornament\\.com/tournaments/.*/registration/$|i', @@ -802,12 +855,10 @@ '|^https?://vidl\\.it/.*$|i', ], 'https://app-v2.vidmizer.com/api/oembed' => [ - '|^https?://players\\.vidmizer\\.com/.*$|i', + '|^https?://players\\-cdn\\-v2\\.vidmizer\\.com/.*$|i', ], 'https://api.vidyard.com/dashboard/v1.1/oembed' => [ - '|^https?://embed\\.vidyard\\.com/.*$|i', - '|^https?://play\\.vidyard\\.com/.*$|i', - '|^https?://share\\.vidyard\\.com/.*$|i', + '|^https?://.*\\.vidyard\\.com/.*$|i', '|^https?://.*\\.hubs\\.vidyard\\.com/.*$|i', ], 'https://vimeo.com/api/oembed.json' => [ @@ -839,6 +890,10 @@ 'https://data.voxsnap.com/oembed' => [ '|^https?://article\\.voxsnap\\.com/.*/.*$|i', ], + 'https://embed.wave.video/oembed' => [ + '|^https?://watch\\.wave\\.video/.*$|i', + '|^https?://embed\\.wave\\.video/.*$|i', + ], 'http://play.wecandeo.com/oembed' => [ '|^https?://www\\.wecandeo\\.com/.*$|i', ], @@ -854,6 +909,9 @@ '|^https?://.*\\.wizer\\.me/learn/.*$|i', '|^https?://.*\\.wizer\\.me/preview/.*$|i', ], + 'https://wokwi.com/api/oembed' => [ + '|^https?://wokwi\\.com/share/.*$|i', + ], 'http://www.wootled.com/oembed' => [ '|^https?://www\\.wootled\\.com/.*$|i', ], @@ -877,6 +935,12 @@ '|^https?://youtu\\.be/.*$|i', '|^https?://.*\\.youtube\\.com/playlist\\?.*$|i', ], + 'https://app.zeplin.io/embed' => [ + '|^https?://app\\.zeplin\\.io/project/.*/screen/.*$|i', + '|^https?://app\\.zeplin\\.io/project/.*/screen/.*/version/.*$|i', + '|^https?://app\\.zeplin\\.io/project/.*/styleguide/components\\?coid\\=.*$|i', + '|^https?://app\\.zeplin\\.io/styleguide/.*/components\\?coid\\=.*$|i', + ], 'https://app.zingsoft.com/oembed' => [ '|^https?://app\\.zingsoft\\.com/embed/.*$|i', '|^https?://app\\.zingsoft\\.com/view/.*$|i', @@ -898,7 +962,4 @@ '|^https?://imgur\\.com/.*$|i', '|^https?://i\\.imgur\\.com/.*$|i', ], - 'https://www.tiktok.com/oembed' => [ - '|^https?://.*\\.tiktok\\.com/.*$|i', - ], ];