From ef587970995a67641b15f2c1cc682e7f1be9964e Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Sun, 21 Aug 2011 10:57:53 +0200 Subject: [PATCH] available --- pandora/archive/models.py | 4 ++++ pandora/item/models.py | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pandora/archive/models.py b/pandora/archive/models.py index 42ea3556a..9cfed69f5 100644 --- a/pandora/archive/models.py +++ b/pandora/archive/models.py @@ -161,6 +161,7 @@ class File(models.Model): def save(self, *args, **kwargs): if self.auto: self.set_state() + self.available = self.streams.filter(source=None, available=True).count() > 0 super(File, self).save(*args, **kwargs) #upload and data handling @@ -498,6 +499,7 @@ class Stream(models.Model): resolution=resolution, format=f) if created: derivative.source = self + derivative.save() name = derivative.name() derivative.video.name = os.path.join(os.path.dirname(self.video.name), name) derivative.encode() @@ -528,6 +530,8 @@ class Stream(models.Model): else: self.aspect_ratio = 128/80 super(Stream, self).save(*args, **kwargs) + if self.available and not self.file.available: + self.file.save() def json(self): if settings.XSENDFILE or settings.XACCELREDIRECT: diff --git a/pandora/item/models.py b/pandora/item/models.py index 24d66b3e5..1ecc18b1d 100644 --- a/pandora/item/models.py +++ b/pandora/item/models.py @@ -793,7 +793,8 @@ class Item(models.Model): self.save() def streams(self): - return [video.streams.filter(source=None)[0] for video in self.main_videos()] + return [video.streams.filter(source=None, available=True)[0] + for video in self.main_videos()] def update_timeline(self, force=False): config = site_config()