MyBB Community Forums

Full Version: [MyCode] Get your custom video in posts just posting its URL (automatic embed)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
'Basics' of auto-embed credits to SAFAD
threads: http://community.mybboard.net/thread-49050.html http://community.mybboard.net/thread-48781.html

1st: Number of chars in Video-ID
Pick a video url and see its relation with embed code... there must be an "ID Code" between both that will be the mycode key value (video-ID). You will need the number of chars from that code.

* example:
Dailymotion:

video URL:
http://www.dailymotion.com/relevance/search/pes+2010+e3/video/x9h0nm_pes-2010-e3-2k9_videogames

video Embed:
<div><object width="480" height="291"><param name="movie" value="http://www.dailymotion.com/swf/x9h0nm_pes-2010-e3-2k9_videogames&related=0"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><embed src="http://www.dailymotion.com/swf/x9h0nm_pes-2010-e3-2k9_videogames&related=0" type="application/x-shockwave-flash" width="480" height="291" allowFullScreen="true" allowScriptAccess="always"></embed></object><br /><b><a href="http://www.dailymotion.com/video/x9h0nm_pes-2010-e3-2k9_videogames">PES 2010 E3 2K9</a></b><br /><i>Enviado por <a href="http://www.dailymotion.com/CSL_Console">CSL_Console</a>. - <a href="http://www.dailymotion.com/br/channel/videogames">Veja reviews de games, trailers e seus melhores momentos jogando</a></i></div>

Key value (Video-ID): x9h0nm - 6 chars


2nd: Build the "Regular Expression" mycode with video url

Just paste video url in mycode replacement following SAFAD replacements
(example from auto-youtube)

(\[youtube\]|(<a href=\")?(http://)?(www.)?youtube.com/watch\?v=)(.{11}?)((.*?)\" target=\"_blank\">)?((.*?)\[/youtube\]|(.*?)</a>)

  1. Red = Basic site URL
  2. Green = Number os chars from youtube´s video ID > Example: http://www.youtube.com/watch?v=W4K_k_7Eroo



* Still studying dailymotion example:
http://www.dailymotion.com/relevance/search/pes+2010+e3/video/x9h0nm_pes-2010-e3-2k9_videogames
  1. Green = basic video URL


Regular Expression:
(\[dailymotion\]|(<a href=\")?(http://)?(www.)?dailymotion.com/(.*?)/vi....{6}?)((.*?)\" target=\"_blank\">)?((.*?)\[/dailymotion\]|(.*?)</a>)

{6} = number os characters from Video-ID Lightbulb


3rd: Build the "Replacement" mycode with Embed code

Just copy & paste EMBED Code from video and replace Video-ID with ${5} tag:

from:
Video example:

Quote:<div><object width="480" height="291"><param name="movie" value="http://www.dailymotion.com/swf/x9h0nm_pes-2010-e3-2k9_videogames&related=0"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><embed src="http://www.dailymotion.com/swf/x9h0nm_pes-2010-e3-2k9_videogames&related=0" type="application/x-shockwave-flash" width="480" height="291" allowFullScreen="true" allowScriptAccess="always"></embed></object><br /><b><a href="http://www.dailymotion.com/video/x9h0nm_pes-2010-e3-2k9_videogames">PES 2010 E3 2K9</a></b><br /><i>Enviado por <a href="http://www.dailymotion.com/CSL_Console">CSL_Console</a>. - <a href="http://www.dailymotion.com/br/channel/videogames">Ver mais videos de jogos</a></i></div>

  1. Red = useless code
  2. Blue = Video-ID



Replacement:
<object width="480" height="291"><param name="movie" value="http://www.dailymotion.com/swf/${6}&related=0"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><embed src="http://www.dailymotion.com/swf/${6}&related=0" type="application/x-shockwave-flash" width="480" height="291" allowFullScreen="true" allowScriptAccess="always"></embed></object>


it´s done...pretty simple Smile

"MyCode preview" won´t work, test directly in post preview pasting some Video urls - surelly will work
Interesting.. thanks for posting.
Testing...
You Have Stolen My Codes !
he is giving you the credits