4images Forum & Community

4images Modifications / Modifikationen => Mods & Plugins (Requests & Discussions) => Topic started by: Sun Zaza on December 21, 2008, 01:17:47 PM

Title: Looking for videos which the duration is more than *** minutes
Post by: Sun Zaza on December 21, 2008, 01:17:47 PM
Hi all,

I believe I have a very nice mod request for 4images:

On my video site I have an additional field with the video duration: {image_duration}.

How can the users look for videos (Search) which the duration is more than 5 minutes? (That was an example).

Is that possible?
Is there any other mod on this forum to tweak? :wink:

Thanks in advance,
Title: Re: Looking for videos which the duration is more than *** minutes
Post by: V@no on December 21, 2008, 08:34:13 PM
you can start with this tutorial:
[Tutorial] Making additional field searchable (http://www.4homepages.de/forum/index.php?topic=1313.msg5562#msg5562)
Title: Re: Looking for videos which the duration is more than *** minutes
Post by: Sun Zaza on December 21, 2008, 08:39:00 PM
Hi Vano,

I use this mod for more than 2 years, but how can the users look for videos (Search) which the duration is more than 5 minutes?

I cannot get your point.
Title: Re: Looking for videos which the duration is more than *** minutes
Post by: V@no on December 21, 2008, 10:50:11 PM
In what format your duration time is stored in the database? if it's text or varchar then its probably wont work at all...unless its stored as a number (int, mediumint, etc)...
Title: Re: Looking for videos which the duration is more than *** minutes
Post by: Sun Zaza on December 21, 2008, 10:53:19 PM
You are wright V@no, It is text. I will change now to int.

Do you want me to change something else?
Title: Re: Looking for videos which the duration is more than *** minutes
Post by: V@no on December 21, 2008, 11:48:14 PM
I don't know how your code work, but if you change to int then you can't use any other characters but the numbers. so time 4:27 will need to be converted to seconds: 267
Title: Re: Looking for videos which the duration is more than *** minutes
Post by: Sun Zaza on December 21, 2008, 11:51:03 PM
I am using now TIME(). So instead of 00:00 I have 00:00:00
Title: Re: Looking for videos which the duration is more than *** minutes
Post by: V@no on December 22, 2008, 01:54:04 AM
Ok, lets try this. I'm not quiet sure what exactly is stored in your database in image_duration, but I'll assume it stores time in seconds, so if video duration is 4:27 in the database it stored number 267 and not huge timestamp number.

In search.php find:

if (!empty($search_id)) {

Insert above:

if (isset($HTTP_GET_VARS['image_duration']) || isset($HTTP_POST_VARS['image_duration'])) {
  $image_duration = isset($HTTP_POST_VARS['image_duration']) ? trim($HTTP_POST_VARS['image_duration']) : trim($HTTP_GET_VARS['image_duration']);
}
else {
  $image_duration = 0;
}

### convert string into seconds. asuming string format is h:m:s (also accepted m:s or simply s)
$t = explode(":", $image_duration);
$c = 3-count($t);
for($i = 0; $i < $c; $i++) array_unshift($t, 0); ### make sure array has at least 3 values
$c = count($t);
$image_duration = gmmktime(intval($t[$c-3]), intval($t[$c-2]), intval($t[$c-1]), 1, 1, 1970); ### this will return number in seconds.

if ($image_duration && $show_result == 1) {
  $search_id['image_duration'] = $image_duration;
}
  if (!empty($sql_where_query)) {
Insert above:
  if (!empty($search_id['image_duration']))
  {
    $sql_where_query .= "AND image_duration >= ".$search_id['image_duration'];
  }
Title: Re: Looking for videos which the duration is more than *** minutes
Post by: Sun Zaza on December 22, 2008, 09:57:14 AM
The time is stored as this format: 00:00:00

Check the screenshot please.

Is that a problem?
Title: Re: Looking for videos which the duration is more than *** minutes
Post by: V@no on December 22, 2008, 10:11:19 AM
hmmmm then it can't be int type of the field...which bring us back to my second reply...

Try remove from my code above:### convert string into seconds. asuming string format is h:m:s (also accepted m:s or simply s)
$t = explode(":", $image_duration);
$c = 3-count($t);
for($i = 0; $i < $c; $i++) array_unshift($t, 0); ### make sure array has at least 3 values
$c = count($t);
$image_duration = gmmktime(intval($t[$c-3]), intval($t[$c-2]), intval($t[$c-1]), 1, 1, 1970); ### this will return number in seconds.

and see if it still works.
Title: Re: Looking for videos which the duration is more than *** minutes
Post by: Sun Zaza on December 22, 2008, 10:37:14 AM
Ok I done it. But how can I test it?

See the attachment please:

The URL: http://www.jogabonito.nl/search.php
Title: Re: Looking for videos which the duration is more than *** minutes
Post by: V@no on December 22, 2008, 03:46:06 PM
well, since your time duration format is 00:00:00 the visitor must enter the needed duration manually - needs a new input field for that.
Title: Re: Looking for videos which the duration is more than *** minutes
Post by: Sun Zaza on December 22, 2008, 03:55:55 PM
I was also thinking about that. It should be something like your other mod: [MOD] Search between specifyed date http://www.4homepages.de/forum/index.php?topic=6182.0  (http://www.4homepages.de/forum/index.php?topic=6182.0)

I will give it a try. Your never know...
Title: Re: Looking for videos which the duration is more than *** minutes
Post by: J.Lond on January 12, 2009, 05:43:09 AM
Hey Cruxy are you manually adding the duration of your videos or have you found a way to automate the process?  I would love to implement an {image_duration} tag as long as it was an automatic process.

Best Regards
Title: Re: Looking for videos which the duration is more than *** minutes
Post by: Sun Zaza on January 12, 2009, 03:41:09 PM
Unfortunately not. I add manually the video duration (For youtube video's).
You can see it here: www.jogabonito.nl.

For the video on your server, Maybe you can ask V@no.
Title: Re: Looking for videos which the duration is more than *** minutes
Post by: J.Lond on January 13, 2009, 11:09:42 AM
Thank you Cruxy for the quick reply.

Best Regards