another background script: encoder

This commit is contained in:
j 2010-01-23 10:25:48 +11:00
parent 0e7534e963
commit bf9a91280e
5 changed files with 53 additions and 9 deletions

View file

@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
# vi:si:et:sw=4:sts=4:ts=4
# Written 2009 by j@mailb.org
from django.contrib import admin
@ -25,7 +24,6 @@ class MovieAdmin(admin.ModelAdmin):
admin.site.register(models.Movie, MovieAdmin)
class FileAdmin(admin.ModelAdmin):
search_fields = ['path', 'video_codec']
@ -39,7 +37,6 @@ class ArchiveFileAdmin(admin.ModelAdmin):
admin.site.register(models.ArchiveFile, ArchiveFileAdmin)
class ArchiveAdmin(admin.ModelAdmin):
search_fields = ['name']
admin.site.register(models.Archive, ArchiveAdmin)

View file

@ -19,10 +19,10 @@ def run():
exchange="oxdb-bg",
routing_key="oxdb-bg")
def handle_background_tasks_callback(data, message):
print("Got feed import message")
print("Got bg message")
print data
if 'loadIMDb' in data:
imdbId = message_data['loadIMDb']
imdbId = data['loadIMDb']
load.loadIMDb(imdbId)
elif 'findMovie' in data:
f = models.File.objects.get(pk=data['findMovie'])

43
oxdb/backend/encoder.py Normal file
View file

@ -0,0 +1,43 @@
from carrot.connection import DjangoBrokerConnection
from carrot.messaging import Consumer, Publisher
from django.conf import settings
import load
import models
def send_encoder_message(msg):
conn = DjangoBrokerConnection()
publisher = Publisher(connection=conn, exchange="oxdb-encoder",
routing_key="oxdb-encoder")
publisher.send(msg)
publisher.close()
def run():
conn = DjangoBrokerConnection()
consumer = Consumer(connection=conn, queue="oxdb-encoder",
exchange="oxdb-encoder",
routing_key="oxdb-encoder")
def handle_background_tasks_callback(data, message):
print("Got encoder message")
print data
if 'extract' in data:
'''
update file stuff
create derivates and other related stuff for a file
'''
fileId = data['fileId']
f = models.File.objects.get(pk=fileId)
f.extract()
elif 'updateMovie' in data:
'''
update movie
create proxy stream and other related files extracted from movieFiles
'''
movieId = data['movieId']
m = models.Movie.objects.get(pk=fileId)
m.extract()
message.ack()
consumer.register_callback(handle_background_tasks_callback)
consumer.wait() # Go into the consumer loop.

View file

@ -1,20 +1,20 @@
# -*- coding: utf-8 -*-
# vi:si:et:sw=4:sts=4:ts=4
# j@v2v.cc
import os
from os.path import join, dirname, basename, splitext, exists
from glob import glob
from django.core.management.base import BaseCommand, CommandError
from django.conf import settings
from ... import daemon
class Command(BaseCommand):
"""
listen to rabbitmq and execute background dasks.
listen to rabbitmq and execute background task.
"""
help = 'listen to rabbitmq and execute background dasks.'
help = 'listen to rabbitmq and execute background task.'
args = ''
def handle(self, **options):

View file

@ -1107,6 +1107,10 @@ class File(models.Model):
self.movie = getMovie(info)
self.save()
def extract(self):
#FIXME: do stuff, like create timeline or create smaller videos etc
return
class Still(models.Model):
created = models.DateTimeField(auto_now_add=True)
modified = models.DateTimeField(auto_now=True)