Author Topic: Looking for videos which the duration is more than *** minutes  (Read 12654 times)

0 Members and 1 Guest are viewing this topic.

Offline Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
Looking for videos which the duration is more than *** minutes
« 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,

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Looking for videos which the duration is more than *** minutes
« Reply #1 on: December 21, 2008, 08:34:13 PM »
you can start with this tutorial:
[Tutorial] Making additional field searchable
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
Re: Looking for videos which the duration is more than *** minutes
« Reply #2 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.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Looking for videos which the duration is more than *** minutes
« Reply #3 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)...
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
Re: Looking for videos which the duration is more than *** minutes
« Reply #4 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?

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Looking for videos which the duration is more than *** minutes
« Reply #5 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
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
Re: Looking for videos which the duration is more than *** minutes
« Reply #6 on: December 21, 2008, 11:51:03 PM »
I am using now TIME(). So instead of 00:00 I have 00:00:00

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Looking for videos which the duration is more than *** minutes
« Reply #7 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($t0); ### 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]), 111970); ### 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'];
  }
« Last Edit: December 22, 2008, 02:06:47 AM by V@no »
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
Re: Looking for videos which the duration is more than *** minutes
« Reply #8 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?

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Looking for videos which the duration is more than *** minutes
« Reply #9 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($t0); ### 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]), 111970); ### this will return number in seconds.

and see if it still works.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
Re: Looking for videos which the duration is more than *** minutes
« Reply #10 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

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Looking for videos which the duration is more than *** minutes
« Reply #11 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.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
Re: Looking for videos which the duration is more than *** minutes
« Reply #12 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

I will give it a try. Your never know...

Offline J.Lond

  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: Looking for videos which the duration is more than *** minutes
« Reply #13 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

Offline Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
Re: Looking for videos which the duration is more than *** minutes
« Reply #14 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.