This commit is contained in:
j 2007-07-10 14:14:50 +00:00
parent 9779cfc86a
commit 7c1c01a756
6 changed files with 15 additions and 30 deletions

View file

@ -32,19 +32,6 @@ def loadStaticFile(fname):
return loadFile(join(dirname(abspath(__file__)), "static", fname))
def loadDefaultFrame(afile):
frame = join(afile.frameFolder, 'default.png')
if not exists(frame):
data = loadStaticFile('images/stillDark.png')
imageIO = StringIO(data)
sourceImage = Image.open(imageIO)
sourceWidth = sourceImage.size[0]
sourceHeight = sourceImage.size[1]
top = (sourceHeight - afile.sceneHeight) / 2
targetImage = sourceImage.crop((0, top, sourceWidth, top + afile.sceneHeight))
targetImage.save(frame, 'PNG')
return loadFile(frame)
def loadFrame(afile, position):
position = basename(position)
frame = join(afile.frameFolder, '%s.%s' % (position, img_extension))
@ -52,7 +39,7 @@ def loadFrame(afile, position):
afile.extractFrame(position)
if exists(frame):
return loadFile(frame)
return loadDefaultFrame(afile)
return ''
def loadClip(afile, position):
position = basename(position)

View file

@ -25,7 +25,9 @@
# Allow every exposed function to be called as json,
# tg.allow_json = False
tg.no_empty_flash = True
tg.empty_flash = False
# List of Widgets to include on every page.
# for exemple ['turbogears.mochikit']

View file

@ -4,6 +4,7 @@
from turbogears import controllers, expose, flash, redirect
from model import *
from json import *
import cherrypy
# import logging
@ -24,7 +25,6 @@ class Root(controllers.RootController):
def default(self, md5Hash, action, position = None):
f = ArchiveFile.byMd5sum(md5Hash)
if action == 'metadata':
print f
return dict(meta = f)
elif action in ('timeline', 'timeline.png'):
cherrypy.response.headerMap['Content-Type'] = "image/jpeg"

View file

@ -8,19 +8,16 @@
# @jsonify can convert your objects to following types:
# lists, dicts, numbers and strings
from turbojson.jsonify import jsonify
from turbojson.jsonify import jsonify, jsonify_sqlobject
from model import ArchiveFile
@jsonify.when('isinstance(obj, ArchiveFile)')
def jsonify_ArchiveFile(obj):
result = jsonify_sqlobject( obj )
#FIXME, possibly do something with the date values
# date, date_added, modDate, pubDate
for key in ('id', 'archiveID', 'subtitle_meta_id'):
result.pop(key)
return result
@jsonify.when('isinstance(obj, datetime.datetime)')
def jsonify_datetime(obj):
return str(obj)
result = jsonify_sqlobject( obj )
#FIXME, possibly do something with the date values
# date, date_added, modDate, pubDate
for key in ('id', 'archiveID', 'subtitle_meta_id'):
result.pop(key)
print "after, json", result
return result

View file

@ -7,6 +7,7 @@ import sys
_audio_codec_map = {
'ffmp3': 'mp3',
'mad': 'mp3',
}
_video_codec_map = {

View file

@ -196,8 +196,6 @@ class ArchiveFile(SQLObject):
extracted = BoolCol(default = False)
filename = UnicodeCol(default = '')
def _get_part(self):
part = 1
parts = re.compile('Part (\d)').findall(self.path)