diff --git a/pandora/archive/models.py b/pandora/archive/models.py index f175001..b209cc7 100644 --- a/pandora/archive/models.py +++ b/pandora/archive/models.py @@ -84,7 +84,9 @@ class File(models.Model): self.folder = self.get_folder() self.sort_name = utils.sort_string(canonicalTitle(self.name)) - if self.info: + if not os.path.splitext(self.name)[-1] in ( + '.srt', '.rar', '.sub', '.idx', '.txt', '.jpg', '.png', '.nfo') \ + and self.info: for key in ('duration', 'size'): setattr(self, key, self.info.get(key, 0)) @@ -128,12 +130,14 @@ class File(models.Model): self.pixels = int(self.width * self.height * float(utils.parse_decimal(self.framerate)) * self.duration) else: - self.is_video = os.path.splitext(self.name)[-1] in ('.avi', '.mkv', '.dv', '.ogv', '.mpeg', '.mov') - self.is_audio = os.path.splitext(self.name)[-1] in ('.mp3', '.wav', '.ogg', '.flac') + self.is_video = os.path.splitext(self.name)[-1] in ('.avi', '.mkv', '.dv', '.ogv', '.mpeg', '.mov', '.webm') + self.is_audio = os.path.splitext(self.name)[-1] in ('.mp3', '.wav', '.ogg', '.flac', '.oga') self.is_subtitle = os.path.splitext(self.name)[-1] in ('.srt', ) - if not self.is_audio and not self.is_video and self.name.endswith('.srt'): + if self.name.endswith('.srt'): self.is_subtitle = True + self.is_audio = False + self.is_video = False else: self.is_subtitle = False diff --git a/pandora/archive/views.py b/pandora/archive/views.py index e179b75..ee3b0a5 100644 --- a/pandora/archive/views.py +++ b/pandora/archive/views.py @@ -105,6 +105,7 @@ def update(request): file__available=False, file__wanted=True)] response['data']['file'] = [f.file.oshash for f in files.filter(file__is_subtitle=True, + file__available=False, name__endswith='.srt')] return render_to_json_response(response) @@ -149,6 +150,8 @@ def upload(request): response = json_response(status=403, text='permissino denied') if 'file' in request.FILES: if not f.available: + if f.data: + f.data.delete() f.data.save('data.raw', request.FILES['file']) f.available = True f.save() diff --git a/pandora/item/models.py b/pandora/item/models.py index 06a3ffc..a9f438a 100644 --- a/pandora/item/models.py +++ b/pandora/item/models.py @@ -729,11 +729,11 @@ class Item(models.Model): users = self.users_with_files() if users.filter(is_superuser=True).count()>0: files = self.files.filter(instances__volume__user__is_superuser=True) - users = User.objects.filter(volumes__files__file__item__in=files, + users = User.objects.filter(volumes__files__file__in=files, is_superuser=True).distinct() elif users.filter(is_staff=True).count()>0: files = self.files.filter(instances__volume__user__is_staff=True) - users = User.objects.filter(volumes__files__file__item__in=files, + users = User.objects.filter(volumes__files__file__in=files, is_staff=True).distinct() else: files = self.files.all()