• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
  • This forum has been archived. New threads and replies may not be made. All add-ons/resources that are active should be migrated to the Resource Manager. See this thread for more information.

[Add More Video Sites] BB Code Media

EQnoble

Well-known member
Can someone help me with BBCode for this http://veevr.com/
Media Site ID: veevr
________________________________________
Site Title: Veevr.com
________________________________________
Site URL: http://veevr.com/
________________________________________
Match URLs: #veevr\.com/videos/(?P<id>[a-z0-9]+)#si
________________________________________
Embed HTML:
HTML:
<iframe src='http://veevr.com/embed/{$id}' width='640' height='360' scrolling='no' frameborder='0'></iframe>
________________________________________

____advanced options___________________________
Regular Expression Matching: Use 'Match URLs' as PCRE regular expressions [ Checked ]
________________________________________
 

EQnoble

Well-known member
Not stupid...more like....in a hurry and excited to see if the code is going to work when you push save...I have said before...I forget how old I am...but stupid is a broad word my friend:)

-> mma-tube

Yeah I'll try that one...but I gotta check out the new Resource Manager right now that just went up http://xenforo.com/community/resources/ :) Sweet!!!!
 

Jake Bunce

XenForo moderator
Staff member
I made a ******* code a while ago, but I only posted it via PM because it's porn. But I got permission to post it here as long as I don't post the URLs I used (no porn links allowed):

Here are instructions for *******.

Admin CP -> Home -> BB Code Media Sites -> Add BB Code Media Site

Media Site ID: *******

Site Title: *******

Site URL: http://www.*******.com/

Match URLs: http://www.*******.com/view_video.php?viewkey={$id}

Embed HTML:

Code:
<see html callback>
Then under Advanced Options:

Embed HTML Callback: MediaSites_*******::buildEmbed

And you need to create the following directory/file:

library/MediaSites/*******.php

Code:
<?php

class MediaSites_*******
{
	public static function buildEmbed($mediaKey, array $site)
	{
		// CAPTURE WEB PAGE
		$pageHtml = file_get_contents('http://www.*******.com/view_video.php?viewkey=' . $mediaKey);

		// ISOLATE THE EMBED CODE IN THE SOURCE
		if(preg_match('/[^\w]<textarea onclick="this\.select\(\)" class="share-flag-embed">(?P<embedhtml>[^<]+)<\/textarea>/siU', $pageHtml, $match))
		{
			// IT HAS HTML ENTITIES, UNDO THAT
			$match['embedhtml'] = htmlspecialchars_decode($match['embedhtml']);

			// FROM EMBED CODE, ISOLATE THE ID
			if(preg_match('#<param name="FlashVars" value="options=http://www\.*******\.com/embed_player\.php\?id=(?P<videoid>[^"]+)"/>#si', $match['embedhtml'], $info))
			{
				// DEFINE GENERIC EMBED HTML WITH REPLACEMENT VARIABLE __MEDIAKEY__
				$embedHtml = '<object type="application/x-shockwave-flash" data="http://cdn1.static.*******.phncdn.com/flash/embed_player.swf" width="608" height="476">
<param name="movie" value="http://cdn1.static.*******.phncdn.com/flash/embed_player.swf" />
<param name="bgColor" value="#000000" />
<param name="allowfullscreen" value="true" />
<param name="allowScriptAccess" value="always" />
<param name="FlashVars" value="options=http://www.*******.com/embed_player.php?id=__VIDEOID__"/>
</object>';

				// MAKE THE REPLACEMENTS
				$finalHtml = str_replace('__VIDEOID__', $info['videoid'], $embedHtml);

				// RETURN THE FINISHED HTML
				return $finalHtml;
			}
		}

		// RETURN NOTHING IF NO MATCH
		return '';
	}
}
URLs tested:
<omitted>
 

Attachments

Rudy

Well-known member
CBS News does not appear to work correctly.

This URL works fine directly:

http://www.cbsnews.com/video/watch/?id=7396768n

But if I embed it, I seem to get a generic "breaking news" video that is not even related.

Here is the "share" URL for the video directly from the CBS site:
Code:
http://www.cbsnews.com/video/watch/?id=7396768n
And, here is the "embed" URL they give if I share the video directly from their site:
HTML:
<embed src="http://cnettv.cnet.com/av/video/cbsnews/atlantis2/cbsnews_player_embed.swf" scale="noscale" salign="lt" type="application/x-shockwave-flash" background="#333333" width="425" height="279" allowFullScreen="true" allowScriptAccess="always" FlashVars="si=254&&contentValue=50119107&shareUrl=http://www.cbsnews.com/video/watch/?id=7396768n" />
This is the embedding I get when I "view source" in the browser; note that the value for contentValue is missing:
HTML:
<embed src="http://cnettv.cnet.com/av/video/cbsnews/atlantis2/cbsnews_player_embed.swf" scale="noscale" salign="lt" type="application/x-shockwave-flash" background="#333333" width="425" height="279" allowFullScreen="true" allowScriptAccess="always" FlashVars="si=254&&contentValue=&shareUrl=http://www.cbsnews.com/video/watch/?id=7396768n" />
 

Rudy

Well-known member
CBS News does not appear to work correctly.
Found the problem already...

CBSNews.php

Line 11

Bad:
PHP:
        if(preg_match('#CBSVideo\.setVideoId\(\"?(?P<vidid>[0-9]+)"?\)#si', $pageHtml, $match))
Good:
PHP:
        if(preg_match('#CBSVideo\.setVideoId\(\"?(?P<videoid>[0-9]+)"?\)#si', $pageHtml, $match))
<vidid> was incorrect. Changing to <videoid> was the ticket.
 

Rudy

Well-known member
One other bug I'm noticing: I installed the add-on pack by EQnoble that compiles a lot of these. What I notice now is that when popping open an editor window, or even if an error window pops open, the embedded item (in this case, a CBS News video and an eBay widget) are overlaying the popup window. IOW, I don't know if the z-index of the embedded media is overriding that of the windows (these use Flash, IIRC), or if it just blindly ignores CSS. But it is a usability problem if you can't click on the controls in the editor window, for example.
 

EQnoble

Well-known member
could you point out which ones as you see them? I believe it is just a matter of changing or adding wmode on each of the conflicting ones.


I will also add the change to cbsnews that you pointed out.
 

Rudy

Well-known member
So far, it's on the CBS News and eBay. Easy way to check: embed the video. Then, go back and edit the post--the embedded item ends up being on top rather than the editor.

Where would you add the "wmode"? I'm not that familiar with the code yet.

I can spot check a few before I call it a night. Back shortly...
 

EQnoble

Well-known member
Yeah if you can double check some that would be awesome, there is a lot of sites and after I went through and fixed all the broken ones (missed the typo in cbsnews so thanks for that...I didn't even know it was broken lol) I intended to fix the wmode stuff but totally forgot honestly. I was just zombied out after a couple of hours of mediasite tinkering I guess.
 

Rudy

Well-known member
I was just zombied out after a couple of hours of mediasite tinkering I guess.
I agree--it is a mountain of code to go through. I've fried my own grey matter over the years when I've worked on projects with deadlines--it gets so you're fixing all sorts of code, but overlook small (aka stupid :D ) mistakes that bring the whole application down. (Such as, nested IF statements in PHP that aren't closed properly...or a missing semicolon...)

No worries! I'll test some of them out either tonight or tomorrow. I know we won't use many of these (they are quite obscure for the types of sites we run), but I can try some tomorrow to see what happens.
 

EQnoble

Well-known member
Actually I am finding this to be faster than I thought for this small problem (the moderation tools overlay problem), I may have this done within the hour.

bout halfway done now...