import cleanup

This commit is contained in:
j 2011-01-22 15:44:30 +05:30
parent f36e0f56ee
commit 00c8db1a19
8 changed files with 33 additions and 28 deletions

View File

@ -7,7 +7,6 @@ from django.contrib.auth.models import User
import utils
class Layer(models.Model):
class Meta:

View File

@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
# vi:si:et:sw=4:sts=4:ts=4
from item.models import *

View File

@ -78,24 +78,28 @@ class File(models.Model):
setattr(self, key, self.info.get(key, 0))
if 'video' in self.info and self.info['video']:
self.video_codec = self.info['video'][0]['codec']
self.width = self.info['video'][0]['width']
self.height = self.info['video'][0]['height']
self.framerate = self.info['video'][0]['framerate']
if 'display_aspect_ratio' in self.info['video'][0]:
self.display_aspect_ratio = self.info['video'][0]['display_aspect_ratio']
video = self.info['video'][0]
self.video_codec = video['codec']
self.width = video['width']
self.height = video['height']
self.framerate = video['framerate']
if 'display_aspect_ratio' in video:
self.display_aspect_ratio = video['display_aspect_ratio']
else:
self.display_aspect_ratio = "%s:%s" % (self.width, self.height)
self.is_video = True
self.is_audio = False
if self.name.endswith('.jpg') or self.name.endswith('.png') or self.duration == 0.04:
if self.name.endswith('.jpg') or \
self.name.endswith('.png') or \
self.duration == 0.04:
self.is_video = False
else:
self.is_video = False
if 'audio' in self.info and self.info['audio']:
self.audio_codec = self.info['audio'][0]['codec']
self.samplerate = self.info['audio'][0].get('samplerate', 0)
self.channels = self.info['audio'][0].get('channels', 0)
audio = self.info['audio'][0]
self.audio_codec = audio['codec']
self.samplerate = audio.get('samplerate', 0)
self.channels = audio.get('channels', 0)
if not self.is_video:
self.is_audio = True
@ -118,8 +122,10 @@ class File(models.Model):
super(File, self).save(*args, **kwargs)
#upload and data handling
video = models.FileField(null=True, blank=True, upload_to=lambda f, x: f.path('%s.webm'%settings.VIDEO_PROFILE))
data = models.FileField(null=True, blank=True, upload_to=lambda f, x: f.path('data.bin'))
video = models.FileField(null=True, blank=True,
upload_to=lambda f, x: f.path('%s.webm'%settings.VIDEO_PROFILE))
data = models.FileField(null=True, blank=True,
upload_to=lambda f, x: f.path('data.bin'))
def path(self, name):
h = self.oshash
@ -297,4 +303,4 @@ class Frame(models.Model):
'''
def __unicode__(self):
return u'%s at %s' % (self.file, self.position)
return u'%s/%s' % (self.file, self.position)

View File

@ -6,7 +6,6 @@ from datetime import datetime
import os.path
import subprocess
from glob import glob
import unicodedata
from django.db import models
from django.core.files.base import ContentFile
@ -24,7 +23,7 @@ import utils
import tasks
from archive import extract
from annotaion.models import Annotation, Layer
from annotaion.models import Annotation
from person.models import get_name_sort
from app.models import site_config
@ -103,13 +102,15 @@ class Item(models.Model):
external_data = fields.DictField(default={}, editable=False)
data = fields.DictField(default={}, editable=False)
json = fields.DictField(default={}, editable=False)
poster = models.ImageField(default=None, blank=True, upload_to=lambda i, x: i.path("poster.jpg"))
poster = models.ImageField(default=None, blank=True,
upload_to=lambda i, x: i.path("poster.jpg"))
poster_url = models.TextField(blank=True)
poster_height = models.IntegerField(default=0)
poster_width = models.IntegerField(default=0)
poster_frame = models.FloatField(default=-1)
icon = models.ImageField(default=None, blank=True, upload_to=lambda i, x: i.path("icon.jpg"))
icon = models.ImageField(default=None, blank=True,
upload_to=lambda i, x: i.path("icon.jpg"))
#stream related fields
stream_aspect = models.FloatField(default=4/3)

View File

@ -1,6 +1,8 @@
# -*- coding: utf-8 -*-
# vi:si:et:sw=4:sts=4:ts=4
from __future__ import division, with_statement
import os
import subprocess
from django.db import models
from django.contrib.auth.models import User
@ -26,7 +28,8 @@ class List(models.Model):
type= models.CharField(max_length=255, default='static')
description = models.TextField(default='')
icon = models.ImageField(default=None, blank=True, upload_to=lambda i, x: i.path("icon.jpg"))
icon = models.ImageField(default=None, blank=True,
upload_to=lambda i, x: i.path("icon.jpg"))
#is through table still required?
items = models.ManyToManyField('item.Item', related_name='lists',
@ -73,7 +76,9 @@ class List(models.Model):
return True
return False
def json(self, keys=['id', 'name', 'user', 'type', 'query', 'status', 'subscribed'], user=None):
def json(self, keys=None, user=None):
if not keys:
keys=['id', 'name', 'user', 'type', 'query', 'status', 'subscribed']
response = {}
for key in keys:
if key == 'items':
@ -98,7 +103,7 @@ class List(models.Model):
def make_icon(self):
frames = []
iself.icon.name = self.path('icon.png')
self.icon.name = self.path('icon.png')
icon = self.icon.path
if frames:
cmd = [

View File

@ -1,14 +1,11 @@
# -*- coding: utf-8 -*-
# vi:si:et:sw=4:sts=4:ts=4
import os
from datetime import datetime
from django.contrib.auth.models import User
from django.db import models
from django.db.models import Max
from django.conf import settings
from ox.utils import json
from ox.django.fields import DictField
from app.models import site_config

View File

@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
# vi:si:et:sw=4:sts=4:ts=4
import os
import random
random.seed()

View File

@ -3649,4 +3649,4 @@ var pandora = new Ox.App({
load();
});
//});