another background script: encoder
This commit is contained in:
parent
0e7534e963
commit
bf9a91280e
5 changed files with 53 additions and 9 deletions
|
@ -1,6 +1,5 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# vi:si:et:sw=4:sts=4:ts=4
|
# vi:si:et:sw=4:sts=4:ts=4
|
||||||
# Written 2009 by j@mailb.org
|
|
||||||
|
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
|
||||||
|
@ -25,7 +24,6 @@ class MovieAdmin(admin.ModelAdmin):
|
||||||
|
|
||||||
admin.site.register(models.Movie, MovieAdmin)
|
admin.site.register(models.Movie, MovieAdmin)
|
||||||
|
|
||||||
|
|
||||||
class FileAdmin(admin.ModelAdmin):
|
class FileAdmin(admin.ModelAdmin):
|
||||||
search_fields = ['path', 'video_codec']
|
search_fields = ['path', 'video_codec']
|
||||||
|
|
||||||
|
@ -39,7 +37,6 @@ class ArchiveFileAdmin(admin.ModelAdmin):
|
||||||
|
|
||||||
admin.site.register(models.ArchiveFile, ArchiveFileAdmin)
|
admin.site.register(models.ArchiveFile, ArchiveFileAdmin)
|
||||||
|
|
||||||
|
|
||||||
class ArchiveAdmin(admin.ModelAdmin):
|
class ArchiveAdmin(admin.ModelAdmin):
|
||||||
search_fields = ['name']
|
search_fields = ['name']
|
||||||
admin.site.register(models.Archive, ArchiveAdmin)
|
admin.site.register(models.Archive, ArchiveAdmin)
|
||||||
|
|
|
@ -19,10 +19,10 @@ def run():
|
||||||
exchange="oxdb-bg",
|
exchange="oxdb-bg",
|
||||||
routing_key="oxdb-bg")
|
routing_key="oxdb-bg")
|
||||||
def handle_background_tasks_callback(data, message):
|
def handle_background_tasks_callback(data, message):
|
||||||
print("Got feed import message")
|
print("Got bg message")
|
||||||
print data
|
print data
|
||||||
if 'loadIMDb' in data:
|
if 'loadIMDb' in data:
|
||||||
imdbId = message_data['loadIMDb']
|
imdbId = data['loadIMDb']
|
||||||
load.loadIMDb(imdbId)
|
load.loadIMDb(imdbId)
|
||||||
elif 'findMovie' in data:
|
elif 'findMovie' in data:
|
||||||
f = models.File.objects.get(pk=data['findMovie'])
|
f = models.File.objects.get(pk=data['findMovie'])
|
||||||
|
|
43
oxdb/backend/encoder.py
Normal file
43
oxdb/backend/encoder.py
Normal 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.
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# vi:si:et:sw=4:sts=4:ts=4
|
# vi:si:et:sw=4:sts=4:ts=4
|
||||||
# j@v2v.cc
|
|
||||||
import os
|
import os
|
||||||
from os.path import join, dirname, basename, splitext, exists
|
from os.path import join, dirname, basename, splitext, exists
|
||||||
from glob import glob
|
|
||||||
|
|
||||||
from django.core.management.base import BaseCommand, CommandError
|
from django.core.management.base import BaseCommand, CommandError
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
from ... import daemon
|
from ... import daemon
|
||||||
|
|
||||||
|
|
||||||
class Command(BaseCommand):
|
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 = ''
|
args = ''
|
||||||
|
|
||||||
def handle(self, **options):
|
def handle(self, **options):
|
||||||
|
|
|
@ -1107,6 +1107,10 @@ class File(models.Model):
|
||||||
self.movie = getMovie(info)
|
self.movie = getMovie(info)
|
||||||
self.save()
|
self.save()
|
||||||
|
|
||||||
|
def extract(self):
|
||||||
|
#FIXME: do stuff, like create timeline or create smaller videos etc
|
||||||
|
return
|
||||||
|
|
||||||
class Still(models.Model):
|
class Still(models.Model):
|
||||||
created = models.DateTimeField(auto_now_add=True)
|
created = models.DateTimeField(auto_now_add=True)
|
||||||
modified = models.DateTimeField(auto_now=True)
|
modified = models.DateTimeField(auto_now=True)
|
||||||
|
|
Loading…
Reference in a new issue