View Single Post
Old 05-14-2010, 03:28 AM  
just a punk
So fuckin' bored
 
just a punk's Avatar
 
Industry Role:
Join Date: Jun 2003
Posts: 32,350
Improved PHP code for WP Tubes

Here is a bit improved version of the PHP code for auto-updating WordPress Tube Sites:

PHP Code:
// put the affiliate link to paysite into the 'paysite_url' custom field according to Free WordPress Tube doc
$post ['custom_fields'] ['paysite_url'] = 'http://www.ropeporn.com/index.html?id=XXX';
// format clip's duration as mm:ss
$post ['custom_fields'] ['duration'] = date 'i:s'$post ['custom_fields'] ['duration'] );
// create an URL of thumb from it's path and filename
$post ['custom_fields'] ['thumb'] = $post ['custom_fields'] ['screen_url'] . $post ['custom_fields'] ['screen'];
// put site name into the "paysite_title" custom field according to Free WordPress Tube doc
$post ['custom_fields'] ['paysite_title'] = 'Rope Porn';
// since FLV videos have no uniqui GUID's let's use their URL's as post GUID's  
$post ['guid'] = $post ['custom_fields'] ['clip_url'] . $post ['custom_fields'] ['flv'];
// now the most complex part. we have to create the FLV player code, assuming that our FLV player is stored as flvplayer.swf in the root dir of the blog
$post ['custom_fields'] ['video_code'] = '<object id="player" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" name="player" width="700" height="544"> 
<param name="movie" value="/flvplayer.swf" /> 
<param name="allowfullscreen" value="true" /> 
<param name="allowscriptaccess" value="always" /> 
<param name="flashvars" value="image=' 
$post ['custom_fields'] ['thumb'] . '&file=' $post ['guid'] . '&autostart=false&linkfromdisplay=true&link=' urlencode $post ['custom_fields'] ['paysite_url'] ) . '" /> <object type="application/x-shockwave-flash" data="/flvplayer.swf" width="700" height="544"> 
<param name="movie" value="' 
$post ['guid'] . '" /> 
<param name="link" value="' 
urlencode $post ['custom_fields'] ['paysite_url'] ) . '" /> 
<param name="allowfullscreen" value="true" /> 
<param name="linkfromdisplay" value="true" /> 
<param name="allowscriptaccess" value="always" /> 
<param name="flashvars" value="image=' 
$post ['custom_fields'] ['thumb'] . '&file=' $post ['guid'] . '&autostart=false&linkfromdisplay=true&link=' urlencode $post ['custom_fields'] ['paysite_url'] ) . '" /> <p><a href="http://get.adobe.com/flashplayer">Get Flash</a> to see this player.</p> 
</object> 
</object>'
;
// now let's delete all useless custom fields 
unset ( $post ['custom_fields'] ['screen_url'] );
unset ( 
$post ['custom_fields'] ['screen'] );
unset ( 
$post ['custom_fields'] ['clip_url'] );
unset ( 
$post ['custom_fields'] ['flv'] ); 
This version of code will be fine with links that contain GET parameters ("&").
__________________
Obey the Cowgod
just a punk is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote