added queue length for videos not processed yet and cleaned up video.pl

git-svn-id: http://yolanda.mister-muffin.de/svn@288 7eef14d0-6ed0-489d-bf55-20463b2d70db
This commit is contained in:
josch 2008-04-09 14:16:57 +00:00
parent e0a88beb70
commit 89ae39188d
2 changed files with 30 additions and 48 deletions

View file

@ -80,6 +80,7 @@
<string id="information_registered">Your account has been created.</string> <string id="information_registered">Your account has been created.</string>
<string id="information_uploaded">Your file has been uploaded.</string> <string id="information_uploaded">Your file has been uploaded.</string>
<string id="information_settings_changed">Your successfully changed your settings.</string> <string id="information_settings_changed">Your successfully changed your settings.</string>
<string id="information_video_not_yet_available">The video being requested is not yet available. The overall sum of video queued is:</string>
<!-- warnings --> <!-- warnings -->
<string id="warning_no_results">There are no results satisfying your query.</string> <string id="warning_no_results">There are no results satisfying your query.</string>

View file

@ -18,57 +18,43 @@ if($query->url_param('action') eq 'bookmark' and $query->url_param('id'))
$page->{'message'}->{'type'} = "information"; $page->{'message'}->{'type'} = "information";
} }
#check if id or title is passed #check if id or title is passed
if($query->url_param('title') or $query->url_param('id')) if($query->url_param('id'))
{ {
if($query->url_param('id'))
{
#if id is passed ignore title and check for the id
$dbquery = "select v.id, v.title, v.description, u.username, from_unixtime( v.timestamp ), $dbquery = "select v.id, v.title, v.description, u.username, from_unixtime( v.timestamp ),
v.creator, v.subject, v.source, v.language, v.coverage, v.rights, v.creator, v.subject, v.source, v.language, v.coverage, v.rights,
v.license, filesize, duration, width, height, fps, viewcount, downloadcount v.license, filesize, duration, width, height, fps, viewcount, downloadcount
from videos as v, users as u where v.id = ? and u.id=v.userid"; from videos as v, users as u where v.id = ? and u.id=v.userid";
@args = ($query->url_param('id')); @args = ($query->url_param('id'));
$sth = $dbh->prepare($dbquery);
$rowcount = $sth->execute(@args) or die $dbh->errstr;
#if there are still no results
if($rowcount == 0)
{
#check if maybe the video has not yet been converted
$dbquery = "select id from uploaded where id = ?";
$sth = $dbh->prepare($dbquery);
$rowcount = $sth->execute($query->url_param('id')) or die $dbh->errstr;
#if id is found
if($rowcount == 1)
{
$sth = $dbh->prepare("select sum(duration) from uploaded");
$sth->execute() or die $dbh->errstr;
($length) = $sth->fetchrow_array();
$h = int($length/3600);
$m = int($length/60-$h*60);
$s = int($length-$m*60-$h*3600);
print $query->redirect("/index.pl?information=information_video_not_yet_available&value=".$h."h ".$m."m ".$s."s");
} }
else else
{ {
#if no id was passed there has to be a title we search for
$dbquery = "select v.id, v.title, v.description, u.username, from_unixtime( v.timestamp ),
v.creator, v.subject, v.source, v.language, v.coverage, v.rights,
v.license, filesize, duration, width, height, fps, viewcount, downloadcount
from videos as v, users as u where v.title = ? and u.id=v.userid";
@args = ($query->url_param('title'));
}
$sth = $dbh->prepare($dbquery);
$rowcount = $sth->execute(@args) or die $dbh->errstr;
#if the args are wrong there my be zero results
#if there was a title passed, then perform a search
if($rowcount == 0 and $query->url_param('title'))
{
$dbquery = "select v.id, v.title, v.description, u.username,
from_unixtime( v.timestamp ), v.creator, v.subject,
v.source, v.language, v.coverage, v.rights, v.license, filesize,
duration, width, height, fps, viewcount, downloadcount, 1";
$dbquery .= ", match(v.title, v.description, v.subject) against( ? in boolean mode) as relevance";
$dbquery .= " from videos as v, users as u where u.id = v.userid";
$dbquery .= " and match(v.title, v.description, v.subject) against( ? in boolean mode)";
@args = ($query->url_param('title'), $query->url_param('title'));
$sth = $dbh->prepare($dbquery);
$rowcount = $sth->execute(@args) or die $dbh->errstr;
}
#from this point on, do not use $query->param('id') anymore - we do not know what was given
if($rowcount == 0)
{
#still no results
#there is nothing we can do now - this video doesn't exist... #there is nothing we can do now - this video doesn't exist...
print $query->redirect("/index.pl?error=error_no_video"); print $query->redirect("/index.pl?error=error_no_video");
} }
}
elsif($rowcount == 1) elsif($rowcount == 1)
{ {
if($query->param('embed') eq "video") if($query->param('embed') eq "video")
@ -220,11 +206,6 @@ if($query->url_param('title') or $query->url_param('id'))
} }
print output_page(); print output_page();
} }
else
{
#when an ambigous title was passed there may me many results
#redirect to an appropriate search or throw an error with a link to such a search
}
} }
else else
{ {