mirror of
https://github.com/meeb/tubesync.git
synced 2025-06-24 14:06:36 +00:00
Use Media.has_metadata
in Media.save
function
This commit is contained in:
parent
98c031ed5f
commit
60ffc4cdc8
@ -830,14 +830,21 @@ class Media(models.Model):
|
||||
update_fields = {'media_file', 'skip'}.union(update_fields)
|
||||
|
||||
# Trigger an update of derived fields from metadata
|
||||
if update_fields is None or 'metadata' in update_fields:
|
||||
update_md = (
|
||||
self.created and
|
||||
self.has_metadata and
|
||||
(
|
||||
update_fields is None or
|
||||
'metadata' in update_fields
|
||||
)
|
||||
)
|
||||
if update_md:
|
||||
setattr(self, '_cached_metadata_dict', None)
|
||||
if self.metadata:
|
||||
self.title = self.metadata_title[:200]
|
||||
self.duration = self.metadata_duration
|
||||
if update_fields is not None and "metadata" in update_fields:
|
||||
# If only some fields are being updated, make sure we update title and duration if metadata changes
|
||||
update_fields = {"title", "duration"}.union(update_fields)
|
||||
if update_fields is not None:
|
||||
# If only some fields are being updated, make sure we update title and duration if metadata changes
|
||||
update_fields = {"title", "duration"}.union(update_fields)
|
||||
|
||||
super().save(
|
||||
force_insert=force_insert,
|
||||
|
Loading…
Reference in New Issue
Block a user