cablegates/pandora/item/tasks.py

33 lines
869 B
Python
Raw Normal View History

# -*- coding: utf-8 -*-
# vi:si:et:sw=4:sts=4:ts=4
from datetime import timedelta
from celery.decorators import task, periodic_task
import models
@periodic_task(run_every=timedelta(days=1))
def cronjob(**kwargs):
print "do some cleanup stuff once a day"
2010-09-10 15:12:22 +00:00
@task(ignore_resulsts=True, queue='default')
def update_poster(itemId):
2010-09-23 16:01:48 +00:00
item = models.Item.objects.get(itemId=itemId)
2010-12-01 00:00:33 +00:00
item.make_poster(True)
2010-09-10 15:12:22 +00:00
@task(ignore_resulsts=True, queue='default')
def update_imdb(itemId):
item = models.Item.objects.get(itemId=itemId)
item.update_imdb()
@task(queue="encoding")
def update_streams(itemId):
'''
create stream, extract timeline and create derivatives
'''
item = models.Item.objects.get(itemId=itemId)
if item.files.filter(is_main=True, is_video=True, available=False).count() == 0:
item.update_streams()
return True