• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Embeding video from site w/o embed code - opinion of doing it & tech help

Mutt

Well-known member
#1
for the adult media embed bbcode addon I posted I was asked to add the site http://efukt.com which does not provide a embed code. I looked at ways to get it to work & could not get their flash player to embed on my end. eventually I just grabbed the URL to the .flv file and used flowplayer to display it on my end. it works perfectly fine adn the result looks like this.
Screenshot_2.png

first, what's your opinion on doing this? video embedding is the norm these days & if the site provides an embed code, I think nothing of it but w/ a site like this one who does not provide an embed code it seems like straight up bandwidth theft. is it improper neticate? (to try and be fair I included a link to the site under the vid)

second, I found 1 URL that did not work & I believe it's because there is a ? in the URL.
http://efukt.com/20974_u_mad?_YOU_MAD.html
I get the following error when trying to post it
Screenshot_4.png


can anyone suggest a way to fix this? attached are my Media BBCode settings. I assume I'm going to have to change the match url to a regular expression.

I uploaded flowplayer-3.2.7.swf & flowplayer-3.2.6.min.js from flowplayer to /xen dir/js/flowplayer/

and I uploaded the file efukt.php to /xen dir/library/MediaSites/
Code:
<?php
 
class MediaSites_efukt
{
    public static function buildEmbed($mediaKey, array $site)
    {
        // CAPTURE WEB PAGE
        $url = 'http://efukt.com/' . $mediaKey . '.html';
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_USERAGENT, 'Firefox (WindowsXP) - Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6');
        curl_setopt($ch, CURLOPT_URL,$url);
        curl_setopt($ch, CURLOPT_FAILONERROR, true);
        curl_setopt($ch, CURLOPT_AUTOREFERER, true);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
        curl_setopt($ch, CURLOPT_TIMEOUT, 30);
        $pageHtml = curl_exec($ch);
                           
        // ISOLATE THE VIDEOID IN THE SOURCE
        if(preg_match('/flashvars.file = \"(.+?)\"\;/s', $pageHtml, $match))
        {
            // DEFINE GENERIC EMBED HTML WITH REPLACEMENT VARIABLES __VIDEOID__ AND __MEDIAKEY__
            $embedHtml = '<script type="text/javascript" src="./js/flowplayer/flowplayer-3.2.6.min.js"></script>
<div align="center"><a href="__VIDEOID__" style="display:block;width:520px;height:330px" id="player"></a>
<script>flowplayer("player", "./js/flowplayer/flowplayer-3.2.7.swf", { clip: { autoPlay: false, autoBuffering: true } });</script>
<font size="1"><a href="' .$url. '" target="_blank">' . $url . '</a></font></div>';
   
            // MAKE THE REPLACEMENTS
            $finalHtml = str_replace('__VIDEOID__', $match[1], $embedHtml);
 
            // RETURN THE FINISHED HTML
            return $finalHtml;
        } else {
            $finalHtml = 'Could Not find VideoID for <a href="' .$url. '" target="_blank">' . $url . '</a>';
            return $finalHtml;
        }
 
        // RETURN NOTHING IF NO MATCH
        return '';
    }
}
 

Attachments

Mutt

Well-known member
#4
i found another one that wouldn't work. this one had a ' in the url. i'm going to try adding an unhtml command
 

Mutt

Well-known member
#5
ok I changed the the .php file. this fixed my issues w/ some URLs, the autoplay issue, & the multiple vids on 1 page issue.

looks like my only problem left is is the URL w/ the ? in it. still getting the error when trying to submit the url. still no clue how to address that

Code:
<?php
 
class MediaSites_efukt
{
    public static function buildEmbed($mediaKey, array $site)
    {
        // CAPTURE WEB PAGE
        $mediaKey = urldecode($mediaKey);
        $url = 'http://efukt.com/' . $mediaKey . '.html';
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_USERAGENT, 'Firefox (WindowsXP) - Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6');
        curl_setopt($ch, CURLOPT_URL,$url);
        curl_setopt($ch, CURLOPT_FAILONERROR, true);
        curl_setopt($ch, CURLOPT_AUTOREFERER, true);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
        curl_setopt($ch, CURLOPT_TIMEOUT, 30);
        $pageHtml = curl_exec($ch);
                                 
        // ISOLATE THE VIDEOID IN THE SOURCE
        if(preg_match('/flashvars.file = \"(.+?)\";/s', $pageHtml, $match))
        {
            // DEFINE GENERIC EMBED HTML WITH REPLACEMENT VARIABLES __VIDEOID__ AND __MEDIAKEY__
$embedHtml = '<div align="center"><object id="flowplayer" width="520" height="330" data="./js/flowplayer/flowplayer-3.2.7.swf" type="application/x-shockwave-flash">
<param name="movie" value="./js/flowplayer/flowplayer-3.2.7.swf" />
<param name="allowfullscreen" value="true" />
<param name="flashvars" value=\'config={"clip":{"url":"__VIDEOID__","autoPlay":false}}\' />
</object>
<br><font size="1"><a href="' . $url . '" target="_blank">' . $url . '</a></font></div>';
         
            // MAKE THE REPLACEMENTS
            $finalHtml = str_replace('__VIDEOID__', $match[1], $embedHtml);
 
            // RETURN THE FINISHED HTML
            return $finalHtml;
        } else {
            $finalHtml = 'Could Not find VideoID for <a href="' .$url. '" target="_blank">' . $url . '</a>';
            return $finalHtml;
        }
 
        // RETURN NOTHING IF NO MATCH
        return '';
    }
}
 

Jake Bunce

XenForo moderator
Staff member
#6
first, what's your opinion on doing this? video embedding is the norm these days & if the site provides an embed code, I think nothing of it but w/ a site like this one who does not provide an embed code it seems like straight up bandwidth theft. is it improper neticate? (to try and be fair I included a link to the site under the vid)
That's debatable. What I don't like about embeds like this is that you are scraping the web page on every page load. It's just a yucky thing to do. It consumes lots of memory and bandwidth. Unless you use a URL Match Callback to get the ID in which case you are only scraping one time, but admins and users tend not to like that because the BB code in the post contains nothing from the URL so you rely entirely on the editor to give you the correct ID after you paste the URL.