Adult Script Pro Community Forums

The forum is here for legacy reasons. No new posts will be created. User registration is disabled! If you have any questions, please email us or check https://www.adultscriptpro.com for more details!

You are not logged in.

#1 2011-10-10 06:45:16

Eri
Member
Registered: 2011-03-18
Posts: 977

video thumbs on xml

i have made a file to show video thumbs in xml for the jw player to show thumbs at the seek bar
but i want to use cache and if this is the right way to do it.


Here is the code

<?php
define('_VALID', true);
require '/var/www/vhosts/mysite.com/httpdocs/libraries/bootstrap.php';

error_reporting(E_ALL);
ini_set('display_errors', 1);

$video_id     = (isset($_GET['id'])) ? (int) $_GET['id'] : 0;
if ($video_id === 0) {
    die('Invalid video id!');
}

header("content-type:text/xml;charset=utf-8");
ob_start();
echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>
<data>";
$db                = VF::factory('database');
$current_date    = date('Y-m-d');
$index            = array();            
$sql                = "SELECT v.video_id, v.thumb,
                                     GROUP_CONCAT(DISTINCT c.cat_id) AS categories,
                                     GROUP_CONCAT(DISTINCT c.slug) AS slugs,
                                     GROUP_CONCAT(DISTINCT c.name) AS name,
                                     GROUP_CONCAT(DISTINCT t.name) AS tags
                                FROM #__video AS v
                                LEFT JOIN #__video_category AS vc ON (vc.video_id = v.video_id)
                                LEFT JOIN #__video_categories AS c ON (vc.cat_id = c.cat_id)
                                LEFT JOIN #__video_tags AS t ON (t.video_id = v.video_id)
                                LEFT JOIN #__video_meta AS vm ON (vm.video_id = v.video_id)
                                LEFT JOIN #__user AS u ON (u.user_id = v.user_id)
                                WHERE v.video_id = ".$video_id."";
$videos = $db->get_rows($sql);                  
foreach ($videos as $video) {                                            
    echo '<link>'.BASE_URL.'/media/videos/tmb/'.path($video['video_id']).'/1.jpg</link>',"\n";
    echo '<link>'.BASE_URL.'/media/videos/tmb/'.path($video['video_id']).'/2.jpg</link>',"\n";
    echo '<link>'.BASE_URL.'/media/videos/tmb/'.path($video['video_id']).'/3.jpg</link>',"\n";
    echo '<link>'.BASE_URL.'/media/videos/tmb/'.path($video['video_id']).'/4.jpg</link>',"\n";
    echo '<link>'.BASE_URL.'/media/videos/tmb/'.path($video['video_id']).'/5.jpg</link>',"\n";
    echo '<link>'.BASE_URL.'/media/videos/tmb/'.path($video['video_id']).'/6.jpg</link>',"\n";
    echo '<link>'.BASE_URL.'/media/videos/tmb/'.path($video['video_id']).'/7.jpg</link>',"\n";
    echo '<link>'.BASE_URL.'/media/videos/tmb/'.path($video['video_id']).'/8.jpg</link>',"\n";
    echo '<link>'.BASE_URL.'/media/videos/tmb/'.path($video['video_id']).'/9.jpg</link>',"\n";
    echo '<link>'.BASE_URL.'/media/videos/tmb/'.path($video['video_id']).'/10.jpg</link>',"\n";
    echo '<link>'.BASE_URL.'/media/videos/tmb/'.path($video['video_id']).'/11.jpg</link>',"\n";
    echo '<link>'.BASE_URL.'/media/videos/tmb/'.path($video['video_id']).'/12.jpg</link>',"\n";
    echo '<link>'.BASE_URL.'/media/videos/tmb/'.path($video['video_id']).'/13.jpg</link>',"\n";
    echo '<link>'.BASE_URL.'/media/videos/tmb/'.path($video['video_id']).'/14.jpg</link>',"\n";
    echo '<link>'.BASE_URL.'/media/videos/tmb/'.path($video['video_id']).'/15.jpg</link>',"\n";
    echo '<link>'.BASE_URL.'/media/videos/tmb/'.path($video['video_id']).'/16.jpg</link>',"\n";
    echo '<link>'.BASE_URL.'/media/videos/tmb/'.path($video['video_id']).'/17.jpg</link>',"\n";
    echo '<link>'.BASE_URL.'/media/videos/tmb/'.path($video['video_id']).'/18.jpg</link>',"\n";
    echo '<link>'.BASE_URL.'/media/videos/tmb/'.path($video['video_id']).'/19.jpg</link>',"\n";
    echo '<link>'.BASE_URL.'/media/videos/tmb/'.path($video['video_id']).'/20.jpg</link>',"\n"; }
echo "</data>";

VF::close();

?>

Best Adult Affilitate Network:
ExoClick
Best Deals on Dedicated Servers - CDN
INXY

Offline

#2 2011-10-10 07:07:37

symtab
Administrator
Registered: 2010-08-23
Posts: 7,501
Website

Re: video thumbs on xml

For the video thumbs you only need the following v.video_id, v.thumb, v.thumbs. The query will become:

$db = VF::factory('db');
$cache = VF::factory('cache');
if (!$video = $cache->get('video_thumbs_'.$video_id, 86400)) {
   $db->query("SELECT video_id, thumb, thumbs FROM #__video WHERE video_id = ".$video_id." LIMIT 1");
   if ($db->affected_rows()) {
      $video = $db->fetch_assoc();
      $cache->store('video_thumbs_'.$video_id, $video, 86400);
   } else {
      $video = array();
   }
}

// just checking if this video exists
echo '<data>',"\n";
if (isset($video['thumbs'])) {
  $thumbs = (int) $video['thumbs'];
  for ($i=1; $i<=$thumbs; $i++) {
     echo '<link>'.BASE_URL.'/media/videos/tmb/'.path($video_id).'/'.$i.'.jpg</link>',"\n";
  }
}
echo '</data>',"\n";

Didnt test the code. Let me know if it works as expected, if not i fix.


Adult Scripts: Adult Script Pro - Adult Search Script
Adult Advertising/Traffic: Plug Rush - EXOClick - PopAds

Offline

#3 2011-10-10 08:22:07

Eri
Member
Registered: 2011-03-18
Posts: 977

Re: video thumbs on xml

getting this error
<b>Fatal error</b>:  VF::load() [<a href='function.require'>function.require</a>]: Failed opening required '/var/www/vhosts/mysite.com/httpdocs/libraries/framework/db.php' (include_path='.:/usr/share/pear:/usr/share/php') in <b>/var/www/vhosts/mysite.com/httpdocs/libraries/framework.php</b> on line <b>22</b><br />


Best Adult Affilitate Network:
ExoClick
Best Deals on Dedicated Servers - CDN
INXY

Offline

#4 2011-10-10 10:25:24

symtab
Administrator
Registered: 2010-08-23
Posts: 7,501
Website

Re: video thumbs on xml

You need to replace /var/www/vhosts/mysite.com/httpdocs/ with /where/aspro/is/installed/


Adult Scripts: Adult Script Pro - Adult Search Script
Adult Advertising/Traffic: Plug Rush - EXOClick - PopAds

Offline

#5 2011-10-10 10:40:41

Eri
Member
Registered: 2011-03-18
Posts: 977

Re: video thumbs on xml

I know, i have replaced my site link with mysite.com


Best Adult Affilitate Network:
ExoClick
Best Deals on Dedicated Servers - CDN
INXY

Offline

#6 2011-10-10 11:01:27

symtab
Administrator
Registered: 2010-08-23
Posts: 7,501
Website

Re: video thumbs on xml

And it still doesnt work?


Adult Scripts: Adult Script Pro - Adult Search Script
Adult Advertising/Traffic: Plug Rush - EXOClick - PopAds

Offline

#7 2011-10-10 13:42:19

Eri
Member
Registered: 2011-03-18
Posts: 977

Re: video thumbs on xml

yep


Best Adult Affilitate Network:
ExoClick
Best Deals on Dedicated Servers - CDN
INXY

Offline

#8 2011-10-10 14:26:45

symtab
Administrator
Registered: 2010-08-23
Posts: 7,501
Website

Re: video thumbs on xml

Please email me FTP access.


Adult Scripts: Adult Script Pro - Adult Search Script
Adult Advertising/Traffic: Plug Rush - EXOClick - PopAds

Offline

Board footer

Powered by FluxBB