symlink stream if item has only one video file, update imdb in background

This commit is contained in:
j 2010-12-23 18:02:00 +05:30
parent ccddcae5e5
commit 46d02853ce

View file

@ -146,9 +146,9 @@ def get_item(info):
'year': info.get('year', '') 'year': info.get('year', '')
} }
#FIXME: this should be done async #FIXME: this should be done async
#item.save() item.save()
#tasks.update_imdb.delay(item.itemId) tasks.update_imdb.delay(item.itemId)
item.update_imdb() #item.update_imdb()
tasks.update_poster.delay(item.itemId) tasks.update_poster.delay(item.itemId)
else: else:
q = Item.objects.filter(find__key='title', find__value=info['title']) 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, created = Stream.objects.get_or_create(item=self, profile='%s.webm' % settings.VIDEO_PROFILE)
stream.video.name = stream.path() stream.video.name = stream.path()
cmd = [] cmd = []
print files if os.path.exists(stream.video.path):
for f in sorted(files): os.unlink(stream.video.path)
cmd.append('+') if len(files) > 1:
cmd.append(files[f]) for f in sorted(files):
if not os.path.exists(os.path.dirname(stream.video.path)): cmd.append('+')
os.makedirs(os.path.dirname(stream.video.path)) cmd.append(files[f])
cmd = [ 'mkvmerge', '-o', stream.video.path ] + cmd[1:] if not os.path.exists(os.path.dirname(stream.video.path)):
#print cmd os.makedirs(os.path.dirname(stream.video.path))
p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) cmd = [ 'mkvmerge', '-o', stream.video.path ] + cmd[1:]
#p = subprocess.Popen(cmd, stdin=subprocess.PIPE) #print cmd
p.wait() 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() stream.save()
if 'video' in stream.info: if 'video' in stream.info: