From eeeeeeb6493ab632d85d3b84795cabaef0a9fc64 Mon Sep 17 00:00:00 2001 From: josch Date: Thu, 18 Oct 2007 11:47:50 +0000 Subject: [PATCH] added latest additions git-svn-id: http://yolanda.mister-muffin.de/svn@88 7eef14d0-6ed0-489d-bf55-20463b2d70db --- trunk/gnutube_daemon.pl | 3 +++ trunk/search.pl | 59 +++++++++++++++++++++++++++++++++++++++++ trunk/site/gnutube.xml | 1 + 3 files changed, 63 insertions(+) diff --git a/trunk/gnutube_daemon.pl b/trunk/gnutube_daemon.pl index 181cbc4..8d6f5a1 100755 --- a/trunk/gnutube_daemon.pl +++ b/trunk/gnutube_daemon.pl @@ -11,6 +11,7 @@ $dbuser = 'root'; $dbpass = ''; $gnutube_root = '/var/www/gnutube'; +#TODO: deamonize by uncommenting this line #Proc::Daemon::Init; $LOG = "/var/www/gnutube/daemon.log"; @@ -126,6 +127,7 @@ while(1) } else { + #TODO: maybe delete entry from uploaded table after successful upload? $filesize = -s "$gnutube_root/tmp/$id"; #check if the upload already is in the right format @@ -150,6 +152,7 @@ while(1) } else #encode video { + #FIXME: remove endtime - this is for testing only system "ffmpeg2theora --optimize --videobitrate 1000 --audiobitrate 64 --sharpness 0 --endtime 10 --output $gnutube_root/videos/$id $gnutube_root/tmp/$id 2>&1"; appendlog $id, $audio, $video, $width, $height, $fps, $duration, $sha; diff --git a/trunk/search.pl b/trunk/search.pl index 8bd08ae..361d511 100644 --- a/trunk/search.pl +++ b/trunk/search.pl @@ -66,6 +66,65 @@ if($query->param('query')) #print xml print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page'); } +if($query->param('sort')) +{ + %page = (); + + #if a username is associated with session id, username is nonempty + $page->{'username'} = get_username_from_sid($session->id); + $page->{'locale'} = $locale; + $page->{'stylesheet'} = $stylesheet; + $page->{'xmlns:dc'} = $xmlns_dc; + $page->{'xmlns:cc'} = $xmlns_cc; + $page->{'xmlns:rdf'} = $xmlns_rdf; + + $page->{results}->{query} = decode_utf8($query->param('query')); + + #connect to db + my $dbh = DBI->connect("DBI:mysql:$database:$dbhost", $dbuser, $dbpass) or die $dbh->errstr; + + #prepare query + my $sth = $dbh->prepare(qq{select id, title, description, userid, timestamp from videos order by timestamp desc }) or die $dbh->errstr; + + #execute it + $sth->execute($query->param('query')) or die $dbh->errstr; + + #get every returned value + while (my ($id, $title, $description, $userid, $timestamp) = $sth->fetchrow_array()) + { + #before code cleanup, this was a really obfuscated array/hash creation + push @{ $page->{'results'}->{'result'} }, + { + 'thumbnail' => ['./video-stills/225x150/4chan_city_mashup.png'], + 'rdf:RDF' => + { + 'cc:Work' => + { + 'rdf:about' => "./video.pl?title=$title&id=$id", + 'dc:title' => [$title], + 'dc:date' => [$timestamp], + 'dc:publisher' => [get_username_from_id($userid)] + }, + 'cc:License' => + { + 'rdf:about' => 'http://creativecommons.org/licenses/GPL/2.0/' + } + } + }; + } + + #finish query + $sth->finish() or die $dbh->errstr; + + #close db + $dbh->disconnect() or die $dbh->errstr; + + #print xml http header along with session cookie + print $session->header(-type=>'text/xml'); + + #print xml + print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page'); +} else { print $session->header(); diff --git a/trunk/site/gnutube.xml b/trunk/site/gnutube.xml index ff4a517..f4fd474 100755 --- a/trunk/site/gnutube.xml +++ b/trunk/site/gnutube.xml @@ -23,6 +23,7 @@ search.pl?query= upload.pl uploader.pl + search.pl?sort=desc