make pad.ma config work

This commit is contained in:
j 2011-12-15 12:21:21 +01:00
parent a5c9d023c1
commit 4d113c80c6
3 changed files with 26 additions and 11 deletions

View File

@ -21,18 +21,25 @@ class Command(BaseCommand):
if ext in ('.webm', '.mp4'):
oshash = os.path.dirname(f)[-19:].replace('/', '')
format = ext[1:]
resolution = int(profile[:-1])
if profile.endswith('p'):
profile = profile[:-1]
resolution = int(profile)
qs = models.Stream.objects.filter(file__oshash=oshash, format=format, resolution=resolution)
if qs.count() == 0:
print 'add', f
print oshash, resolution, format
stream = models.Stream()
stream.file = models.File.objects.get(oshash=oshash)
stream.resolution = resolution
stream.format = format
stream.video.name = f[len(settings.MEDIA_ROOT)+1:]
self.available = True
stream.save()
qs = models.File.objects.filter(oshash=oshash)
if qs.count() == 1:
stream = models.Stream()
stream.file = qs[0]
stream.resolution = resolution
stream.format = format
stream.video.name = f[len(settings.MEDIA_ROOT)+1:]
stream.available = True
stream.save()
if not stream.file.info:
stream.file.info = stream.info
stream.file.save()
#link streams
resolution = settings.CONFIG['video']['resolutions'][0]
format = settings.CONFIG['video']['formats'][0]
@ -42,3 +49,7 @@ class Command(BaseCommand):
#extract timelines
for s in models.Stream.objects.filter(source=None):
s.make_timeline()
s.file.selected = True
s.file.save()
s.file.item.update_timeline()

View File

@ -158,7 +158,7 @@ class Item(models.Model):
icon = models.ImageField(default=None, blank=True,
upload_to=lambda i, x: i.path("icon.jpg"))
torrent = models.FileField(default=None, blank=True,
torrent = models.FileField(default=None, blank=True, max_length=1000,
upload_to=lambda i, x: i.path('torrent.torrent'))
stream_info = fields.DictField(default={}, editable=False)
@ -851,6 +851,9 @@ class Item(models.Model):
break
def make_torrent(self):
streams = self.streams()
if streams.count() == 0:
return
base = self.path('torrent')
base = os.path.abspath(os.path.join(settings.MEDIA_ROOT, base))
if os.path.exists(base):
@ -861,7 +864,6 @@ class Item(models.Model):
base = os.path.abspath(os.path.join(settings.MEDIA_ROOT, base))
size = 0
duration = 0.0
streams = self.streams()
if streams.count() == 1:
url = "%s/torrent/%s.webm" % (self.get_absolute_url(),
quote(self.get('title').encode('utf-8')))
@ -1069,6 +1071,8 @@ class Item(models.Model):
return icon
def load_subtitles(self):
if not filter(lambda l: l['id'] == 'subtitles', settings.CONFIG['layers']):
return
with transaction.commit_on_success():
layer = 'subtitles'
Annotation.objects.filter(layer=layer,item=self).delete()

View File

@ -762,7 +762,7 @@ def video(request, id, resolution, format, index=None):
# reise Http404
streams = Stream.objects.filter(file__item__itemId=item.itemId,
resolution=resolution, format=format).order_by('file__part')
if index > streams.count():
if index + 1 > streams.count():
raise Http404
stream = streams[index]
if not stream.available or not stream.video: