add media state: uploading, queued, encoding, available
This commit is contained in:
parent
877bb282b8
commit
ff38db7751
5 changed files with 204 additions and 10 deletions
172
pandora/archive/migrations/0008_state.py
Normal file
172
pandora/archive/migrations/0008_state.py
Normal file
|
@ -0,0 +1,172 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
import datetime
|
||||||
|
from south.db import db
|
||||||
|
from south.v2 import SchemaMigration
|
||||||
|
from django.db import models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(SchemaMigration):
|
||||||
|
|
||||||
|
def forwards(self, orm):
|
||||||
|
# Adding field 'File.queued'
|
||||||
|
db.add_column('archive_file', 'queued',
|
||||||
|
self.gf('django.db.models.fields.BooleanField')(default=False),
|
||||||
|
keep_default=False)
|
||||||
|
|
||||||
|
|
||||||
|
def backwards(self, orm):
|
||||||
|
# Deleting field 'File.queued'
|
||||||
|
db.delete_column('archive_file', 'queued')
|
||||||
|
|
||||||
|
|
||||||
|
models = {
|
||||||
|
'archive.file': {
|
||||||
|
'Meta': {'object_name': 'File'},
|
||||||
|
'audio_codec': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
|
||||||
|
'available': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||||
|
'bits_per_pixel': ('django.db.models.fields.FloatField', [], {'default': '-1'}),
|
||||||
|
'channels': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
|
||||||
|
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
|
||||||
|
'data': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}),
|
||||||
|
'display_aspect_ratio': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
|
||||||
|
'duration': ('django.db.models.fields.FloatField', [], {'null': 'True'}),
|
||||||
|
'encoding': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||||
|
'extension': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '255', 'null': 'True'}),
|
||||||
|
'framerate': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
|
||||||
|
'height': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
|
||||||
|
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||||
|
'info': ('ox.django.fields.DictField', [], {'default': '{}'}),
|
||||||
|
'is_audio': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||||
|
'is_subtitle': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||||
|
'is_video': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||||
|
'item': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'files'", 'null': 'True', 'to': "orm['item.Item']"}),
|
||||||
|
'language': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '8', 'null': 'True'}),
|
||||||
|
'modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
|
||||||
|
'oshash': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '16'}),
|
||||||
|
'part': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '255', 'null': 'True'}),
|
||||||
|
'part_title': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '255', 'null': 'True'}),
|
||||||
|
'path': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '2048'}),
|
||||||
|
'pixel_format': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
|
||||||
|
'pixels': ('django.db.models.fields.BigIntegerField', [], {'default': '0'}),
|
||||||
|
'queued': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||||
|
'samplerate': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
|
||||||
|
'selected': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||||
|
'size': ('django.db.models.fields.BigIntegerField', [], {'default': '0'}),
|
||||||
|
'sort_path': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '2048'}),
|
||||||
|
'type': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '255'}),
|
||||||
|
'uploading': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||||
|
'version': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '255', 'null': 'True'}),
|
||||||
|
'video_codec': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
|
||||||
|
'wanted': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||||
|
'width': ('django.db.models.fields.IntegerField', [], {'default': '0'})
|
||||||
|
},
|
||||||
|
'archive.frame': {
|
||||||
|
'Meta': {'unique_together': "(('file', 'position'),)", 'object_name': 'Frame'},
|
||||||
|
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
|
||||||
|
'file': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'frames'", 'to': "orm['archive.File']"}),
|
||||||
|
'frame': ('django.db.models.fields.files.ImageField', [], {'default': 'None', 'max_length': '100', 'null': 'True'}),
|
||||||
|
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||||
|
'modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
|
||||||
|
'position': ('django.db.models.fields.FloatField', [], {})
|
||||||
|
},
|
||||||
|
'archive.instance': {
|
||||||
|
'Meta': {'unique_together': "(('path', 'volume'),)", 'object_name': 'Instance'},
|
||||||
|
'atime': ('django.db.models.fields.IntegerField', [], {'default': '1378990140'}),
|
||||||
|
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
|
||||||
|
'ctime': ('django.db.models.fields.IntegerField', [], {'default': '1378990140'}),
|
||||||
|
'file': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'instances'", 'to': "orm['archive.File']"}),
|
||||||
|
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||||
|
'ignore': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||||
|
'modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
|
||||||
|
'mtime': ('django.db.models.fields.IntegerField', [], {'default': '1378990140'}),
|
||||||
|
'path': ('django.db.models.fields.CharField', [], {'max_length': '2048'}),
|
||||||
|
'volume': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'files'", 'to': "orm['archive.Volume']"})
|
||||||
|
},
|
||||||
|
'archive.stream': {
|
||||||
|
'Meta': {'unique_together': "(('file', 'resolution', 'format'),)", 'object_name': 'Stream'},
|
||||||
|
'aspect_ratio': ('django.db.models.fields.FloatField', [], {'default': '0'}),
|
||||||
|
'available': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||||
|
'color': ('ox.django.fields.TupleField', [], {'default': '[]'}),
|
||||||
|
'cuts': ('ox.django.fields.TupleField', [], {'default': '[]'}),
|
||||||
|
'duration': ('django.db.models.fields.FloatField', [], {'default': '0'}),
|
||||||
|
'file': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'streams'", 'to': "orm['archive.File']"}),
|
||||||
|
'format': ('django.db.models.fields.CharField', [], {'default': "'webm'", 'max_length': '255'}),
|
||||||
|
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||||
|
'info': ('ox.django.fields.DictField', [], {'default': '{}'}),
|
||||||
|
'media': ('django.db.models.fields.files.FileField', [], {'default': 'None', 'max_length': '100', 'blank': 'True'}),
|
||||||
|
'oshash': ('django.db.models.fields.CharField', [], {'max_length': '16', 'null': 'True', 'db_index': 'True'}),
|
||||||
|
'resolution': ('django.db.models.fields.IntegerField', [], {'default': '96'}),
|
||||||
|
'source': ('django.db.models.fields.related.ForeignKey', [], {'default': 'None', 'related_name': "'derivatives'", 'null': 'True', 'to': "orm['archive.Stream']"}),
|
||||||
|
'volume': ('django.db.models.fields.FloatField', [], {'default': '0'})
|
||||||
|
},
|
||||||
|
'archive.volume': {
|
||||||
|
'Meta': {'unique_together': "(('user', 'name'),)", 'object_name': 'Volume'},
|
||||||
|
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
|
||||||
|
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||||
|
'modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
|
||||||
|
'name': ('django.db.models.fields.CharField', [], {'max_length': '1024'}),
|
||||||
|
'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'volumes'", 'to': "orm['auth.User']"})
|
||||||
|
},
|
||||||
|
'auth.group': {
|
||||||
|
'Meta': {'object_name': 'Group'},
|
||||||
|
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||||
|
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
|
||||||
|
'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
|
||||||
|
},
|
||||||
|
'auth.permission': {
|
||||||
|
'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
|
||||||
|
'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||||
|
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
|
||||||
|
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||||
|
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
|
||||||
|
},
|
||||||
|
'auth.user': {
|
||||||
|
'Meta': {'object_name': 'User'},
|
||||||
|
'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
|
||||||
|
'email': ('django.db.models.fields.EmailField', [], {'max_length': '255', 'blank': 'True'}),
|
||||||
|
'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
|
||||||
|
'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
|
||||||
|
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||||
|
'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
|
||||||
|
'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||||
|
'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||||
|
'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
|
||||||
|
'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
|
||||||
|
'password': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
|
||||||
|
'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
|
||||||
|
'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'})
|
||||||
|
},
|
||||||
|
'contenttypes.contenttype': {
|
||||||
|
'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
|
||||||
|
'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||||
|
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||||
|
'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||||
|
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
|
||||||
|
},
|
||||||
|
'item.item': {
|
||||||
|
'Meta': {'object_name': 'Item'},
|
||||||
|
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
|
||||||
|
'data': ('ox.django.fields.DictField', [], {'default': '{}'}),
|
||||||
|
'external_data': ('ox.django.fields.DictField', [], {'default': '{}'}),
|
||||||
|
'groups': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "'items'", 'blank': 'True', 'to': "orm['auth.Group']"}),
|
||||||
|
'icon': ('django.db.models.fields.files.ImageField', [], {'default': 'None', 'max_length': '100', 'blank': 'True'}),
|
||||||
|
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||||
|
'itemId': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '128', 'blank': 'True'}),
|
||||||
|
'json': ('ox.django.fields.DictField', [], {'default': '{}'}),
|
||||||
|
'level': ('django.db.models.fields.IntegerField', [], {'db_index': 'True'}),
|
||||||
|
'modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
|
||||||
|
'oxdbId': ('django.db.models.fields.CharField', [], {'max_length': '42', 'unique': 'True', 'null': 'True', 'blank': 'True'}),
|
||||||
|
'poster': ('django.db.models.fields.files.ImageField', [], {'default': 'None', 'max_length': '100', 'blank': 'True'}),
|
||||||
|
'poster_frame': ('django.db.models.fields.FloatField', [], {'default': '-1'}),
|
||||||
|
'poster_height': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
|
||||||
|
'poster_source': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
|
||||||
|
'poster_width': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
|
||||||
|
'rendered': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
|
||||||
|
'stream_aspect': ('django.db.models.fields.FloatField', [], {'default': '1.3333333333333333'}),
|
||||||
|
'stream_info': ('ox.django.fields.DictField', [], {'default': '{}'}),
|
||||||
|
'torrent': ('django.db.models.fields.files.FileField', [], {'default': 'None', 'max_length': '1000', 'blank': 'True'}),
|
||||||
|
'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'items'", 'null': 'True', 'to': "orm['auth.User']"})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
complete_apps = ['archive']
|
|
@ -76,6 +76,7 @@ class File(models.Model):
|
||||||
available = models.BooleanField(default = False)
|
available = models.BooleanField(default = False)
|
||||||
selected = models.BooleanField(default = False)
|
selected = models.BooleanField(default = False)
|
||||||
uploading = models.BooleanField(default = False)
|
uploading = models.BooleanField(default = False)
|
||||||
|
queued = models.BooleanField(default = False)
|
||||||
encoding = models.BooleanField(default = False)
|
encoding = models.BooleanField(default = False)
|
||||||
wanted = models.BooleanField(default = False)
|
wanted = models.BooleanField(default = False)
|
||||||
|
|
||||||
|
@ -339,11 +340,22 @@ class File(models.Model):
|
||||||
duration = self.duration
|
duration = self.duration
|
||||||
if self.type != 'video':
|
if self.type != 'video':
|
||||||
duration = None
|
duration = None
|
||||||
|
state = ''
|
||||||
|
if self.available:
|
||||||
|
state = 'available'
|
||||||
|
elif self.encoding:
|
||||||
|
state = 'encoding'
|
||||||
|
elif self.queued:
|
||||||
|
state = 'queued'
|
||||||
|
elif self.uploading:
|
||||||
|
state = 'uploading'
|
||||||
|
elif self.wanted:
|
||||||
|
state = 'wanted'
|
||||||
data = {
|
data = {
|
||||||
'audioCodec': self.audio_codec,
|
'audioCodec': self.audio_codec,
|
||||||
'available': self.available,
|
'available': self.available,
|
||||||
'duration': duration,
|
'duration': duration,
|
||||||
'encoding': self.encoding,
|
'state': state,
|
||||||
'framerate': self.framerate,
|
'framerate': self.framerate,
|
||||||
'id': self.oshash,
|
'id': self.oshash,
|
||||||
'instances': [i.json() for i in self.instances.all()],
|
'instances': [i.json() for i in self.instances.all()],
|
||||||
|
|
|
@ -89,7 +89,7 @@ def process_stream(fileId):
|
||||||
streams = file.streams.filter(source=None)
|
streams = file.streams.filter(source=None)
|
||||||
if streams.count() > 0:
|
if streams.count() > 0:
|
||||||
stream = streams[0]
|
stream = streams[0]
|
||||||
models.File.objects.filter(id=fileId).update(encoding=True)
|
models.File.objects.filter(id=fileId).update(encoding=True, queued=False)
|
||||||
stream.make_timeline()
|
stream.make_timeline()
|
||||||
stream.extract_derivatives()
|
stream.extract_derivatives()
|
||||||
file = models.File.objects.get(id=fileId)
|
file = models.File.objects.get(id=fileId)
|
||||||
|
@ -114,7 +114,7 @@ def extract_stream(fileId):
|
||||||
file=file, resolution=max(config['resolutions']),
|
file=file, resolution=max(config['resolutions']),
|
||||||
format=config['formats'][0])
|
format=config['formats'][0])
|
||||||
if created:
|
if created:
|
||||||
models.File.objects.filter(id=fileId).update(encoding=True)
|
models.File.objects.filter(id=fileId).update(encoding=True, queued=False)
|
||||||
stream.media.name = stream.path(stream.name())
|
stream.media.name = stream.path(stream.name())
|
||||||
stream.encode()
|
stream.encode()
|
||||||
if stream.available:
|
if stream.available:
|
||||||
|
|
|
@ -243,6 +243,7 @@ def firefogg_upload(request):
|
||||||
response['result'] = -1
|
response['result'] = -1
|
||||||
elif form.cleaned_data['done']:
|
elif form.cleaned_data['done']:
|
||||||
f.uploading = False
|
f.uploading = False
|
||||||
|
f.queued = True
|
||||||
f.save()
|
f.save()
|
||||||
#FIXME: this fails badly if rabbitmq goes down
|
#FIXME: this fails badly if rabbitmq goes down
|
||||||
try:
|
try:
|
||||||
|
@ -295,6 +296,7 @@ def direct_upload(request):
|
||||||
response['result'] = -1
|
response['result'] = -1
|
||||||
if form.cleaned_data['done']:
|
if form.cleaned_data['done']:
|
||||||
file.uploading = False
|
file.uploading = False
|
||||||
|
file.queued = True
|
||||||
file.save()
|
file.save()
|
||||||
#try/execpt so it does not fail if rabitmq is down
|
#try/execpt so it does not fail if rabitmq is down
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -76,15 +76,19 @@ pandora.ui.mediaView = function(options, self) {
|
||||||
columns: [
|
columns: [
|
||||||
{
|
{
|
||||||
clickable: function(data) {
|
clickable: function(data) {
|
||||||
return !data.encoding;
|
return ['uploading', 'queued', 'encoding'].indexOf(data.state) == -1;
|
||||||
},
|
},
|
||||||
format: function(value, data) {
|
format: function(value, data) {
|
||||||
return $('<img>')
|
return $('<img>')
|
||||||
.attr({
|
.attr({
|
||||||
src: data.encoding
|
src: ['uploading', 'queued', 'encoding'].indexOf(data.state) > -1
|
||||||
? Ox.UI.getImageURL('symbolSync')
|
? Ox.UI.getImageURL('symbol' + {
|
||||||
|
'uploading': 'Upload',
|
||||||
|
'queued': 'Data',
|
||||||
|
'encoding': 'Sync'
|
||||||
|
}[data.state])
|
||||||
: data.wanted
|
: data.wanted
|
||||||
? Ox.UI.getImageURL('symbolUpload')
|
? Ox.UI.getImageURL('symbolUp')
|
||||||
: Ox.UI.getImageURL('symbolCheck')
|
: Ox.UI.getImageURL('symbolCheck')
|
||||||
})
|
})
|
||||||
.css({
|
.css({
|
||||||
|
@ -99,8 +103,12 @@ pandora.ui.mediaView = function(options, self) {
|
||||||
title: Ox._('Status'),
|
title: Ox._('Status'),
|
||||||
titleImage: 'check',
|
titleImage: 'check',
|
||||||
tooltip: function (data) {
|
tooltip: function (data) {
|
||||||
return data.encoding
|
return ['uploading', 'queued', 'encoding'].indexOf(data.state) > -1
|
||||||
? Ox._('Processing video on server')
|
? Ox._({
|
||||||
|
'uploading': 'Video is currently uploaded to server',
|
||||||
|
'queued': 'Waiting for server to process video',
|
||||||
|
'encoding': 'Processing video on server'
|
||||||
|
}[data.state])
|
||||||
: data.instances.filter(function(i) {return i.ignore; }).length > 0
|
: data.instances.filter(function(i) {return i.ignore; }).length > 0
|
||||||
? Ox._('Use this file')
|
? Ox._('Use this file')
|
||||||
: Ox._('Dont use this file');
|
: Ox._('Dont use this file');
|
||||||
|
@ -226,7 +234,7 @@ pandora.ui.mediaView = function(options, self) {
|
||||||
query: self.filesQuery
|
query: self.filesQuery
|
||||||
}), callback);
|
}), callback);
|
||||||
},
|
},
|
||||||
keys: ['encoding', 'instances', 'wanted'],
|
keys: ['state', 'instances', 'wanted'],
|
||||||
scrollbarVisible: true,
|
scrollbarVisible: true,
|
||||||
sort: [{key: 'path', operator: '+'}],
|
sort: [{key: 'path', operator: '+'}],
|
||||||
unique: 'id'
|
unique: 'id'
|
||||||
|
|
Loading…
Reference in a new issue