Video Embed Swap/SQL Query help

brentdev

shamwow aficionado
Nov 24, 2008
475
23
0
www.quietaffiliate.com
Ok, so after way too long spent trying to accomplish this on a localized version of the blog i'm bringing my question to you in shame.

So the video hosting company i've been using for 3 years sold out to another which promptly decided to change all the embed codes. The video ID's are still the same but I now have to change 300+ posts that may or may not have the old embed code to now use the updated code (otherwise the video's are dead).
What SQL command would go through all the post content fields in a table and change any example of the old code:

Code:
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" width="416" height="234" id="mbox_player_7c99dfb41b1fe6c7f4"><param name="movie" value="http://www.motionbox.com/external/hd_player/type%253Dsd%252Caffiliate_name%253Dpro%252Cvideo_uid%253D7c99dfb41b1fe6c7f4" /><param name="allowScriptAccess" value="always" /><param name="allowFullscreen" value="true" /><embed src="http://www.motionbox.com/external/hd_player/type%253Dsd%252Caffiliate_name%253Dpro%252Cvideo_uid%253D7c99dfb41b1fe6c7f4" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" width="416" height="234" allowFullscreen="true" allowScriptAccess="always" name="mbox_player_7c99dfb41b1fe6c7f4"></embed></object>


with the new code:


Code:
<object id="video-7c99dfb41b1fe6c7f4" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="416" height="234"><param name="movie" value="http://www.sproutvideo.com/flash/MediaPlayer.swf" /><param name="allowScriptAccess" value="always"><param name="allowFullscreen" value="true"><param name="flashvars" value="id=7c99dfb41b1fe6c7f4&st=170e02740ae12cde&type=sd"><!--[if !IE]>--><object type="application/x-shockwave-flash" allowScriptAccess="always" allowFullscreen="true" data="http://www.sproutvideo.com/flash/MediaPlayer.swf" width="416" height="234" flashvars="id=7c99dfb41b1fe6c7f4&st=170e02740ae12cde&type=sd"><!--<![endif]--><p>Please install Adobe Flash to watch this video. <a href="http://www.adobe.com/go/getflashplayer/"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p><!--[if !IE]>--></object><!--<![endif]--></object>


I bow down to thee sql masters... seriously though right now i've got 300 or so videos that are dead until i fix this + am stuck.

I realize it's not wrapping the lines, here's a pastbin of the old vs. new code:
OLD CODE <object classid="clsid:D27CDB6E-AE6D-1
 


i would try REPLACE(str,from_str,to_str). but somehow EXCLUDE the video ID. or find and replace in two executions, BEFORE the video ID. and after.

XXXXXXXXXXXvideoIDYYYYYYYYYYYYY


I would definitely try to find and replace with exluding the video id first, definitely a way cleaner solution. Wish i was better at sql to help out.
goodluck
 
This is not something you can do with a simple sql query. I would do it like this: Dump the row id + the content field in a sql file. Then write a script in php that reads the sql file and changes the code using php simple DOM parser and write results to a sql file you can then import. (update posts set postcontent="__changed__html__" where id=__postid__)