upload now works again - fixed daemon.pl

git-svn-id: http://yolanda.mister-muffin.de/svn@171 7eef14d0-6ed0-489d-bf55-20463b2d70db
main
josch 17 years ago
parent 77eae53dc5
commit de6e466797

@ -5,16 +5,16 @@ use DBI;
use Digest::SHA;
use File::Copy;
$database = 'gnutube';
$database = 'yolanda';
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$gnutube_root = '/var/www/gnutube';
$root = '/var/www/yolanda';
#TODO: deamonize by uncommenting this line
#Proc::Daemon::Init;
$LOG = "/var/www/gnutube/daemon.log";
$LOG = "$root/daemon.log";
sub appendlog
@ -53,7 +53,7 @@ while(1)
if($id)
{
$info = `ffplay -stats -an -vn -nodisp $gnutube_root/tmp/$id 2>&1`;
$info = `ffplay -stats -an -vn -nodisp $root/tmp/$id 2>&1`;
if($info =~ /ignoring/)
{
@ -61,7 +61,7 @@ while(1)
#write status 2 to uploaded table
$dbh->do(qq{update uploaded set status = ? where id = ?}, undef, 2, $id) or interrupt $dbh->errstr;
unlink "$gnutube_root/tmp/$id";
unlink "$root/tmp/$id";
}
elsif ($info =~ /I\/O error occured/)
{
@ -69,7 +69,7 @@ while(1)
#write status 3 to uploaded table
$dbh->do(qq{update uploaded set status = ? where id = ?}, undef, 3, $id) or interrupt $dbh->errstr;
unlink "$gnutube_root/tmp/$id";
unlink "$root/tmp/$id";
}
elsif ($info =~ /Unknown format/ or $info =~ /could not find codec parameters/)
{
@ -77,12 +77,12 @@ while(1)
#write status 4 to uploaded table
$dbh->do(qq{update uploaded set status = ? where id = ?}, undef, 4, $id) or interrupt $dbh->errstr;
unlink "$gnutube_root/tmp/$id";
unlink "$root/tmp/$id";
}
else
{
$sha = new Digest::SHA(256);
$sha->addfile("$gnutube_root/tmp/$id");
$sha->addfile("$root/tmp/$id");
$sha = $sha->hexdigest;
#check if this hash is already in database
@ -98,7 +98,7 @@ while(1)
#write status 5 to uploaded table
$dbh->do(qq{update uploaded set status = ? where id = ?}, undef, 5, $id) or interrupt $dbh->errstr;
unlink "$gnutube_root/tmp/$id";
unlink "$root/tmp/$id";
}
else
{
@ -114,12 +114,12 @@ while(1)
#write status 2 to uploaded table
$dbh->do(qq{update uploaded set status = ? where id = ?}, undef, 2, $id) or interrupt $dbh->errstr;
unlink "$gnutube_root/tmp/$id";
unlink "$root/tmp/$id";
}
else
{
#TODO: maybe delete entry from uploaded table after successful upload?
$filesize = -s "$gnutube_root/tmp/$id";
$filesize = -s "$root/tmp/$id";
#convert hh:mm:ss.s duration to full seconds - thanks perl for making this so damn easy!
#don't want to know how this would look in python or php... hell I don't even have to create extra variables!
@ -137,7 +137,7 @@ while(1)
$tnheight = 120;
$tnwidth = int(120*($width/$height)/2 + .5)*2;
}
system "ffmpeg -i $gnutube_root/tmp/$id -vcodec mjpeg -vframes 1 -an -f rawvideo -ss $thumbnailsec -s ".$tnwidth."x$tnheight $gnutube_root/video-stills/$id";
system "ffmpeg -i $root/tmp/$id -vcodec mjpeg -vframes 1 -an -f rawvideo -ss $thumbnailsec -s ".$tnwidth."x$tnheight $root/video-stills/$id";
#check if the upload already is in the right format
if ($container eq 'ogg' and $video eq 'theora' and $audio eq 'vorbis')
@ -152,13 +152,13 @@ while(1)
$height, $fps, $sha, $id) or interrupt $dbh->errstr;
#move video
move "$gnutube_root/tmp/$id", "$gnutube_root/videos/$id";
move "$root/tmp/$id", "$root/videos/$id";
}
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";
system "ffmpeg2theora --optimize --videobitrate 1000 --audiobitrate 64 --sharpness 0 --endtime 10 --output $root/videos/$id $root/tmp/$id 2>&1";
appendlog $id, $audio, $video, $width, $height, $fps, $duration, $sha;
#add video to videos table
@ -169,7 +169,7 @@ while(1)
$height, $fps, $sha, $id) or interrupt $dbh->errstr;
#delete temp file
unlink "$gnutube_root/tmp/$id";
unlink "$root/tmp/$id";
}
#write status 1 to uploaded table

@ -116,7 +116,7 @@ sub fill_results
#before code cleanup, this was a really obfuscated array/hash creation
push @{ $page->{'results'}->{'result'} },
{
'thumbnail' => "/video-stills/$id",
'thumbnail' => $duration == 0 ? "/images/tango/video-x-generic.png" : "/video-stills/$id",
'duration' => $duration,
'viewcount' => $viewcount,
'edit' => $userinfo->{'username'} eq $publisher ? "true" : "false",
@ -128,7 +128,7 @@ sub fill_results
'dc:title' => [$title],
'dc:creator' => [$creator],
'dc:date' => [$timestamp],
'dc:identifier' => ["$domain/video/$title/$id"],
'dc:identifier' => ["$domain/video/$title/$id" . ($duration == 0 ? "/edit=true" : "")],
'dc:publisher' => [$publisher]
},
'cc:License' =>

@ -15,28 +15,37 @@ if($userinfo->{'username'})
{
if($query->param('2'))
{
$page->{uploadform} = {'page' => '2'};
$page->{'uploadform'}->{'page'} = '2';
}
elsif($query->param('3'))
{
$page->{uploadform} = {'page' => '3'};
$page->{'uploadform'}->{'page'} = '3';
}
elsif($query->param('4'))
{
$page->{uploadform} = {'page' => '4'};
$page->{'uploadform'}->{'page'} = '4';
}
elsif($query->param('5'))
{
$page->{uploadform} = {'page' => '5'};
$page->{'uploadform'}->{'page'} = '5';
}
elsif($query->param('6'))
{
$page->{uploadform} = {'page' => '6'};
$page->{'uploadform'}->{'page'} = '6';
}
else
{
$page->{uploadform} = {'page' => '1'};
$page->{'uploadform'}->{'page'} = '1';
}
$temp = $query->param('DC.Description');
$temp =~ s/\r\n/\n/g;
$page->{'uploadform'}->{'DC.Title'} = $query->param('DC.Title');
$page->{'uploadform'}->{'DC.Subject'} = $query->param('DC.Subject');
$page->{'uploadform'}->{'DC.Description'} = $temp;
$page->{'uploadform'}->{'DC.Creator'} = $query->param('DC.Creator');
$page->{'uploadform'}->{'DC.Source'} = $query->param('DC.Source');
$page->{'uploadform'}->{'DC.Language'} = $query->param('DC.Language');
$page->{'uploadform'}->{'DC.Coverage'} = $query->param('DC.Coverage');
}
else
{

@ -436,22 +436,52 @@
<xsl:attribute name="action">
<xsl:value-of select="$site_strings[@id='page_upload']" />
</xsl:attribute>
<input name="DC.Creator" type="hidden">
<xsl:attribute name="value">
<xsl:value-of select="//uploadform/@DC.Creator" />
</xsl:attribute>
</input>
<input name="DC.Source" type="hidden">
<xsl:attribute name="value">
<xsl:value-of select="//uploadform/@DC.Source" />
</xsl:attribute>
</input>
<input name="DC.Language" type="hidden">
<xsl:attribute name="value">
<xsl:value-of select="//uploadform/@DC.Language" />
</xsl:attribute>
</input>
<input name="DC.Coverage" type="hidden">
<xsl:attribute name="value">
<xsl:value-of select="//uploadform/@DC.Coverage" />
</xsl:attribute>
</input>
<fieldset>
<input type="hidden" name="page" value="2" />
<div class="messagebox">
<xsl:value-of select="$locale_strings[@id='instruction_title']" />
<br />
<input name="DC.Title" type="text" size="30" />
<input name="DC.Title" type="text" size="30">
<xsl:attribute name="value">
<xsl:value-of select="//uploadform/@DC.Title" />
</xsl:attribute>
</input>
</div>
<div class="messagebox">
<xsl:value-of select="$locale_strings[@id='instruction_subject']" />
<br />
<input name="DC.Subject" type="text" size="30" />
<input name="DC.Subject" type="text" size="30">
<xsl:attribute name="value">
<xsl:value-of select="//uploadform/@DC.Subject" />
</xsl:attribute>
</input>
</div>
<div class="messagebox">
<xsl:value-of select="$locale_strings[@id='instruction_description']" />
<br />
<textarea name="DC.Description" cols="50" rows="5"></textarea>
<textarea name="DC.Description" cols="50" rows="5">
<xsl:value-of select="//uploadform/@DC.Description" />
</textarea>
</div>
<input type="submit" name="2">
<xsl:attribute name="value">
@ -474,6 +504,41 @@
<xsl:attribute name="action">
<xsl:value-of select="$site_strings[@id='page_upload']" />
</xsl:attribute>
<input name="DC.Title" type="hidden">
<xsl:attribute name="value">
<xsl:value-of select="//uploadform/@DC.Title" />
</xsl:attribute>
</input>
<input name="DC.Subject" type="hidden">
<xsl:attribute name="value">
<xsl:value-of select="//uploadform/@DC.Subject" />
</xsl:attribute>
</input>
<input name="DC.Description" type="hidden">
<xsl:attribute name="value">
<xsl:value-of select="//uploadform/@DC.Description" />
</xsl:attribute>
</input>
<input name="DC.Creator" type="hidden">
<xsl:attribute name="value">
<xsl:value-of select="//uploadform/@DC.Creator" />
</xsl:attribute>
</input>
<input name="DC.Source" type="hidden">
<xsl:attribute name="value">
<xsl:value-of select="//uploadform/@DC.Source" />
</xsl:attribute>
</input>
<input name="DC.Language" type="hidden">
<xsl:attribute name="value">
<xsl:value-of select="//uploadform/@DC.Language" />
</xsl:attribute>
</input>
<input name="DC.Coverage" type="hidden">
<xsl:attribute name="value">
<xsl:value-of select="//uploadform/@DC.Coverage" />
</xsl:attribute>
</input>
<fieldset>
<input type="submit" name="1">
<xsl:attribute name="value">
@ -501,6 +566,21 @@
<xsl:attribute name="action">
<xsl:value-of select="$site_strings[@id='page_upload']" />
</xsl:attribute>
<input name="DC.Title" type="hidden">
<xsl:attribute name="value">
<xsl:value-of select="//uploadform/@DC.Title" />
</xsl:attribute>
</input>
<input name="DC.Subject" type="hidden">
<xsl:attribute name="value">
<xsl:value-of select="//uploadform/@DC.Subject" />
</xsl:attribute>
</input>
<input name="DC.Description" type="hidden">
<xsl:attribute name="value">
<xsl:value-of select="//uploadform/@DC.Description" />
</xsl:attribute>
</input>
<fieldset>
<div class="messagebox">
<xsl:value-of select="$locale_strings[@id='instruction_creator']" />
@ -554,6 +634,41 @@
<xsl:attribute name="action">
<xsl:value-of select="$site_strings[@id='page_upload']" />
</xsl:attribute>
<input name="DC.Title" type="hidden">
<xsl:attribute name="value">
<xsl:value-of select="//uploadform/@DC.Title" />
</xsl:attribute>
</input>
<input name="DC.Subject" type="hidden">
<xsl:attribute name="value">
<xsl:value-of select="//uploadform/@DC.Subject" />
</xsl:attribute>
</input>
<input name="DC.Description" type="hidden">
<xsl:attribute name="value">
<xsl:value-of select="//uploadform/@DC.Description" />
</xsl:attribute>
</input>
<input name="DC.Creator" type="hidden">
<xsl:attribute name="value">
<xsl:value-of select="//uploadform/@DC.Creator" />
</xsl:attribute>
</input>
<input name="DC.Source" type="hidden">
<xsl:attribute name="value">
<xsl:value-of select="//uploadform/@DC.Source" />
</xsl:attribute>
</input>
<input name="DC.Language" type="hidden">
<xsl:attribute name="value">
<xsl:value-of select="//uploadform/@DC.Language" />
</xsl:attribute>
</input>
<input name="DC.Coverage" type="hidden">
<xsl:attribute name="value">
<xsl:value-of select="//uploadform/@DC.Coverage" />
</xsl:attribute>
</input>
<fieldset>
<div class="messagebox">
<input type="radio" name="license" checked="checked" />none
@ -598,7 +713,57 @@
<xsl:attribute name="action">
<xsl:value-of select="$site_strings[@id='page_upload']" />
</xsl:attribute>
<input name="DC.Title" type="hidden">
<xsl:attribute name="value">
<xsl:value-of select="//uploadform/@DC.Title" />
</xsl:attribute>
</input>
<input name="DC.Subject" type="hidden">
<xsl:attribute name="value">
<xsl:value-of select="//uploadform/@DC.Subject" />
</xsl:attribute>
</input>
<input name="DC.Description" type="hidden">
<xsl:attribute name="value">
<xsl:value-of select="//uploadform/@DC.Description" />
</xsl:attribute>
</input>
<fieldset>
<input name="DC.Title" type="hidden">
<xsl:attribute name="value">
<xsl:value-of select="//uploadform/@DC.Title" />
</xsl:attribute>
</input>
<input name="DC.Subject" type="hidden">
<xsl:attribute name="value">
<xsl:value-of select="//uploadform/@DC.Subject" />
</xsl:attribute>
</input>
<input name="DC.Description" type="hidden">
<xsl:attribute name="value">
<xsl:value-of select="//uploadform/@DC.Description" />
</xsl:attribute>
</input>
<input name="DC.Creator" type="hidden">
<xsl:attribute name="value">
<xsl:value-of select="//uploadform/@DC.Creator" />
</xsl:attribute>
</input>
<input name="DC.Source" type="hidden">
<xsl:attribute name="value">
<xsl:value-of select="//uploadform/@DC.Source" />
</xsl:attribute>
</input>
<input name="DC.Language" type="hidden">
<xsl:attribute name="value">
<xsl:value-of select="//uploadform/@DC.Language" />
</xsl:attribute>
</input>
<input name="DC.Coverage" type="hidden">
<xsl:attribute name="value">
<xsl:value-of select="//uploadform/@DC.Coverage" />
</xsl:attribute>
</input>
<div class="messagebox">
title:
<br />
@ -643,6 +808,41 @@
<xsl:attribute name="action">
<xsl:value-of select="$site_strings[@id='page_uploader']" />
</xsl:attribute>
<input name="DC.Title" type="hidden">
<xsl:attribute name="value">
<xsl:value-of select="//uploadform/@DC.Title" />
</xsl:attribute>
</input>
<input name="DC.Subject" type="hidden">
<xsl:attribute name="value">
<xsl:value-of select="//uploadform/@DC.Subject" />
</xsl:attribute>
</input>
<input name="DC.Description" type="hidden">
<xsl:attribute name="value">
<xsl:value-of select="//uploadform/@DC.Description" />
</xsl:attribute>
</input>
<input name="DC.Creator" type="hidden">
<xsl:attribute name="value">
<xsl:value-of select="//uploadform/@DC.Creator" />
</xsl:attribute>
</input>
<input name="DC.Source" type="hidden">
<xsl:attribute name="value">
<xsl:value-of select="//uploadform/@DC.Source" />
</xsl:attribute>
</input>
<input name="DC.Language" type="hidden">
<xsl:attribute name="value">
<xsl:value-of select="//uploadform/@DC.Language" />
</xsl:attribute>
</input>
<input name="DC.Coverage" type="hidden">
<xsl:attribute name="value">
<xsl:value-of select="//uploadform/@DC.Coverage" />
</xsl:attribute>
</input>
<fieldset>
<div class="messagebox">
<xsl:value-of select="$locale_strings[@id='instruction_file']" />

Loading…
Cancel
Save