From 46d02853ce1521c0223192a722c32c9a5ffc9e23 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Thu, 23 Dec 2010 18:02:00 +0530 Subject: [PATCH] symlink stream if item has only one video file, update imdb in background --- pandora/item/models.py | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/pandora/item/models.py b/pandora/item/models.py index cc137acd..50f853ad 100644 --- a/pandora/item/models.py +++ b/pandora/item/models.py @@ -146,9 +146,9 @@ def get_item(info): 'year': info.get('year', '') } #FIXME: this should be done async - #item.save() - #tasks.update_imdb.delay(item.itemId) - item.update_imdb() + item.save() + tasks.update_imdb.delay(item.itemId) + #item.update_imdb() tasks.update_poster.delay(item.itemId) else: q = Item.objects.filter(find__key='title', find__value=info['title']) @@ -652,17 +652,21 @@ class Item(models.Model): stream, created = Stream.objects.get_or_create(item=self, profile='%s.webm' % settings.VIDEO_PROFILE) stream.video.name = stream.path() cmd = [] - print files - for f in sorted(files): - cmd.append('+') - cmd.append(files[f]) - if not os.path.exists(os.path.dirname(stream.video.path)): - os.makedirs(os.path.dirname(stream.video.path)) - cmd = [ 'mkvmerge', '-o', stream.video.path ] + cmd[1:] - #print cmd - p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - #p = subprocess.Popen(cmd, stdin=subprocess.PIPE) - p.wait() + if os.path.exists(stream.video.path): + os.unlink(stream.video.path) + if len(files) > 1: + for f in sorted(files): + cmd.append('+') + cmd.append(files[f]) + if not os.path.exists(os.path.dirname(stream.video.path)): + os.makedirs(os.path.dirname(stream.video.path)) + cmd = [ 'mkvmerge', '-o', stream.video.path ] + cmd[1:] + #print cmd + p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + #p = subprocess.Popen(cmd, stdin=subprocess.PIPE) + p.wait() + else: + os.symlink(files[0], stream.video.path) stream.save() if 'video' in stream.info: