fixed ugly sql
git-svn-id: http://yolanda.mister-muffin.de/svn@98 7eef14d0-6ed0-489d-bf55-20463b2d70db
This commit is contained in:
parent
1c155bdcad
commit
9e2639bde3
2 changed files with 21 additions and 22 deletions
|
@ -45,9 +45,10 @@ $dbh = DBI->connect("DBI:mysql:$database:$dbhost", $dbuser, $dbpass) or interrup
|
|||
while(1)
|
||||
{
|
||||
#get fresh video id from db
|
||||
my $sth = $dbh->prepare(qq{select id, title, description, userid, timestamp from uploaded where status = 0 limit 1}) or interrupt $dbh->errstr;
|
||||
my $sth = $dbh->prepare(qq{select id from uploaded where status = 0 limit 1}) or interrupt $dbh->errstr;
|
||||
|
||||
$sth->execute() or interrupt $dbh->errstr;
|
||||
my ($id, $title, $description, $userid, $timestamp) = $sth->fetchrow_array();
|
||||
my ($id) = $sth->fetchrow_array();
|
||||
$sth->finish() or interrupt $dbh->errstr;
|
||||
|
||||
if($id)
|
||||
|
@ -144,16 +145,12 @@ while(1)
|
|||
{
|
||||
appendlog $id, "file already is ogg-theora/vorbis";
|
||||
|
||||
#write status 1 to uploaded table
|
||||
$sth = $dbh->prepare(qq{update uploaded set status = ? where id = ?}) or interrupt $dbh->errstr;
|
||||
$sth->execute(1, $id) or interrupt $dbh->errstr;
|
||||
$sth->finish() or interrupt $dbh->errstr;
|
||||
|
||||
#add video to videos table
|
||||
$sth = $dbh->prepare(qq{insert into videos (id, title, description, userid, timestamp,
|
||||
hash, filesize, duration, width, height, fps)
|
||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)}) or interrupt $dbh->errstr;
|
||||
$sth->execute($id, $title, $description, $userid, $timestamp, $sha, $filesize, $duration, $width, $height, $fps) or interrupt $dbh->errstr;
|
||||
$sth = $dbh->prepare(qq{insert into videos select id, title, description, userid, timestamp, creator,
|
||||
subject, contributor, source, language, coverage, rights, license, notice,
|
||||
derivativeworks, sharealike, commercialuse, ?, ?, ?, ?, ?, ?
|
||||
from uploaded where id = ?}) or interrupt $dbh->errstr;
|
||||
$sth->execute($filesize, $duration, $width, $height, $fps, $sha, $id) or interrupt $dbh->errstr;
|
||||
$sth->finish() or interrupt $dbh->errstr;
|
||||
|
||||
#move video
|
||||
|
@ -162,24 +159,26 @@ while(1)
|
|||
else #encode video
|
||||
{
|
||||
#FIXME: remove endtime - this is for testing only
|
||||
#TODO: addmetadata information
|
||||
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;
|
||||
|
||||
#write status 1 to uploaded table
|
||||
$sth = $dbh->prepare(qq{update uploaded set status = ? where id = ?}) or interrupt $dbh->errstr;
|
||||
$sth->execute(1, $id) or interrupt $dbh->errstr;
|
||||
$sth->finish() or interrupt $dbh->errstr;
|
||||
|
||||
#add video to videos table
|
||||
$sth = $dbh->prepare(qq{insert into videos (id, title, description, userid, timestamp,
|
||||
hash, filesize, duration, width, height, fps)
|
||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)}) or interrupt $dbh->errstr;
|
||||
$sth->execute($id, $title, $description, $userid, $timestamp, $sha, $filesize, $duration, $width, $height, $fps) or interrupt $dbh->errstr;
|
||||
$sth = $dbh->prepare(qq{insert into videos select id, title, description, userid, timestamp, creator,
|
||||
subject, contributor, source, language, coverage, rights, license, notice,
|
||||
derivativeworks, sharealike, commercialuse, ?, ?, ?, ?, ?, ?
|
||||
from uploaded where id = ?}) or interrupt $dbh->errstr;
|
||||
$sth->execute($filesize, $duration, $width, $height, $fps, $sha, $id) or interrupt $dbh->errstr;
|
||||
$sth->finish() or interrupt $dbh->errstr;
|
||||
|
||||
#delete temp file
|
||||
unlink "$gnutube_root/tmp/$id";
|
||||
}
|
||||
|
||||
#write status 1 to uploaded table
|
||||
$sth = $dbh->prepare(qq{update uploaded set status = ? where id = ?}) or interrupt $dbh->errstr;
|
||||
$sth->execute(1, $id) or interrupt $dbh->errstr;
|
||||
$sth->finish() or interrupt $dbh->errstr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,7 +48,6 @@ $dbh->do(qq{create table
|
|||
title varchar(255) not null,
|
||||
description varchar(255) not null,
|
||||
userid int not null,
|
||||
status int not null,
|
||||
timestamp bigint not null,
|
||||
creator varchar(255) not null,
|
||||
subject varchar(255) not null,
|
||||
|
@ -62,6 +61,7 @@ $dbh->do(qq{create table
|
|||
derivativeworks bool not null,
|
||||
sharealike bool not null,
|
||||
commercialuse bool not null,
|
||||
status int not null,
|
||||
primary key (id)
|
||||
)
|
||||
}) or die $dbh->errstr;
|
||||
|
@ -73,7 +73,6 @@ $dbh->do(qq{create table
|
|||
title varchar(255) not null,
|
||||
description varchar(255) not null,
|
||||
userid int not null,
|
||||
hash char(64) not null,
|
||||
timestamp bigint not null,
|
||||
creator varchar(255) not null,
|
||||
subject varchar(255) not null,
|
||||
|
@ -92,6 +91,7 @@ $dbh->do(qq{create table
|
|||
width smallint not null,
|
||||
height smallint not null,
|
||||
fps float not null,
|
||||
hash char(64) not null,
|
||||
primary key (id),
|
||||
fulltext (title, description, subject)
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue