Skip to content

Commit

Permalink
new version
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarotero committed Jul 6, 2020
1 parent ab291e4 commit 14f29a5
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 23 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 6 additions & 1 deletion src/ApiTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

use Datetime;
use Psr\Http\Message\UriInterface;
use Throwable;

trait ApiTrait
{
Expand Down Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion src/QueryResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use DOMElement;
use DOMNodeList;
use Psr\Http\Message\UriInterface;
use Throwable;

class QueryResult
{
Expand Down Expand Up @@ -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
Expand Down
91 changes: 76 additions & 15 deletions src/resources/oembed.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -38,24 +39,28 @@
'|^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',
],
'https://audioclip.naver.com/oembed' => [
'|^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',
],
'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',
Expand Down Expand Up @@ -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',
],
Expand Down Expand Up @@ -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',
],
Expand All @@ -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',
Expand All @@ -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',
],
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
],
Expand Down Expand Up @@ -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',
],
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -529,13 +563,19 @@
'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',
],
'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',
Expand All @@ -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',
],
Expand Down Expand Up @@ -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',
],
Expand Down Expand Up @@ -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',
],
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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' => [
Expand Down Expand Up @@ -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',
],
Expand All @@ -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',
],
Expand All @@ -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',
Expand All @@ -898,7 +962,4 @@
'|^https?://imgur\\.com/.*$|i',
'|^https?://i\\.imgur\\.com/.*$|i',
],
'https://www.tiktok.com/oembed' => [
'|^https?://.*\\.tiktok\\.com/.*$|i',
],
];

0 comments on commit 14f29a5

Please sign in to comment.