forked from 0x2620/pandora
cache stream state
This commit is contained in:
parent
5f87203531
commit
020a3e1808
2 changed files with 6 additions and 6 deletions
|
@ -227,7 +227,7 @@ def moveFiles(request):
|
||||||
'''
|
'''
|
||||||
change file / item link
|
change file / item link
|
||||||
param data {
|
param data {
|
||||||
ids: hashes of files
|
ids: ids of files
|
||||||
itemId: new itemId
|
itemId: new itemId
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -123,6 +123,7 @@ class Item(models.Model):
|
||||||
|
|
||||||
torrent = models.FileField(default=None, blank=True,
|
torrent = models.FileField(default=None, blank=True,
|
||||||
upload_to=lambda i, x: i.path('torrent.torrent'))
|
upload_to=lambda i, x: i.path('torrent.torrent'))
|
||||||
|
stream_info = fields.DictField(default={}, editable=False)
|
||||||
|
|
||||||
#stream related fields
|
#stream related fields
|
||||||
stream_aspect = models.FloatField(default=4/3)
|
stream_aspect = models.FloatField(default=4/3)
|
||||||
|
@ -671,15 +672,14 @@ class Item(models.Model):
|
||||||
self.torrent.name = self.path('torrent/%s.torrent' % self.get('title'))
|
self.torrent.name = self.path('torrent/%s.torrent' % self.get('title'))
|
||||||
self.save()
|
self.save()
|
||||||
|
|
||||||
def update_streams(self):
|
def update_streams(self, force=False):
|
||||||
files = {}
|
files = {}
|
||||||
for f in self.main_videos():
|
for f in self.main_videos():
|
||||||
files[utils.sort_title(f.name)] = f.video.path
|
files[utils.sort_title(f.name)] = f.video.path
|
||||||
|
if force or self.stream_info != files:
|
||||||
#FIXME: how to detect if something changed?
|
self.stream_info = files
|
||||||
if files:
|
|
||||||
stream, created = Stream.objects.get_or_create(item=self,
|
stream, created = Stream.objects.get_or_create(item=self,
|
||||||
profile=settings.VIDEO_PROFILE)
|
profile=settings.VIDEO_PROFILE)
|
||||||
stream.video.name = stream.path()
|
stream.video.name = stream.path()
|
||||||
cmd = []
|
cmd = []
|
||||||
if os.path.exists(stream.video.path):
|
if os.path.exists(stream.video.path):
|
||||||
|
|
Loading…
Reference in a new issue