Giter VIP home page Giter VIP logo

Comments (3)

mpratt avatar mpratt commented on June 2, 2024

Hi DoyleCC,

Thanks for reporting but I cant replicate the issue. It seems to be working just fine for me:

$embera = new Embera\Embera();
print_r($embera->getUrlInfo('http://www.dailymotion.com/video/x2fm26p_magic-flip-book_tech http://www.dailymotion.com/video/xzva95_jacob-jones-and-the-bigfoot-mystery-launch-trailer_videogames'));

Array
(
    [http://www.dailymotion.com/video/x2fm26p_magic-flip-book_tech] => Array
        (
            [embera_using_fake] => 0
            [type] => video
            [version] => 1.0
            [provider_name] => Dailymotion
            [provider_url] => http://www.dailymotion.com
            [title] => Magic Flip Book
            [author_name] => Grand Illusions
            [author_url] => http://www.dailymotion.com/grand-illusions
            [width] => 480
            [height] => 269
            [html] => <iframe src="http://www.dailymotion.com/embed/video/x2fm26p" width="480" height="269" frameborder="0" allowfullscreen></iframe>
            [thumbnail_url] => http://s1.dmcdn.net/Is5bU/x240-n0j.jpg
            [thumbnail_width] => 427
            [thumbnail_height] => 240
        )

    [http://www.dailymotion.com/video/xzva95_jacob-jones-and-the-bigfoot-mystery-launch-trailer_videogames] => Array
        (
            [embera_using_fake] => 0
            [type] => video
            [version] => 1.0
            [provider_name] => Dailymotion
            [provider_url] => http://www.dailymotion.com
            [title] => Jacob Jones and the Bigfoot Mystery - Launch trailer
            [author_name] => TheVaultvideojuegos
            [author_url] => http://www.dailymotion.com/TheVaultvideojuegos
            [width] => 480
            [height] => 269
            [html] => <iframe src="http://www.dailymotion.com/embed/video/xzva95" width="480" height="269" frameborder="0" allowfullscreen></iframe>
            [thumbnail_url] => http://s1.dmcdn.net/BeIXa/x240-GcR.jpg
            [thumbnail_width] => 427
            [thumbnail_height] => 240
        )

)

or

$embera = new Embera\Embera();
echo $embera->autoEmbed('http://www.dailymotion.com/video/x2fm26p_magic-flip-book_tech http://www.dailymotion.com/video/xzva95_jacob-jones-and-the-bigfoot-mystery-launch-trailer_videogames');

<iframe src="http://www.dailymotion.com/embed/video/x2fm26p" width="480" height="269" frameborder="0" allowfullscreen></iframe> <iframe src="http://www.dailymotion.com/embed/video/xzva95" width="480" height="269" frameborder="0" allowfullscreen></iframe>

Can you give me an example of a url that's not working for you?

from embera.

DoyleCC avatar DoyleCC commented on June 2, 2024

Sorry, it was my mistake.
My site has also still Dailymotion videos embedded from years ago, so I have links with the old and the new url's.
When I updated to 1.8.5 I had forgotten that I changed the regex in earlier versions to embed the old url's too.

Sorry again for bothering you.

from embera.

mpratt avatar mpratt commented on June 2, 2024

No problem DoyleCC!

If I may, let me suggest another approach to your problem. Instead of overwriting the core class, just write a new Oembed provider.

You want to convert the older urls dailymotion.com/username/video/id to something like dailymotion.com/video/id_title

// Create a new class that extends the DailyMotion Provider
class CustomDailyMotion extends \Embera\Providers\DailyMotion
{
    /** inline {@inheritdoc} */
    protected function normalizeUrl()
    {
        parent::normalizeUrl();

        // Support for older dailymotion links
        if (preg_match('~dailymotion\.com/(?:[^/]+)/video/([^/]+)/?~i', $this->url, $matches)) {
            $this->url = new \Embera\Url('http://www.dailymotion.com/video/' . $matches['1']);
        }
    }
}

$embera = new Embera\Embera();

// Register the new class to 
$embera->addProvider('dailymotion.com', 'CustomDailyMotion');
$embera->addProvider('*.dailymotion.com', 'CustomDailyMotion');
print_r($embera->getUrlInfo(array(
    'http://www.dailymotion.com/video/x2fm26p_magic-flip-book_tech', 
     // Normal url
    'http://www.dailymotion.com/username/video/x2fm26p', 
     // will be converted to http://www.dailymotion.com/video/x2fm26p
    'http://www.dailymotion.com/other_user_name_old_links/video/x2fm26p_magic-flip-book_tech', 
     // will be converted to http://www.dailymotion.com/video/x2fm26p_magic-flip-book_tech
)));

By converting the links, you get a compatible url with the new format. Embera takes care of the rest.
You don't need to modify the core class, so you don't have to think about doing changes right after updating.

Note that I'm registering the CustomClass to dailymotion.com and to *.dailymotion.com. I did that because I visited the website again and found out that dailymotion has support for http://games.dailymotion.com and to live streaming.

I changed the DailyMotion class in order to support those changes and I'll be pushing an update this weekend.

Im closing this issue for now!

from embera.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.