Comments (3)
Hi @tomaszkane !
You are right, Embera doesnt return the video_id, but that is because youtube does not do it either. Check this request for example https://www.youtube.com/oembed?url=https://www.youtube.com/watch?v=J---aiyznGQ&format=json
However you can use filters and fetch the video_id and return it in the response if you really need it.
$embera = new Embera(...........);
$embera->addFilter(function ($response) {
if (strtolower($response['embera_provider_name']) == 'youtube' && preg_match('~/embed/(.+)\?feature=oembed~', $response['html'], $matches)) {
$response['video_id'] = $matches['1'];
}
return $response;
});
var_dump($embera->getUrlData('https://www.youtube.com/watch?v=J---aiyznGQ'));
Something like that should work.
The code is untested but you get the idea...
Let me know if that helps..
from embera.
Hi,
yes I know, YT don't return video_id
. But why Embera not adding this information to (new Embera())->getUrlData($videoUrl);
by own / automatically? ID always must be present in given URI, so add it to results from getUrlData()
?
BTW, thanks for simpler solution for get this is (filter instead of long regexp).
from embera.
Hi @tomaszkane !
I am glad the filter option worked for you!
In regards to adding the video_id into the Embera response for Youtube, I dont think I will add it. I want to respect the endpoint response as much as possible, only on a few providers I modify the html response, but I mostly want to leave the response as close as possible to the original.
Perhaps if many users ask for this functionality to be added, I'll consider doing it, but for now, I think with filters you have the option to get the info you need for your usecase. Filters are very versatile since it allows access to the raw response.
from embera.
Related Issues (20)
- Animoto using a s3.amazonaws.com url. HOT 1
- Embedding playbuzz items HOT 1
- The New YouTube Desktop Design is not Supported. HOT 1
- Allow hidden vi HOT 1
- Silk defunct HOT 1
- Playbuzz implementation is incomplete HOT 1
- youtube rel=0 ? HOT 1
- How about dropping support php version prior to 7.2? HOT 3
- Allowing CKEditor5 code HOT 3
- Argument 2 passed to Embera\Http\OembedClient::__construct() must be an instance of Embera\Http\HttpClient, instance of Embera\Http\HttpClientCache given HOT 3
- Added Wordwall provider HOT 3
- Defer loading iframes and remove obsolete iframe's tags HOT 1
- Custom Provider Parameters HOT 6
- Broken/Unsupported Providers HOT 3
- Facebook is problematic HOT 4
- Instagram oEmbed is deprecated HOT 1
- Support custom request headers HOT 2
- Vimeo private video links HOT 1
- Imgur not embedded? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from embera.