X-Git-Url: https://git.mdrn.pl/audio.git/blobdiff_plain/eee35e00bf0d0eb3d2a9f08f72c7052962fecbf6..10ee4271e2cb35c585726a1c306e6c4ef561b257:/src/archive/forms.py diff --git a/src/archive/forms.py b/src/archive/forms.py index 81568c6..eca8f1a 100644 --- a/src/archive/forms.py +++ b/src/archive/forms.py @@ -3,10 +3,11 @@ import os import os.path from django import forms -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ import mutagen from django.utils.encoding import force_bytes +from youtube.utils import get_duration from archive.models import Audiobook from archive.settings import FILES_PATH, NEW_PATH from archive.utils import ExistingFile, sha1_file @@ -14,6 +15,9 @@ from archive.utils import ExistingFile, sha1_file class AudiobookForm(forms.ModelForm): class Meta: model = Audiobook + exclude = [ + 'youtube_id', 'youtube_queued' + ] def save(self, commit=True, path=None): """ Performs normal save, with given file as an source audiobook. @@ -30,6 +34,7 @@ class AudiobookForm(forms.ModelForm): # save the file in model abs_path = os.path.join(NEW_PATH, path) + m.duration = get_duration(abs_path) m.source_file.save( path, ExistingFile(abs_path))