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
class AudiobookForm(forms.ModelForm):
class Meta:
model = Audiobook
- exclude = []
+ exclude = [
+ 'youtube_id', 'youtube_queued'
+ ]
def save(self, commit=True, path=None):
""" Performs normal save, with given file as an source audiobook.
# 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))